summaryrefslogtreecommitdiff
path: root/fs/bcachefs/replicas.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-09-26 17:49:34 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:16 -0400
commit4637429e3946d083eedde1668c17a4fadaf3c0b1 (patch)
treee963537ab982b1a82fa0aa33afab53713ce33fa7 /fs/bcachefs/replicas.c
parentbe47e0ba4fc92bd065ac0b7ad345913eea1bc6fc (diff)
bcachefs: bch2_sb_field_get() refactoring
Instead of using token pasting to generate methods for each superblock section, just make the type a parameter to bch2_sb_field_get(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/replicas.c')
-rw-r--r--fs/bcachefs/replicas.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/bcachefs/replicas.c b/fs/bcachefs/replicas.c
index a9a694fb0b18..cef2a0447b86 100644
--- a/fs/bcachefs/replicas.c
+++ b/fs/bcachefs/replicas.c
@@ -700,9 +700,9 @@ int bch2_sb_replicas_to_cpu_replicas(struct bch_fs *c)
struct bch_replicas_cpu new_r = { 0, 0, NULL };
int ret = 0;
- if ((sb_v1 = bch2_sb_get_replicas(c->disk_sb.sb)))
+ if ((sb_v1 = bch2_sb_field_get(c->disk_sb.sb, replicas)))
ret = __bch2_sb_replicas_to_cpu_replicas(sb_v1, &new_r);
- else if ((sb_v0 = bch2_sb_get_replicas_v0(c->disk_sb.sb)))
+ else if ((sb_v0 = bch2_sb_field_get(c->disk_sb.sb, replicas_v0)))
ret = __bch2_sb_replicas_v0_to_cpu_replicas(sb_v0, &new_r);
if (ret)
return ret;
@@ -732,13 +732,13 @@ static int bch2_cpu_replicas_to_sb_replicas_v0(struct bch_fs *c,
for_each_cpu_replicas_entry(r, src)
bytes += replicas_entry_bytes(src) - 1;
- sb_r = bch2_sb_resize_replicas_v0(&c->disk_sb,
+ sb_r = bch2_sb_field_resize(&c->disk_sb, replicas_v0,
DIV_ROUND_UP(bytes, sizeof(u64)));
if (!sb_r)
return -BCH_ERR_ENOSPC_sb_replicas;
bch2_sb_field_delete(&c->disk_sb, BCH_SB_FIELD_replicas);
- sb_r = bch2_sb_get_replicas_v0(c->disk_sb.sb);
+ sb_r = bch2_sb_field_get(c->disk_sb.sb, replicas_v0);
memset(&sb_r->entries, 0,
vstruct_end(&sb_r->field) -
@@ -777,13 +777,13 @@ static int bch2_cpu_replicas_to_sb_replicas(struct bch_fs *c,
if (!need_v1)
return bch2_cpu_replicas_to_sb_replicas_v0(c, r);
- sb_r = bch2_sb_resize_replicas(&c->disk_sb,
+ sb_r = bch2_sb_field_resize(&c->disk_sb, replicas,
DIV_ROUND_UP(bytes, sizeof(u64)));
if (!sb_r)
return -BCH_ERR_ENOSPC_sb_replicas;
bch2_sb_field_delete(&c->disk_sb, BCH_SB_FIELD_replicas_v0);
- sb_r = bch2_sb_get_replicas(c->disk_sb.sb);
+ sb_r = bch2_sb_field_get(c->disk_sb.sb, replicas);
memset(&sb_r->entries, 0,
vstruct_end(&sb_r->field) -
@@ -998,8 +998,8 @@ unsigned bch2_sb_dev_has_data(struct bch_sb *sb, unsigned dev)
struct bch_sb_field_replicas_v0 *replicas_v0;
unsigned i, data_has = 0;
- replicas = bch2_sb_get_replicas(sb);
- replicas_v0 = bch2_sb_get_replicas_v0(sb);
+ replicas = bch2_sb_field_get(sb, replicas);
+ replicas_v0 = bch2_sb_field_get(sb, replicas_v0);
if (replicas) {
struct bch_replicas_entry *r;