summaryrefslogtreecommitdiff
path: root/libbcachefs/disk_groups.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-10-18 21:57:11 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-18 22:14:53 -0400
commit6a34032417d9bb90ead6f3b7bf891347bc4a1ed3 (patch)
treef2c1cf29f8651cc5ac41504a441a15d39b22f807 /libbcachefs/disk_groups.c
parent9f98746bfcd5159307237f7a491fd79db02d8bf3 (diff)
Update bcachefs sources to a180af9dd349 bcachefs: Refactor memcpy into direct assignment
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'libbcachefs/disk_groups.c')
-rw-r--r--libbcachefs/disk_groups.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/libbcachefs/disk_groups.c b/libbcachefs/disk_groups.c
index 43aad8ba..e00133b6 100644
--- a/libbcachefs/disk_groups.c
+++ b/libbcachefs/disk_groups.c
@@ -157,14 +157,13 @@ int bch2_sb_disk_groups_to_cpu(struct bch_fs *c)
lockdep_assert_held(&c->sb_lock);
- groups = bch2_sb_get_disk_groups(c->disk_sb.sb);
+ groups = bch2_sb_field_get(c->disk_sb.sb, disk_groups);
nr_groups = disk_groups_nr(groups);
if (!groups)
return 0;
- cpu_g = kzalloc(sizeof(*cpu_g) +
- sizeof(cpu_g->entries[0]) * nr_groups, GFP_KERNEL);
+ cpu_g = kzalloc(struct_size(cpu_g, entries, nr_groups), GFP_KERNEL);
if (!cpu_g)
return -BCH_ERR_ENOMEM_disk_groups_to_cpu;
@@ -296,7 +295,7 @@ static int __bch2_disk_group_add(struct bch_sb_handle *sb, unsigned parent,
const char *name, unsigned namelen)
{
struct bch_sb_field_disk_groups *groups =
- bch2_sb_get_disk_groups(sb->sb);
+ bch2_sb_field_get(sb->sb, disk_groups);
unsigned i, nr_groups = disk_groups_nr(groups);
struct bch_disk_group *g;
@@ -314,7 +313,7 @@ static int __bch2_disk_group_add(struct bch_sb_handle *sb, unsigned parent,
sizeof(struct bch_disk_group) * (nr_groups + 1)) /
sizeof(u64);
- groups = bch2_sb_resize_disk_groups(sb, u64s);
+ groups = bch2_sb_field_resize(sb, disk_groups, u64s);
if (!groups)
return -BCH_ERR_ENOSPC_disk_label_add;
@@ -338,7 +337,7 @@ static int __bch2_disk_group_add(struct bch_sb_handle *sb, unsigned parent,
int bch2_disk_path_find(struct bch_sb_handle *sb, const char *name)
{
struct bch_sb_field_disk_groups *groups =
- bch2_sb_get_disk_groups(sb->sb);
+ bch2_sb_field_get(sb->sb, disk_groups);
int v = -1;
do {
@@ -368,7 +367,7 @@ int bch2_disk_path_find_or_create(struct bch_sb_handle *sb, const char *name)
if (*next == '.')
next++;
- groups = bch2_sb_get_disk_groups(sb->sb);
+ groups = bch2_sb_field_get(sb->sb, disk_groups);
v = __bch2_disk_group_find(groups, parent, name, len);
if (v < 0)
@@ -386,7 +385,7 @@ int bch2_disk_path_find_or_create(struct bch_sb_handle *sb, const char *name)
void bch2_disk_path_to_text(struct printbuf *out, struct bch_sb *sb, unsigned v)
{
struct bch_sb_field_disk_groups *groups =
- bch2_sb_get_disk_groups(sb);
+ bch2_sb_field_get(sb, disk_groups);
struct bch_disk_group *g;
unsigned nr = 0;
u16 path[32];