bcachefs: Use x-macros for compat feature bits
This is to generate strings for them, so that we can print them out. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
33a391a255
commit
19dd3172b0
@ -1370,11 +1370,17 @@ enum bch_sb_feature {
|
||||
BCH_FEATURE_NR,
|
||||
};
|
||||
|
||||
#define BCH_SB_COMPAT() \
|
||||
x(alloc_info, 0) \
|
||||
x(alloc_metadata, 1) \
|
||||
x(extents_above_btree_updates_done, 2) \
|
||||
x(bformat_overflow_done, 3)
|
||||
|
||||
enum bch_sb_compat {
|
||||
BCH_COMPAT_FEAT_ALLOC_INFO = 0,
|
||||
BCH_COMPAT_FEAT_ALLOC_METADATA = 1,
|
||||
BCH_COMPAT_FEAT_EXTENTS_ABOVE_BTREE_UPDATES_DONE = 2,
|
||||
BCH_COMPAT_FEAT_BFORMAT_OVERFLOW_DONE = 3,
|
||||
#define x(f, n) BCH_COMPAT_##f,
|
||||
BCH_SB_COMPAT()
|
||||
#undef x
|
||||
BCH_COMPAT_NR,
|
||||
};
|
||||
|
||||
/* options: */
|
||||
|
@ -762,7 +762,7 @@ static int bch2_gc_done(struct bch_fs *c,
|
||||
{
|
||||
struct bch_dev *ca;
|
||||
bool verify = (!initial ||
|
||||
(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_ALLOC_INFO)));
|
||||
(c->sb.compat & (1ULL << BCH_COMPAT_alloc_info)));
|
||||
unsigned i, dev;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -757,6 +757,9 @@ next:
|
||||
out:
|
||||
bch2_trans_exit(&trans);
|
||||
|
||||
if (ret)
|
||||
bch_err(c, "error %i in bch2_move_btree", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -880,8 +883,8 @@ int bch2_scan_old_btree_nodes(struct bch_fs *c, struct bch_move_stats *stats)
|
||||
rewrite_old_nodes_pred, c, stats);
|
||||
if (!ret) {
|
||||
mutex_lock(&c->sb_lock);
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_FEAT_EXTENTS_ABOVE_BTREE_UPDATES_DONE;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_FEAT_BFORMAT_OVERFLOW_DONE;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_extents_above_btree_updates_done;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_bformat_overflow_done;
|
||||
c->disk_sb.sb->version_min = c->disk_sb.sb->version;
|
||||
bch2_write_super(c);
|
||||
mutex_unlock(&c->sb_lock);
|
||||
|
@ -23,6 +23,13 @@ const char * const bch2_sb_features[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
const char * const bch2_sb_compat[] = {
|
||||
#define x(f, n) #f,
|
||||
BCH_SB_COMPAT()
|
||||
#undef x
|
||||
NULL
|
||||
};
|
||||
|
||||
const char * const bch2_csum_opts[] = {
|
||||
"none",
|
||||
"crc32c",
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
extern const char * const bch2_error_actions[];
|
||||
extern const char * const bch2_sb_features[];
|
||||
extern const char * const bch2_sb_compat[];
|
||||
extern const char * const bch2_csum_opts[];
|
||||
extern const char * const bch2_compression_opts[];
|
||||
extern const char * const bch2_str_hash_types[];
|
||||
|
@ -933,7 +933,7 @@ static int read_btree_roots(struct bch_fs *c)
|
||||
|
||||
if (i == BTREE_ID_ALLOC &&
|
||||
c->opts.reconstruct_alloc) {
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_FEAT_ALLOC_INFO);
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -943,7 +943,7 @@ static int read_btree_roots(struct bch_fs *c)
|
||||
"invalid btree root %s",
|
||||
bch2_btree_ids[i]);
|
||||
if (i == BTREE_ID_ALLOC)
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_FEAT_ALLOC_INFO);
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
|
||||
}
|
||||
|
||||
ret = bch2_btree_root_read(c, i, &r->key, r->level);
|
||||
@ -953,7 +953,7 @@ static int read_btree_roots(struct bch_fs *c)
|
||||
"error reading btree root %s",
|
||||
bch2_btree_ids[i]);
|
||||
if (i == BTREE_ID_ALLOC)
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_FEAT_ALLOC_INFO);
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1020,7 +1020,7 @@ int bch2_fs_recovery(struct bch_fs *c)
|
||||
last_journal_entry &&
|
||||
!journal_entry_empty(last_journal_entry), c,
|
||||
"filesystem marked clean but journal not empty")) {
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_FEAT_ALLOC_INFO);
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
|
||||
SET_BCH_SB_CLEAN(c->disk_sb.sb, false);
|
||||
c->sb.clean = false;
|
||||
}
|
||||
@ -1061,7 +1061,7 @@ use_clean:
|
||||
}
|
||||
|
||||
if (c->opts.reconstruct_alloc) {
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_FEAT_ALLOC_INFO);
|
||||
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
|
||||
drop_alloc_keys(&c->journal_keys);
|
||||
}
|
||||
|
||||
@ -1114,8 +1114,8 @@ use_clean:
|
||||
set_bit(BCH_FS_ALLOC_READ_DONE, &c->flags);
|
||||
|
||||
if (c->opts.fsck ||
|
||||
!(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_ALLOC_INFO)) ||
|
||||
!(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_ALLOC_METADATA)) ||
|
||||
!(c->sb.compat & (1ULL << BCH_COMPAT_alloc_info)) ||
|
||||
!(c->sb.compat & (1ULL << BCH_COMPAT_alloc_metadata)) ||
|
||||
test_bit(BCH_FS_REBUILD_REPLICAS, &c->flags)) {
|
||||
bch_info(c, "starting mark and sweep");
|
||||
err = "error in mark and sweep";
|
||||
@ -1201,11 +1201,11 @@ use_clean:
|
||||
bch_verbose(c, "quotas done");
|
||||
}
|
||||
|
||||
if (!(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_EXTENTS_ABOVE_BTREE_UPDATES_DONE)) ||
|
||||
!(c->sb.compat & (1ULL << BCH_COMPAT_FEAT_BFORMAT_OVERFLOW_DONE))) {
|
||||
if (!(c->sb.compat & (1ULL << BCH_COMPAT_extents_above_btree_updates_done)) ||
|
||||
!(c->sb.compat & (1ULL << BCH_COMPAT_bformat_overflow_done))) {
|
||||
struct bch_move_stats stats = { 0 };
|
||||
|
||||
bch_verbose(c, "scanning for old btree nodes");
|
||||
bch_info(c, "scanning for old btree nodes");
|
||||
ret = bch2_fs_read_write(c);
|
||||
if (ret)
|
||||
goto err;
|
||||
@ -1213,7 +1213,7 @@ use_clean:
|
||||
ret = bch2_scan_old_btree_nodes(c, &stats);
|
||||
if (ret)
|
||||
goto err;
|
||||
bch_verbose(c, "scanning for old btree nodes done");
|
||||
bch_info(c, "scanning for old btree nodes done");
|
||||
}
|
||||
|
||||
mutex_lock(&c->sb_lock);
|
||||
@ -1227,7 +1227,7 @@ use_clean:
|
||||
}
|
||||
|
||||
if (!test_bit(BCH_FS_ERROR, &c->flags)) {
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_FEAT_ALLOC_INFO;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_alloc_info;
|
||||
write_sb = true;
|
||||
}
|
||||
|
||||
@ -1287,8 +1287,8 @@ int bch2_fs_initialize(struct bch_fs *c)
|
||||
le16_to_cpu(bcachefs_metadata_version_current);
|
||||
c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_atomic_nlink;
|
||||
c->disk_sb.sb->features[0] |= BCH_SB_FEATURES_ALL;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_FEAT_EXTENTS_ABOVE_BTREE_UPDATES_DONE;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_FEAT_BFORMAT_OVERFLOW_DONE;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_extents_above_btree_updates_done;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_bformat_overflow_done;
|
||||
|
||||
bch2_write_super(c);
|
||||
mutex_unlock(&c->sb_lock);
|
||||
|
@ -382,7 +382,6 @@ static void bch2_sb_update(struct bch_fs *c)
|
||||
ca->mi = bch2_mi_to_cpu(mi->members + i);
|
||||
}
|
||||
|
||||
/* doesn't copy member info */
|
||||
static void __copy_super(struct bch_sb_handle *dst_handle, struct bch_sb *src)
|
||||
{
|
||||
struct bch_sb_field *src_f, *dst_f;
|
||||
@ -1083,8 +1082,8 @@ void bch2_fs_mark_clean(struct bch_fs *c)
|
||||
|
||||
SET_BCH_SB_CLEAN(c->disk_sb.sb, true);
|
||||
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_FEAT_ALLOC_INFO;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_FEAT_ALLOC_METADATA;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_alloc_info;
|
||||
c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_alloc_metadata;
|
||||
c->disk_sb.sb->features[0] &= ~(1ULL << BCH_FEATURE_extents_above_btree_updates);
|
||||
c->disk_sb.sb->features[0] &= ~(1ULL << BCH_FEATURE_btree_updates_journalled);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user