summaryrefslogtreecommitdiff
path: root/fs/bcachefs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs')
-rw-r--r--fs/bcachefs/alloc_background.c10
-rw-r--r--fs/bcachefs/bcachefs.h18
-rw-r--r--fs/bcachefs/bcachefs_format.h20
-rw-r--r--fs/bcachefs/bkey_methods.c30
-rw-r--r--fs/bcachefs/btree_cache.c7
-rw-r--r--fs/bcachefs/btree_cache.h2
-rw-r--r--fs/bcachefs/btree_gc.h2
-rw-r--r--fs/bcachefs/btree_io.c2
-rw-r--r--fs/bcachefs/btree_io.h4
-rw-r--r--fs/bcachefs/btree_types.h30
-rw-r--r--fs/bcachefs/btree_update_interior.c2
-rw-r--r--fs/bcachefs/btree_update_leaf.c2
-rw-r--r--fs/bcachefs/buckets.c10
-rw-r--r--fs/bcachefs/dirent.c6
-rw-r--r--fs/bcachefs/ec.c16
-rw-r--r--fs/bcachefs/extent_update.c2
-rw-r--r--fs/bcachefs/extents.c2
-rw-r--r--fs/bcachefs/fs-io.c14
-rw-r--r--fs/bcachefs/fs.c2
-rw-r--r--fs/bcachefs/fsck.c26
-rw-r--r--fs/bcachefs/inode.c18
-rw-r--r--fs/bcachefs/io.c18
-rw-r--r--fs/bcachefs/migrate.c4
-rw-r--r--fs/bcachefs/move.c6
-rw-r--r--fs/bcachefs/opts.c7
-rw-r--r--fs/bcachefs/opts.h1
-rw-r--r--fs/bcachefs/quota.c12
-rw-r--r--fs/bcachefs/recovery.c20
-rw-r--r--fs/bcachefs/reflink.c6
-rw-r--r--fs/bcachefs/super-io.c2
-rw-r--r--fs/bcachefs/super.c4
-rw-r--r--fs/bcachefs/sysfs.c2
-rw-r--r--fs/bcachefs/tests.c50
-rw-r--r--fs/bcachefs/xattr.c4
34 files changed, 180 insertions, 181 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index 54e58b377e51..34590e4b8f5d 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -316,7 +316,7 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
int ret;
down_read(&c->gc_lock);
- ret = bch2_btree_and_journal_walk(c, journal_keys, BTREE_ID_ALLOC,
+ ret = bch2_btree_and_journal_walk(c, journal_keys, BTREE_ID_alloc,
NULL, bch2_alloc_read_fn);
up_read(&c->gc_lock);
@@ -344,7 +344,7 @@ retry:
bch2_trans_begin(trans);
ret = bch2_btree_key_cache_flush(trans,
- BTREE_ID_ALLOC, iter->pos);
+ BTREE_ID_alloc, iter->pos);
if (ret)
goto err;
@@ -386,7 +386,7 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags)
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_ALLOC, POS_MIN,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_alloc, POS_MIN,
BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
for_each_member_device(ca, c, i) {
@@ -423,7 +423,7 @@ int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
u64 *time, now;
int ret = 0;
- iter = bch2_trans_get_iter(trans, BTREE_ID_ALLOC, POS(dev, bucket_nr),
+ iter = bch2_trans_get_iter(trans, BTREE_ID_alloc, POS(dev, bucket_nr),
BTREE_ITER_CACHED|
BTREE_ITER_CACHED_NOFILL|
BTREE_ITER_INTENT);
@@ -927,7 +927,7 @@ static int bch2_invalidate_buckets(struct bch_fs *c, struct bch_dev *ca)
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_ALLOC,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_alloc,
POS(ca->dev_idx, 0),
BTREE_ITER_CACHED|
BTREE_ITER_CACHED_NOFILL|
diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h
index 51ba38f19ca9..9f4e7a3ada36 100644
--- a/fs/bcachefs/bcachefs.h
+++ b/fs/bcachefs/bcachefs.h
@@ -369,14 +369,14 @@ enum gc_phase {
GC_PHASE_START,
GC_PHASE_SB,
- GC_PHASE_BTREE_EC,
- GC_PHASE_BTREE_EXTENTS,
- GC_PHASE_BTREE_INODES,
- GC_PHASE_BTREE_DIRENTS,
- GC_PHASE_BTREE_XATTRS,
- GC_PHASE_BTREE_ALLOC,
- GC_PHASE_BTREE_QUOTAS,
- GC_PHASE_BTREE_REFLINK,
+ GC_PHASE_BTREE_stripes,
+ GC_PHASE_BTREE_extents,
+ GC_PHASE_BTREE_inodes,
+ GC_PHASE_BTREE_dirents,
+ GC_PHASE_BTREE_xattrs,
+ GC_PHASE_BTREE_alloc,
+ GC_PHASE_BTREE_quotas,
+ GC_PHASE_BTREE_reflink,
GC_PHASE_PENDING_DELETE,
GC_PHASE_ALLOC,
@@ -722,7 +722,7 @@ struct bch_fs {
* Tracks GC's progress - everything in the range [ZERO_KEY..gc_cur_pos]
* has been marked by GC.
*
- * gc_cur_phase is a superset of btree_ids (BTREE_ID_EXTENTS etc.)
+ * gc_cur_phase is a superset of btree_ids (BTREE_ID_extents etc.)
*
* Protected by gc_pos_lock. Only written to by GC thread, so GC thread
* can read without a lock.
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index 1df6b7c6e4d7..e9e501a8c3ec 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -1658,18 +1658,18 @@ LE32_BITMASK(JSET_NO_FLUSH, struct jset, flags, 5, 6);
/* Btree: */
-#define BCH_BTREE_IDS() \
- x(EXTENTS, 0, "extents") \
- x(INODES, 1, "inodes") \
- x(DIRENTS, 2, "dirents") \
- x(XATTRS, 3, "xattrs") \
- x(ALLOC, 4, "alloc") \
- x(QUOTAS, 5, "quotas") \
- x(EC, 6, "stripes") \
- x(REFLINK, 7, "reflink")
+#define BCH_BTREE_IDS() \
+ x(extents, 0) \
+ x(inodes, 1) \
+ x(dirents, 2) \
+ x(xattrs, 3) \
+ x(alloc, 4) \
+ x(quotas, 5) \
+ x(stripes, 6) \
+ x(reflink, 7)
enum btree_id {
-#define x(kwd, val, name) BTREE_ID_##kwd = val,
+#define x(kwd, val) BTREE_ID_##kwd = val,
BCH_BTREE_IDS()
#undef x
BTREE_ID_NR
diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c
index 756bf5aeee9b..79e249f49971 100644
--- a/fs/bcachefs/bkey_methods.c
+++ b/fs/bcachefs/bkey_methods.c
@@ -104,7 +104,7 @@ const char *__bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
if (k.k->u64s < BKEY_U64s)
return "u64s too small";
- if (type == BKEY_TYPE_BTREE &&
+ if (type == BKEY_TYPE_btree &&
bkey_val_u64s(k.k) > BKEY_BTREE_PTR_VAL_U64s_MAX)
return "value too big";
@@ -122,7 +122,7 @@ const char *__bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
if (k.k->p.snapshot)
return "nonzero snapshot";
- if (type != BKEY_TYPE_BTREE &&
+ if (type != BKEY_TYPE_btree &&
!bkey_cmp(k.k->p, POS_MAX))
return "POS_MAX key";
@@ -263,18 +263,18 @@ static const struct old_bkey_type {
u8 old;
u8 new;
} bkey_renumber_table[] = {
- {BKEY_TYPE_BTREE, 128, KEY_TYPE_btree_ptr },
- {BKEY_TYPE_EXTENTS, 128, KEY_TYPE_extent },
- {BKEY_TYPE_EXTENTS, 129, KEY_TYPE_extent },
- {BKEY_TYPE_EXTENTS, 130, KEY_TYPE_reservation },
- {BKEY_TYPE_INODES, 128, KEY_TYPE_inode },
- {BKEY_TYPE_INODES, 130, KEY_TYPE_inode_generation },
- {BKEY_TYPE_DIRENTS, 128, KEY_TYPE_dirent },
- {BKEY_TYPE_DIRENTS, 129, KEY_TYPE_hash_whiteout },
- {BKEY_TYPE_XATTRS, 128, KEY_TYPE_xattr },
- {BKEY_TYPE_XATTRS, 129, KEY_TYPE_hash_whiteout },
- {BKEY_TYPE_ALLOC, 128, KEY_TYPE_alloc },
- {BKEY_TYPE_QUOTAS, 128, KEY_TYPE_quota },
+ {BKEY_TYPE_btree, 128, KEY_TYPE_btree_ptr },
+ {BKEY_TYPE_extents, 128, KEY_TYPE_extent },
+ {BKEY_TYPE_extents, 129, KEY_TYPE_extent },
+ {BKEY_TYPE_extents, 130, KEY_TYPE_reservation },
+ {BKEY_TYPE_inodes, 128, KEY_TYPE_inode },
+ {BKEY_TYPE_inodes, 130, KEY_TYPE_inode_generation },
+ {BKEY_TYPE_dirents, 128, KEY_TYPE_dirent },
+ {BKEY_TYPE_dirents, 129, KEY_TYPE_hash_whiteout },
+ {BKEY_TYPE_xattrs, 128, KEY_TYPE_xattr },
+ {BKEY_TYPE_xattrs, 129, KEY_TYPE_hash_whiteout },
+ {BKEY_TYPE_alloc, 128, KEY_TYPE_alloc },
+ {BKEY_TYPE_quotas, 128, KEY_TYPE_quota },
};
void bch2_bkey_renumber(enum btree_node_type btree_node_type,
@@ -320,7 +320,7 @@ void __bch2_bkey_compat(unsigned level, enum btree_id btree_id,
break;
case 2:
if (version < bcachefs_metadata_version_inode_btree_change &&
- btree_id == BTREE_ID_INODES) {
+ btree_id == BTREE_ID_inodes) {
if (!bkey_packed(k)) {
struct bkey_i *u = packed_to_bkey(k);
swap(u->k.p.inode, u->k.p.offset);
diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c
index 97b4f87a377f..1a6b4618c2ae 100644
--- a/fs/bcachefs/btree_cache.c
+++ b/fs/bcachefs/btree_cache.c
@@ -13,13 +13,6 @@
#include <linux/prefetch.h>
#include <linux/sched/mm.h>
-const char * const bch2_btree_ids[] = {
-#define x(kwd, val, name) name,
- BCH_BTREE_IDS()
-#undef x
- NULL
-};
-
void bch2_recalc_btree_reserve(struct bch_fs *c)
{
unsigned i, reserve = 16;
diff --git a/fs/bcachefs/btree_cache.h b/fs/bcachefs/btree_cache.h
index 5fffae92effb..217988696a77 100644
--- a/fs/bcachefs/btree_cache.h
+++ b/fs/bcachefs/btree_cache.h
@@ -7,8 +7,6 @@
struct btree_iter;
-extern const char * const bch2_btree_ids[];
-
void bch2_recalc_btree_reserve(struct bch_fs *);
void bch2_btree_node_hash_remove(struct btree_cache *, struct btree *);
diff --git a/fs/bcachefs/btree_gc.h b/fs/bcachefs/btree_gc.h
index f516faded269..d5559827ed7f 100644
--- a/fs/bcachefs/btree_gc.h
+++ b/fs/bcachefs/btree_gc.h
@@ -57,7 +57,7 @@ static inline int gc_pos_cmp(struct gc_pos l, struct gc_pos r)
static inline enum gc_phase btree_id_to_gc_phase(enum btree_id id)
{
switch (id) {
-#define x(n, v, s) case BTREE_ID_##n: return GC_PHASE_BTREE_##n;
+#define x(name, v) case BTREE_ID_##name: return GC_PHASE_BTREE_##name;
BCH_BTREE_IDS()
#undef x
default:
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index f081233a1ef1..b7d931335dd6 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -1321,7 +1321,7 @@ static int validate_bset_for_write(struct bch_fs *c, struct btree *b,
unsigned whiteout_u64s = 0;
int ret;
- if (bch2_bkey_invalid(c, bkey_i_to_s_c(&b->key), BKEY_TYPE_BTREE))
+ if (bch2_bkey_invalid(c, bkey_i_to_s_c(&b->key), BKEY_TYPE_btree))
return -1;
ret = validate_bset(c, NULL, b, i, sectors, WRITE, false) ?:
diff --git a/fs/bcachefs/btree_io.h b/fs/bcachefs/btree_io.h
index 89685bd57fc0..16ce6dff6af7 100644
--- a/fs/bcachefs/btree_io.h
+++ b/fs/bcachefs/btree_io.h
@@ -193,7 +193,7 @@ static inline void compat_bformat(unsigned level, enum btree_id btree_id,
int write, struct bkey_format *f)
{
if (version < bcachefs_metadata_version_inode_btree_change &&
- btree_id == BTREE_ID_INODES) {
+ btree_id == BTREE_ID_inodes) {
swap(f->bits_per_field[BKEY_FIELD_INODE],
f->bits_per_field[BKEY_FIELD_OFFSET]);
swap(f->field_offset[BKEY_FIELD_INODE],
@@ -209,7 +209,7 @@ static inline void compat_bpos(unsigned level, enum btree_id btree_id,
bch2_bpos_swab(p);
if (version < bcachefs_metadata_version_inode_btree_change &&
- btree_id == BTREE_ID_INODES)
+ btree_id == BTREE_ID_inodes)
swap(p->inode, p->offset);
}
diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h
index 35511d47ae97..fcaa13b9129c 100644
--- a/fs/bcachefs/btree_types.h
+++ b/fs/bcachefs/btree_types.h
@@ -545,16 +545,16 @@ static inline unsigned bset_byte_offset(struct btree *b, void *i)
}
enum btree_node_type {
-#define x(kwd, val, name) BKEY_TYPE_##kwd = val,
+#define x(kwd, val) BKEY_TYPE_##kwd = val,
BCH_BTREE_IDS()
#undef x
- BKEY_TYPE_BTREE,
+ BKEY_TYPE_btree,
};
/* Type of a key in btree @id at level @level: */
static inline enum btree_node_type __btree_node_type(unsigned level, enum btree_id id)
{
- return level ? BKEY_TYPE_BTREE : (enum btree_node_type) id;
+ return level ? BKEY_TYPE_btree : (enum btree_node_type) id;
}
/* Type of keys @b contains: */
@@ -566,8 +566,8 @@ static inline enum btree_node_type btree_node_type(struct btree *b)
static inline bool btree_node_type_is_extents(enum btree_node_type type)
{
switch (type) {
- case BKEY_TYPE_EXTENTS:
- case BKEY_TYPE_REFLINK:
+ case BKEY_TYPE_extents:
+ case BKEY_TYPE_reflink:
return true;
default:
return false;
@@ -590,18 +590,18 @@ static inline bool btree_iter_is_extents(struct btree_iter *iter)
}
#define BTREE_NODE_TYPE_HAS_TRIGGERS \
- ((1U << BKEY_TYPE_EXTENTS)| \
- (1U << BKEY_TYPE_ALLOC)| \
- (1U << BKEY_TYPE_INODES)| \
- (1U << BKEY_TYPE_REFLINK)| \
- (1U << BKEY_TYPE_EC)| \
- (1U << BKEY_TYPE_BTREE))
+ ((1U << BKEY_TYPE_extents)| \
+ (1U << BKEY_TYPE_alloc)| \
+ (1U << BKEY_TYPE_inodes)| \
+ (1U << BKEY_TYPE_reflink)| \
+ (1U << BKEY_TYPE_stripes)| \
+ (1U << BKEY_TYPE_btree))
#define BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS \
- ((1U << BKEY_TYPE_EXTENTS)| \
- (1U << BKEY_TYPE_INODES)| \
- (1U << BKEY_TYPE_EC)| \
- (1U << BKEY_TYPE_REFLINK))
+ ((1U << BKEY_TYPE_extents)| \
+ (1U << BKEY_TYPE_inodes)| \
+ (1U << BKEY_TYPE_stripes)| \
+ (1U << BKEY_TYPE_reflink))
enum btree_trigger_flags {
__BTREE_TRIGGER_NORUN, /* Don't run triggers at all */
diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c
index 961191881b48..e1dd21320153 100644
--- a/fs/bcachefs/btree_update_interior.c
+++ b/fs/bcachefs/btree_update_interior.c
@@ -1196,7 +1196,7 @@ static void btree_split_insert_keys(struct btree_update *as, struct btree *b,
struct bkey_packed *src, *dst, *n;
struct bset *i;
- BUG_ON(btree_node_type(b) != BKEY_TYPE_BTREE);
+ BUG_ON(btree_node_type(b) != BKEY_TYPE_btree);
bch2_btree_node_iter_init(&node_iter, b, &k->k.p);
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index 6100f164278b..c46016961284 100644
--- a/fs/bcachefs/btree_update_leaf.c
+++ b/fs/bcachefs/btree_update_leaf.c
@@ -341,7 +341,7 @@ static inline bool iter_has_nontrans_triggers(struct btree_iter *iter)
{
return (((BTREE_NODE_TYPE_HAS_TRIGGERS &
~BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS)) |
- (1U << BTREE_ID_EC)) &
+ (1U << BTREE_ID_stripes)) &
(1U << iter->btree_id);
}
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index 3dcc77d5242f..55b9818a1dc2 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -1509,7 +1509,7 @@ static int trans_get_key(struct btree_trans *trans,
struct btree_iter **iter,
struct bkey_s_c *k)
{
- unsigned flags = btree_id != BTREE_ID_ALLOC
+ unsigned flags = btree_id != BTREE_ID_alloc
? BTREE_ITER_SLOTS
: BTREE_ITER_CACHED;
int ret;
@@ -1545,11 +1545,11 @@ bch2_trans_start_alloc_update(struct btree_trans *trans, struct btree_iter **_it
if (IS_ERR(a))
return a;
- iter = trans_get_update(trans, BTREE_ID_ALLOC, pos, &k);
+ iter = trans_get_update(trans, BTREE_ID_alloc, pos, &k);
if (iter) {
*u = bch2_alloc_unpack(k);
} else {
- iter = bch2_trans_get_iter(trans, BTREE_ID_ALLOC, pos,
+ iter = bch2_trans_get_iter(trans, BTREE_ID_alloc, pos,
BTREE_ITER_CACHED|
BTREE_ITER_CACHED_NOFILL|
BTREE_ITER_INTENT);
@@ -1606,7 +1606,7 @@ static int bch2_trans_mark_stripe_ptr(struct btree_trans *trans,
struct bch_replicas_padded r;
int ret = 0;
- ret = trans_get_key(trans, BTREE_ID_EC, POS(0, p.ec.idx), &iter, &k);
+ ret = trans_get_key(trans, BTREE_ID_stripes, POS(0, p.ec.idx), &iter, &k);
if (ret < 0)
return ret;
@@ -1830,7 +1830,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans,
__le64 *refcount;
s64 ret;
- ret = trans_get_key(trans, BTREE_ID_REFLINK,
+ ret = trans_get_key(trans, BTREE_ID_reflink,
POS(0, idx), &iter, &k);
if (ret < 0)
return ret;
diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c
index d2ebf1e5819d..b0625176ab35 100644
--- a/fs/bcachefs/dirent.c
+++ b/fs/bcachefs/dirent.c
@@ -64,7 +64,7 @@ static bool dirent_cmp_bkey(struct bkey_s_c _l, struct bkey_s_c _r)
}
const struct bch_hash_desc bch2_dirent_hash_desc = {
- .btree_id = BTREE_ID_DIRENTS,
+ .btree_id = BTREE_ID_dirents,
.key_type = KEY_TYPE_dirent,
.hash_key = dirent_hash_key,
.hash_bkey = dirent_hash_bkey,
@@ -332,7 +332,7 @@ int bch2_empty_dir_trans(struct btree_trans *trans, u64 dir_inum)
struct bkey_s_c k;
int ret;
- for_each_btree_key(trans, iter, BTREE_ID_DIRENTS,
+ for_each_btree_key(trans, iter, BTREE_ID_dirents,
POS(dir_inum, 0), 0, k, ret) {
if (k.k->p.inode > dir_inum)
break;
@@ -357,7 +357,7 @@ int bch2_readdir(struct bch_fs *c, u64 inum, struct dir_context *ctx)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_DIRENTS,
+ for_each_btree_key(&trans, iter, BTREE_ID_dirents,
POS(inum, ctx->pos), 0, k, ret) {
if (k.k->p.inode > inum)
break;
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index a70b859363f0..ced8ceeef992 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -433,7 +433,7 @@ static int get_stripe_key(struct bch_fs *c, u64 idx, struct ec_stripe_buf *strip
int ret;
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EC, POS(0, idx), BTREE_ITER_SLOTS);
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_stripes, POS(0, idx), BTREE_ITER_SLOTS);
k = bch2_btree_iter_peek_slot(iter);
ret = bkey_err(k);
if (ret)
@@ -668,7 +668,7 @@ void bch2_stripes_heap_update(struct bch_fs *c,
static int ec_stripe_delete(struct bch_fs *c, size_t idx)
{
- return bch2_btree_delete_range(c, BTREE_ID_EC,
+ return bch2_btree_delete_range(c, BTREE_ID_stripes,
POS(0, idx),
POS(0, idx + 1),
NULL);
@@ -713,7 +713,7 @@ static int ec_stripe_bkey_insert(struct bch_fs *c,
retry:
bch2_trans_begin(&trans);
- for_each_btree_key(&trans, iter, BTREE_ID_EC, start_pos,
+ for_each_btree_key(&trans, iter, BTREE_ID_stripes, start_pos,
BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
if (bkey_cmp(k.k->p, POS(0, U32_MAX)) > 0) {
if (start_pos.offset) {
@@ -765,7 +765,7 @@ static int ec_stripe_bkey_update(struct btree_trans *trans,
unsigned i;
int ret;
- iter = bch2_trans_get_iter(trans, BTREE_ID_EC,
+ iter = bch2_trans_get_iter(trans, BTREE_ID_stripes,
new->k.p, BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter);
ret = bkey_err(k);
@@ -831,7 +831,7 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
/* XXX this doesn't support the reflink btree */
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents,
bkey_start_pos(pos),
BTREE_ITER_INTENT);
@@ -1604,7 +1604,7 @@ int bch2_stripes_write(struct bch_fs *c, unsigned flags)
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EC, POS_MIN,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_stripes, POS_MIN,
BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
genradix_for_each(&c->stripes[0], giter, m) {
@@ -1645,7 +1645,7 @@ static int bch2_stripes_read_fn(struct bch_fs *c, enum btree_id id,
int bch2_stripes_read(struct bch_fs *c, struct journal_keys *journal_keys)
{
- int ret = bch2_btree_and_journal_walk(c, journal_keys, BTREE_ID_EC,
+ int ret = bch2_btree_and_journal_walk(c, journal_keys, BTREE_ID_stripes,
NULL, bch2_stripes_read_fn);
if (ret)
bch_err(c, "error reading stripes: %i", ret);
@@ -1663,7 +1663,7 @@ int bch2_ec_mem_alloc(struct bch_fs *c, bool gc)
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EC, POS(0, U64_MAX), 0);
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_stripes, POS(0, U64_MAX), 0);
k = bch2_btree_iter_prev(iter);
if (!IS_ERR_OR_NULL(k.k))
diff --git a/fs/bcachefs/extent_update.c b/fs/bcachefs/extent_update.c
index 16d2bca8a662..bb4b2b4352e0 100644
--- a/fs/bcachefs/extent_update.c
+++ b/fs/bcachefs/extent_update.c
@@ -62,7 +62,7 @@ static int count_iters_for_insert(struct btree_trans *trans,
struct bkey_s_c r_k;
for_each_btree_key(trans, iter,
- BTREE_ID_REFLINK, POS(0, idx + offset),
+ BTREE_ID_reflink, POS(0, idx + offset),
BTREE_ITER_SLOTS, r_k, ret2) {
if (bkey_cmp(bkey_start_pos(r_k.k),
POS(0, idx + sectors)) >= 0)
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c
index 08236ceac4df..515840bc3eaa 100644
--- a/fs/bcachefs/extents.c
+++ b/fs/bcachefs/extents.c
@@ -676,7 +676,7 @@ bool bch2_check_range_allocated(struct bch_fs *c, struct bpos pos, u64 size,
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS, pos,
+ for_each_btree_key(&trans, iter, BTREE_ID_extents, pos,
BTREE_ITER_SLOTS, k, err) {
if (bkey_cmp(bkey_start_pos(k.k), end) >= 0)
break;
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index 80ef9d6df287..4ccc9318a924 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -865,7 +865,7 @@ void bch2_readahead(struct readahead_control *ractl)
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS, POS_MIN,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents, POS_MIN,
BTREE_ITER_SLOTS);
bch2_pagecache_add_get(&inode->ei_pagecache_lock);
@@ -911,7 +911,7 @@ static void __bchfs_readpage(struct bch_fs *c, struct bch_read_bio *rbio,
BUG_ON(!bio_add_page(&rbio->bio, page, PAGE_SIZE, 0));
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS, POS_MIN,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents, POS_MIN,
BTREE_ITER_SLOTS);
bchfs_read(&trans, iter, rbio, inum, NULL);
@@ -2144,7 +2144,7 @@ static inline int range_has_data(struct bch_fs *c,
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS, start, 0, k, ret) {
+ for_each_btree_key(&trans, iter, BTREE_ID_extents, start, 0, k, ret) {
if (bkey_cmp(bkey_start_pos(k.k), end) >= 0)
break;
@@ -2520,7 +2520,7 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
goto err;
}
- src = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ src = bch2_trans_get_iter(&trans, BTREE_ID_extents,
POS(inode->v.i_ino, src_start >> 9),
BTREE_ITER_INTENT);
dst = bch2_trans_copy_iter(&trans, src);
@@ -2675,7 +2675,7 @@ static long bchfs_fallocate(struct bch_inode_info *inode, int mode,
truncate_pagecache_range(&inode->v, offset, end - 1);
}
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents,
POS(inode->v.i_ino, block_start >> 9),
BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
end_pos = POS(inode->v.i_ino, block_end >> 9);
@@ -3006,7 +3006,7 @@ static loff_t bch2_seek_data(struct file *file, u64 offset)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS,
+ for_each_btree_key(&trans, iter, BTREE_ID_extents,
POS(inode->v.i_ino, offset >> 9), 0, k, ret) {
if (k.k->p.inode != inode->v.i_ino) {
break;
@@ -3101,7 +3101,7 @@ static loff_t bch2_seek_hole(struct file *file, u64 offset)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS,
+ for_each_btree_key(&trans, iter, BTREE_ID_extents,
POS(inode->v.i_ino, offset >> 9),
BTREE_ITER_SLOTS, k, ret) {
if (k.k->p.inode != inode->v.i_ino) {
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c
index bcb2f83fe354..2d5e00a42b3e 100644
--- a/fs/bcachefs/fs.c
+++ b/fs/bcachefs/fs.c
@@ -916,7 +916,7 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info,
bch2_bkey_buf_init(&prev);
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents,
POS(ei->v.i_ino, start >> 9), 0);
retry:
while ((k = bch2_btree_iter_peek(iter)).k &&
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c
index 7f78edcfe565..ebc234b0b6fe 100644
--- a/fs/bcachefs/fsck.c
+++ b/fs/bcachefs/fsck.c
@@ -24,7 +24,7 @@ static s64 bch2_count_inode_sectors(struct btree_trans *trans, u64 inum)
u64 sectors = 0;
int ret;
- for_each_btree_key(trans, iter, BTREE_ID_EXTENTS,
+ for_each_btree_key(trans, iter, BTREE_ID_extents,
POS(inum, 0), 0, k, ret) {
if (k.k->p.inode != inum)
break;
@@ -396,7 +396,7 @@ err_redo:
if (fsck_err(c, "cannot fix dirent by removing trailing garbage %s (%zu)\n"
"hash table key at wrong offset: btree %u, offset %llu, "
"hashed to %llu chain starts at %llu\n%s",
- buf, strlen(buf), BTREE_ID_DIRENTS,
+ buf, strlen(buf), BTREE_ID_dirents,
k->k->p.offset, hash, h->chain->pos.offset,
(bch2_bkey_val_to_text(&PBUF(buf), c,
*k), buf))) {
@@ -415,7 +415,7 @@ err_redo:
static int bch2_inode_truncate(struct bch_fs *c, u64 inode_nr, u64 new_size)
{
- return bch2_btree_delete_range(c, BTREE_ID_EXTENTS,
+ return bch2_btree_delete_range(c, BTREE_ID_extents,
POS(inode_nr, round_up(new_size, block_bytes(c)) >> 9),
POS(inode_nr + 1, 0), NULL);
}
@@ -474,7 +474,7 @@ static int check_extents(struct bch_fs *c)
bch_verbose(c, "checking extents");
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents,
POS(BCACHEFS_ROOT_INO, 0),
BTREE_ITER_INTENT);
retry:
@@ -537,7 +537,7 @@ retry:
bch2_inode_pack(c, &p, &w.inode);
- ret = bch2_btree_insert(c, BTREE_ID_INODES,
+ ret = bch2_btree_insert(c, BTREE_ID_inodes,
&p.inode.k_i, NULL, NULL,
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW);
@@ -595,7 +595,7 @@ static int check_dirents(struct bch_fs *c)
hash_check_init(&h);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_DIRENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_dirents,
POS(BCACHEFS_ROOT_INO, 0), 0);
retry:
for_each_btree_key_continue(iter, 0, k, ret) {
@@ -747,7 +747,7 @@ static int check_xattrs(struct bch_fs *c)
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_XATTRS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_xattrs,
POS(BCACHEFS_ROOT_INO, 0), 0);
retry:
for_each_btree_key_continue(iter, 0, k, ret) {
@@ -810,7 +810,7 @@ create_root:
bch2_inode_pack(c, &packed, root_inode);
- return bch2_btree_insert(c, BTREE_ID_INODES, &packed.inode.k_i,
+ return bch2_btree_insert(c, BTREE_ID_inodes, &packed.inode.k_i,
NULL, NULL,
BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW);
@@ -958,7 +958,7 @@ next:
if (e->offset == U64_MAX)
goto up;
- for_each_btree_key(&trans, iter, BTREE_ID_DIRENTS,
+ for_each_btree_key(&trans, iter, BTREE_ID_dirents,
POS(e->inum, e->offset + 1), 0, k, ret) {
if (k.k->p.inode != e->inum)
break;
@@ -1011,7 +1011,7 @@ up:
path.nr--;
}
- iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS_MIN, 0);
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_inodes, POS_MIN, 0);
retry:
for_each_btree_key_continue(iter, 0, k, ret) {
if (k.k->type != KEY_TYPE_inode)
@@ -1108,7 +1108,7 @@ static int bch2_gc_walk_dirents(struct bch_fs *c, nlink_table *links,
inc_link(c, links, range_start, range_end, BCACHEFS_ROOT_INO, false);
- for_each_btree_key(&trans, iter, BTREE_ID_DIRENTS, POS_MIN, 0, k, ret) {
+ for_each_btree_key(&trans, iter, BTREE_ID_dirents, POS_MIN, 0, k, ret) {
switch (k.k->type) {
case KEY_TYPE_dirent:
d = bkey_s_c_to_dirent(k);
@@ -1349,7 +1349,7 @@ static int bch2_gc_walk_inodes(struct bch_fs *c,
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_inodes,
POS(0, range_start), 0);
nlinks_iter = genradix_iter_init(links, 0);
@@ -1475,7 +1475,7 @@ int bch2_fsck_walk_inodes_only(struct bch_fs *c)
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_INODES, POS_MIN, 0, k, ret) {
+ for_each_btree_key(&trans, iter, BTREE_ID_inodes, POS_MIN, 0, k, ret) {
if (k.k->type != KEY_TYPE_inode)
continue;
diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c
index 8377d39ccc4d..a3d2bae0a652 100644
--- a/fs/bcachefs/inode.c
+++ b/fs/bcachefs/inode.c
@@ -300,7 +300,7 @@ struct btree_iter *bch2_inode_peek(struct btree_trans *trans,
struct bkey_s_c k;
int ret;
- iter = bch2_trans_get_iter(trans, BTREE_ID_INODES, POS(0, inum),
+ iter = bch2_trans_get_iter(trans, BTREE_ID_inodes, POS(0, inum),
BTREE_ITER_CACHED|flags);
k = bch2_btree_iter_peek_cached(iter);
ret = bkey_err(k);
@@ -498,7 +498,7 @@ int bch2_inode_create(struct btree_trans *trans,
if (IS_ERR(inode_p))
return PTR_ERR(inode_p);
again:
- for_each_btree_key(trans, iter, BTREE_ID_INODES, POS(0, start),
+ for_each_btree_key(trans, iter, BTREE_ID_inodes, POS(0, start),
BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
if (bkey_cmp(iter->pos, POS(0, max)) > 0)
break;
@@ -513,7 +513,7 @@ again:
* cache before using a slot:
*/
if (k.k->type != KEY_TYPE_inode &&
- !bch2_btree_key_cache_find(c, BTREE_ID_INODES, iter->pos))
+ !bch2_btree_key_cache_find(c, BTREE_ID_inodes, iter->pos))
goto found_slot;
}
@@ -560,11 +560,11 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached)
* XXX: the dirent could ideally would delete whiteouts when they're no
* longer needed
*/
- ret = bch2_btree_delete_range_trans(&trans, BTREE_ID_EXTENTS,
+ ret = bch2_btree_delete_range_trans(&trans, BTREE_ID_extents,
start, end, NULL) ?:
- bch2_btree_delete_range_trans(&trans, BTREE_ID_XATTRS,
+ bch2_btree_delete_range_trans(&trans, BTREE_ID_xattrs,
start, end, NULL) ?:
- bch2_btree_delete_range_trans(&trans, BTREE_ID_DIRENTS,
+ bch2_btree_delete_range_trans(&trans, BTREE_ID_dirents,
start, end, NULL);
if (ret)
goto err;
@@ -574,11 +574,11 @@ retry:
bi_generation = 0;
if (cached) {
- iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS(0, inode_nr),
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_inodes, POS(0, inode_nr),
BTREE_ITER_CACHED|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_cached(iter);
} else {
- iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS(0, inode_nr),
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_inodes, POS(0, inode_nr),
BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter);
}
@@ -636,7 +636,7 @@ int __bch2_inode_find_by_inum_trans(struct btree_trans *trans, u64 inode_nr,
struct bkey_s_c k;
int ret;
- iter = bch2_trans_get_iter(trans, BTREE_ID_INODES,
+ iter = bch2_trans_get_iter(trans, BTREE_ID_inodes,
POS(0, inode_nr), flags);
k = (flags & BTREE_ITER_TYPE) == BTREE_ITER_CACHED
? bch2_btree_iter_peek_cached(iter)
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index 8a4d05eee381..de3bd22edb5a 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -408,7 +408,7 @@ int bch2_fpunch(struct bch_fs *c, u64 inum, u64 start, u64 end,
int ret = 0;
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 1024);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents,
POS(inum, start),
BTREE_ITER_INTENT);
@@ -435,7 +435,7 @@ int bch2_write_index_default(struct bch_write_op *op)
bch2_bkey_buf_init(&sk);
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 1024);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents,
bkey_start_pos(&k->k),
BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
@@ -1530,8 +1530,8 @@ static struct promote_op *promote_alloc(struct bch_fs *c,
promote = __promote_alloc(c,
k.k->type == KEY_TYPE_reflink_v
- ? BTREE_ID_REFLINK
- : BTREE_ID_EXTENTS,
+ ? BTREE_ID_reflink
+ : BTREE_ID_extents,
k, pos, pick, opts, sectors, rbio);
if (!promote)
return NULL;
@@ -1627,7 +1627,7 @@ static void bch2_read_retry_nodecode(struct bch_fs *c, struct bch_read_bio *rbio
bch2_bkey_buf_init(&sk);
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents,
rbio->pos, BTREE_ITER_SLOTS);
retry:
rbio->bio.bi_status = 0;
@@ -1682,7 +1682,7 @@ static void bch2_read_retry(struct bch_fs *c, struct bch_read_bio *rbio,
retry:
bch2_trans_begin(&trans);
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS,
+ for_each_btree_key(&trans, iter, BTREE_ID_extents,
POS(inode, bvec_iter.bi_sector),
BTREE_ITER_SLOTS, k, ret) {
unsigned bytes, sectors, offset_into_extent;
@@ -1801,7 +1801,7 @@ static int __bch2_rbio_narrow_crcs(struct btree_trans *trans,
if (crc_is_compressed(rbio->pick.crc))
return 0;
- iter = bch2_trans_get_iter(trans, BTREE_ID_EXTENTS, rbio->pos,
+ iter = bch2_trans_get_iter(trans, BTREE_ID_extents, rbio->pos,
BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter);
if ((ret = bkey_err(k)))
@@ -2011,7 +2011,7 @@ int __bch2_read_indirect_extent(struct btree_trans *trans,
reflink_offset = le64_to_cpu(bkey_i_to_reflink_p(orig_k->k)->v.idx) +
*offset_into_extent;
- iter = bch2_trans_get_iter(trans, BTREE_ID_REFLINK,
+ iter = bch2_trans_get_iter(trans, BTREE_ID_reflink,
POS(0, reflink_offset),
BTREE_ITER_SLOTS);
k = bch2_btree_iter_peek_slot(iter);
@@ -2319,7 +2319,7 @@ void bch2_read(struct bch_fs *c, struct bch_read_bio *rbio, u64 inode)
retry:
bch2_trans_begin(&trans);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents,
POS(inode, rbio->bio.bi_iter.bi_sector),
BTREE_ITER_SLOTS);
while (1) {
diff --git a/fs/bcachefs/migrate.c b/fs/bcachefs/migrate.c
index 6241ff0c129f..1db2c2d6b970 100644
--- a/fs/bcachefs/migrate.c
+++ b/fs/bcachefs/migrate.c
@@ -99,8 +99,8 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags
static int bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
{
- return __bch2_dev_usrdata_drop(c, dev_idx, flags, BTREE_ID_EXTENTS) ?:
- __bch2_dev_usrdata_drop(c, dev_idx, flags, BTREE_ID_REFLINK);
+ return __bch2_dev_usrdata_drop(c, dev_idx, flags, BTREE_ID_extents) ?:
+ __bch2_dev_usrdata_drop(c, dev_idx, flags, BTREE_ID_reflink);
}
static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c
index 2343f41715ef..dfe7f05f39e9 100644
--- a/fs/bcachefs/move.c
+++ b/fs/bcachefs/move.c
@@ -578,7 +578,7 @@ peek:
if (!bkey_extent_is_direct_data(k.k))
goto next_nondata;
- if (btree_id == BTREE_ID_EXTENTS &&
+ if (btree_id == BTREE_ID_extents &&
cur_inum != k.k->p.inode) {
struct bch_inode_unpacked inode;
@@ -668,8 +668,8 @@ int bch2_move_data(struct bch_fs *c,
id++) {
stats->btree_id = id;
- if (id != BTREE_ID_EXTENTS &&
- id != BTREE_ID_REFLINK)
+ if (id != BTREE_ID_extents &&
+ id != BTREE_ID_reflink)
continue;
ret = __bch2_move_data(c, &ctxt, rate, wp,
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
index d53b6dccd161..a6c734efe328 100644
--- a/fs/bcachefs/opts.c
+++ b/fs/bcachefs/opts.c
@@ -30,6 +30,13 @@ const char * const bch2_sb_compat[] = {
NULL
};
+const char * const bch2_btree_ids[] = {
+#define x(name, ...) #name,
+ BCH_BTREE_IDS()
+#undef x
+ NULL
+};
+
const char * const bch2_csum_opts[] = {
"none",
"crc32c",
diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
index d2b3549a33af..38d78ca46c9c 100644
--- a/fs/bcachefs/opts.h
+++ b/fs/bcachefs/opts.h
@@ -11,6 +11,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_btree_ids[];
extern const char * const bch2_csum_opts[];
extern const char * const bch2_compression_opts[];
extern const char * const bch2_str_hash_types[];
diff --git a/fs/bcachefs/quota.c b/fs/bcachefs/quota.c
index d3032a46e7f3..041da982d051 100644
--- a/fs/bcachefs/quota.c
+++ b/fs/bcachefs/quota.c
@@ -363,7 +363,7 @@ static int bch2_quota_init_type(struct bch_fs *c, enum quota_types type)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_QUOTAS, POS(type, 0),
+ for_each_btree_key(&trans, iter, BTREE_ID_quotas, POS(type, 0),
BTREE_ITER_PREFETCH, k, ret) {
if (k.k->p.inode != type)
break;
@@ -435,7 +435,7 @@ int bch2_fs_quota_read(struct bch_fs *c)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_INODES, POS_MIN,
+ for_each_btree_key(&trans, iter, BTREE_ID_inodes, POS_MIN,
BTREE_ITER_PREFETCH, k, ret) {
switch (k.k->type) {
case KEY_TYPE_inode:
@@ -526,7 +526,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
if (c->opts.usrquota)
return -EINVAL;
- ret = bch2_btree_delete_range(c, BTREE_ID_QUOTAS,
+ ret = bch2_btree_delete_range(c, BTREE_ID_quotas,
POS(QTYP_USR, 0),
POS(QTYP_USR + 1, 0),
NULL);
@@ -538,7 +538,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
if (c->opts.grpquota)
return -EINVAL;
- ret = bch2_btree_delete_range(c, BTREE_ID_QUOTAS,
+ ret = bch2_btree_delete_range(c, BTREE_ID_quotas,
POS(QTYP_GRP, 0),
POS(QTYP_GRP + 1, 0),
NULL);
@@ -550,7 +550,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
if (c->opts.prjquota)
return -EINVAL;
- ret = bch2_btree_delete_range(c, BTREE_ID_QUOTAS,
+ ret = bch2_btree_delete_range(c, BTREE_ID_quotas,
POS(QTYP_PRJ, 0),
POS(QTYP_PRJ + 1, 0),
NULL);
@@ -718,7 +718,7 @@ static int bch2_set_quota_trans(struct btree_trans *trans,
struct bkey_s_c k;
int ret;
- iter = bch2_trans_get_iter(trans, BTREE_ID_QUOTAS, new_quota->k.p,
+ iter = bch2_trans_get_iter(trans, BTREE_ID_quotas, new_quota->k.p,
BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter);
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index 4d7badcc568b..b68fcd1d19e4 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -33,7 +33,7 @@ static void drop_alloc_keys(struct journal_keys *keys)
size_t src, dst;
for (src = 0, dst = 0; src < keys->nr; src++)
- if (keys->d[src].btree_id != BTREE_ID_ALLOC)
+ if (keys->d[src].btree_id != BTREE_ID_alloc)
keys->d[dst++] = keys->d[src];
keys->nr = dst;
@@ -554,7 +554,7 @@ static int __bch2_alloc_replay_key(struct btree_trans *trans, struct bkey_i *k)
struct btree_iter *iter;
int ret;
- iter = bch2_trans_get_iter(trans, BTREE_ID_ALLOC, k->k.p,
+ iter = bch2_trans_get_iter(trans, BTREE_ID_alloc, k->k.p,
BTREE_ITER_CACHED|
BTREE_ITER_CACHED_NOFILL|
BTREE_ITER_INTENT);
@@ -606,7 +606,7 @@ static int bch2_journal_replay(struct bch_fs *c,
for_each_journal_key(keys, i) {
cond_resched();
- if (!i->level && i->btree_id == BTREE_ID_ALLOC) {
+ if (!i->level && i->btree_id == BTREE_ID_alloc) {
j->replay_journal_seq = keys.journal_seq_base + i->journal_seq;
ret = bch2_alloc_replay_key(c, i->k);
if (ret)
@@ -645,7 +645,7 @@ static int bch2_journal_replay(struct bch_fs *c,
for_each_journal_key(keys, i) {
cond_resched();
- if (i->level || i->btree_id == BTREE_ID_ALLOC)
+ if (i->level || i->btree_id == BTREE_ID_alloc)
continue;
replay_now_at(j, keys.journal_seq_base + i->journal_seq);
@@ -931,28 +931,28 @@ static int read_btree_roots(struct bch_fs *c)
if (!r->alive)
continue;
- if (i == BTREE_ID_ALLOC &&
+ if (i == BTREE_ID_alloc &&
c->opts.reconstruct_alloc) {
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
continue;
}
if (r->error) {
- __fsck_err(c, i == BTREE_ID_ALLOC
+ __fsck_err(c, i == BTREE_ID_alloc
? FSCK_CAN_IGNORE : 0,
"invalid btree root %s",
bch2_btree_ids[i]);
- if (i == BTREE_ID_ALLOC)
+ if (i == BTREE_ID_alloc)
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
}
ret = bch2_btree_root_read(c, i, &r->key, r->level);
if (ret) {
- __fsck_err(c, i == BTREE_ID_ALLOC
+ __fsck_err(c, i == BTREE_ID_alloc
? FSCK_CAN_IGNORE : 0,
"error reading btree root %s",
bch2_btree_ids[i]);
- if (i == BTREE_ID_ALLOC)
+ if (i == BTREE_ID_alloc)
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
}
}
@@ -1346,7 +1346,7 @@ int bch2_fs_initialize(struct bch_fs *c)
bch2_inode_pack(c, &packed_inode, &root_inode);
err = "error creating root directory";
- ret = bch2_btree_insert(c, BTREE_ID_INODES,
+ ret = bch2_btree_insert(c, BTREE_ID_inodes,
&packed_inode.inode.k_i,
NULL, NULL, 0);
if (ret)
diff --git a/fs/bcachefs/reflink.c b/fs/bcachefs/reflink.c
index 930547de3309..a2cc078597f2 100644
--- a/fs/bcachefs/reflink.c
+++ b/fs/bcachefs/reflink.c
@@ -119,7 +119,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
if (orig->k.type == KEY_TYPE_inline_data)
bch2_check_set_feature(c, BCH_FEATURE_reflink_inline_data);
- for_each_btree_key(trans, reflink_iter, BTREE_ID_REFLINK,
+ for_each_btree_key(trans, reflink_iter, BTREE_ID_reflink,
POS(0, c->reflink_hint),
BTREE_ITER_INTENT|BTREE_ITER_SLOTS, k, ret) {
if (reflink_iter->pos.inode) {
@@ -219,9 +219,9 @@ s64 bch2_remap_range(struct bch_fs *c,
bch2_bkey_buf_init(&new_src);
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 4096);
- src_iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS, src_start,
+ src_iter = bch2_trans_get_iter(&trans, BTREE_ID_extents, src_start,
BTREE_ITER_INTENT);
- dst_iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS, dst_start,
+ dst_iter = bch2_trans_get_iter(&trans, BTREE_ID_extents, dst_start,
BTREE_ITER_INTENT);
while (1) {
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index 776c026ac838..f843a3b34ba2 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -945,7 +945,7 @@ void bch2_sb_clean_renumber(struct bch_sb_field_clean *clean, int write)
for (entry = clean->start;
entry < (struct jset_entry *) vstruct_end(&clean->field);
entry = vstruct_next(entry))
- bch2_bkey_renumber(BKEY_TYPE_BTREE, bkey_to_packed(entry->start), write);
+ bch2_bkey_renumber(BKEY_TYPE_btree, bkey_to_packed(entry->start), write);
}
int bch2_fs_mark_dirty(struct bch_fs *c)
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index be6e66e0db71..de8e770ba300 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -1436,7 +1436,7 @@ int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
for (i = 0; i < ca->mi.nbuckets; i++) {
ret = bch2_btree_key_cache_flush(&trans,
- BTREE_ID_ALLOC, POS(ca->dev_idx, i));
+ BTREE_ID_alloc, POS(ca->dev_idx, i));
if (ret)
break;
}
@@ -1445,7 +1445,7 @@ int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
if (ret)
return ret;
- return bch2_btree_delete_range(c, BTREE_ID_ALLOC,
+ return bch2_btree_delete_range(c, BTREE_ID_alloc,
POS(ca->dev_idx, 0),
POS(ca->dev_idx + 1, 0),
NULL);
diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c
index c4d79096c53a..b9078adaa747 100644
--- a/fs/bcachefs/sysfs.c
+++ b/fs/bcachefs/sysfs.c
@@ -259,7 +259,7 @@ static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS, POS_MIN, 0, k, ret)
+ for_each_btree_key(&trans, iter, BTREE_ID_extents, POS_MIN, 0, k, ret)
if (k.k->type == KEY_TYPE_extent) {
struct bkey_s_c_extent e = bkey_s_c_to_extent(k);
const union bch_extent_entry *entry;
diff --git a/fs/bcachefs/tests.c b/fs/bcachefs/tests.c
index 6d0f8e233e8b..f25a27f26202 100644
--- a/fs/bcachefs/tests.c
+++ b/fs/bcachefs/tests.c
@@ -13,12 +13,12 @@ static void delete_test_keys(struct bch_fs *c)
{
int ret;
- ret = bch2_btree_delete_range(c, BTREE_ID_EXTENTS,
+ ret = bch2_btree_delete_range(c, BTREE_ID_extents,
POS(0, 0), POS(0, U64_MAX),
NULL);
BUG_ON(ret);
- ret = bch2_btree_delete_range(c, BTREE_ID_XATTRS,
+ ret = bch2_btree_delete_range(c, BTREE_ID_xattrs,
POS(0, 0), POS(0, U64_MAX),
NULL);
BUG_ON(ret);
@@ -37,7 +37,7 @@ static int test_delete(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_XATTRS, k.k.p,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_xattrs, k.k.p,
BTREE_ITER_INTENT);
ret = bch2_btree_iter_traverse(iter);
@@ -82,7 +82,7 @@ static int test_delete_written(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_XATTRS, k.k.p,
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_xattrs, k.k.p,
BTREE_ITER_INTENT);
ret = bch2_btree_iter_traverse(iter);
@@ -130,7 +130,7 @@ static int test_iterate(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i);
k.k.p.offset = i;
- ret = bch2_btree_insert(c, BTREE_ID_XATTRS, &k.k_i,
+ ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i,
NULL, NULL, 0);
if (ret) {
bch_err(c, "insert error in test_iterate: %i", ret);
@@ -142,7 +142,7 @@ static int test_iterate(struct bch_fs *c, u64 nr)
i = 0;
- for_each_btree_key(&trans, iter, BTREE_ID_XATTRS,
+ for_each_btree_key(&trans, iter, BTREE_ID_xattrs,
POS_MIN, 0, k, ret) {
if (k.k->p.inode)
break;
@@ -184,7 +184,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
k.k.p.offset = i + 8;
k.k.size = 8;
- ret = bch2_btree_insert(c, BTREE_ID_EXTENTS, &k.k_i,
+ ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i,
NULL, NULL, 0);
if (ret) {
bch_err(c, "insert error in test_iterate_extents: %i", ret);
@@ -196,7 +196,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
i = 0;
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS,
+ for_each_btree_key(&trans, iter, BTREE_ID_extents,
POS_MIN, 0, k, ret) {
BUG_ON(bkey_start_offset(k.k) != i);
i = k.k->p.offset;
@@ -237,7 +237,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i);
k.k.p.offset = i * 2;
- ret = bch2_btree_insert(c, BTREE_ID_XATTRS, &k.k_i,
+ ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i,
NULL, NULL, 0);
if (ret) {
bch_err(c, "insert error in test_iterate_slots: %i", ret);
@@ -249,7 +249,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
i = 0;
- for_each_btree_key(&trans, iter, BTREE_ID_XATTRS, POS_MIN,
+ for_each_btree_key(&trans, iter, BTREE_ID_xattrs, POS_MIN,
0, k, ret) {
if (k.k->p.inode)
break;
@@ -265,7 +265,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
i = 0;
- for_each_btree_key(&trans, iter, BTREE_ID_XATTRS, POS_MIN,
+ for_each_btree_key(&trans, iter, BTREE_ID_xattrs, POS_MIN,
BTREE_ITER_SLOTS, k, ret) {
BUG_ON(k.k->p.offset != i);
BUG_ON(bkey_deleted(k.k) != (i & 1));
@@ -300,7 +300,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
k.k.p.offset = i + 16;
k.k.size = 8;
- ret = bch2_btree_insert(c, BTREE_ID_EXTENTS, &k.k_i,
+ ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i,
NULL, NULL, 0);
if (ret) {
bch_err(c, "insert error in test_iterate_slots_extents: %i", ret);
@@ -312,7 +312,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
i = 0;
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS, POS_MIN,
+ for_each_btree_key(&trans, iter, BTREE_ID_extents, POS_MIN,
0, k, ret) {
BUG_ON(bkey_start_offset(k.k) != i + 8);
BUG_ON(k.k->size != 8);
@@ -326,7 +326,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
i = 0;
- for_each_btree_key(&trans, iter, BTREE_ID_EXTENTS, POS_MIN,
+ for_each_btree_key(&trans, iter, BTREE_ID_extents, POS_MIN,
BTREE_ITER_SLOTS, k, ret) {
BUG_ON(bkey_deleted(k.k) != !(i % 16));
@@ -354,7 +354,7 @@ static int test_peek_end(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_XATTRS, POS_MIN, 0);
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_xattrs, POS_MIN, 0);
k = bch2_btree_iter_peek(iter);
BUG_ON(k.k);
@@ -374,7 +374,7 @@ static int test_peek_end_extents(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS, POS_MIN, 0);
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_extents, POS_MIN, 0);
k = bch2_btree_iter_peek(iter);
BUG_ON(k.k);
@@ -403,7 +403,7 @@ static int insert_test_extent(struct bch_fs *c,
k.k_i.k.size = end - start;
k.k_i.k.version.lo = test_version++;
- ret = bch2_btree_insert(c, BTREE_ID_EXTENTS, &k.k_i,
+ ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i,
NULL, NULL, 0);
if (ret)
bch_err(c, "insert error in insert_test_extent: %i", ret);
@@ -475,7 +475,7 @@ static int rand_insert(struct bch_fs *c, u64 nr)
k.k.p.offset = test_rand();
ret = __bch2_trans_do(&trans, NULL, NULL, 0,
- __bch2_btree_insert(&trans, BTREE_ID_XATTRS, &k.k_i));
+ __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k.k_i));
if (ret) {
bch_err(c, "error in rand_insert: %i", ret);
break;
@@ -495,7 +495,7 @@ static int rand_lookup(struct bch_fs *c, u64 nr)
u64 i;
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_XATTRS, POS_MIN, 0);
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_xattrs, POS_MIN, 0);
for (i = 0; i < nr; i++) {
bch2_btree_iter_set_pos(iter, POS(0, test_rand()));
@@ -522,7 +522,7 @@ static int rand_mixed(struct bch_fs *c, u64 nr)
u64 i;
bch2_trans_init(&trans, c, 0, 0);
- iter = bch2_trans_get_iter(&trans, BTREE_ID_XATTRS, POS_MIN, 0);
+ iter = bch2_trans_get_iter(&trans, BTREE_ID_xattrs, POS_MIN, 0);
for (i = 0; i < nr; i++) {
bch2_btree_iter_set_pos(iter, POS(0, test_rand()));
@@ -561,7 +561,7 @@ static int __do_delete(struct btree_trans *trans, struct bpos pos)
struct bkey_s_c k;
int ret = 0;
- iter = bch2_trans_get_iter(trans, BTREE_ID_XATTRS, pos,
+ iter = bch2_trans_get_iter(trans, BTREE_ID_xattrs, pos,
BTREE_ITER_INTENT);
k = bch2_btree_iter_peek(iter);
ret = bkey_err(k);
@@ -616,7 +616,7 @@ static int seq_insert(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_XATTRS, POS_MIN,
+ for_each_btree_key(&trans, iter, BTREE_ID_xattrs, POS_MIN,
BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
insert.k.p = iter->pos;
@@ -643,7 +643,7 @@ static int seq_lookup(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_XATTRS, POS_MIN, 0, k, ret)
+ for_each_btree_key(&trans, iter, BTREE_ID_xattrs, POS_MIN, 0, k, ret)
;
bch2_trans_exit(&trans);
return ret;
@@ -658,7 +658,7 @@ static int seq_overwrite(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_XATTRS, POS_MIN,
+ for_each_btree_key(&trans, iter, BTREE_ID_xattrs, POS_MIN,
BTREE_ITER_INTENT, k, ret) {
struct bkey_i_cookie u;
@@ -679,7 +679,7 @@ static int seq_delete(struct bch_fs *c, u64 nr)
{
int ret;
- ret = bch2_btree_delete_range(c, BTREE_ID_XATTRS,
+ ret = bch2_btree_delete_range(c, BTREE_ID_xattrs,
POS(0, 0), POS(0, U64_MAX),
NULL);
if (ret)
diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c
index c7840bb949a1..5555d45df54e 100644
--- a/fs/bcachefs/xattr.c
+++ b/fs/bcachefs/xattr.c
@@ -61,7 +61,7 @@ static bool xattr_cmp_bkey(struct bkey_s_c _l, struct bkey_s_c _r)
}
const struct bch_hash_desc bch2_xattr_hash_desc = {
- .btree_id = BTREE_ID_XATTRS,
+ .btree_id = BTREE_ID_xattrs,
.key_type = KEY_TYPE_xattr,
.hash_key = xattr_hash_key,
.hash_bkey = xattr_hash_bkey,
@@ -279,7 +279,7 @@ ssize_t bch2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
bch2_trans_init(&trans, c, 0, 0);
- for_each_btree_key(&trans, iter, BTREE_ID_XATTRS,
+ for_each_btree_key(&trans, iter, BTREE_ID_xattrs,
POS(inum, 0), 0, k, ret) {
BUG_ON(k.k->p.inode < inum);