Commit 41f8b09e authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Rename BTREE_ID enums for consistency with other enums

Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 79f88eba
...@@ -316,7 +316,7 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys) ...@@ -316,7 +316,7 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
int ret; int ret;
down_read(&c->gc_lock); 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); NULL, bch2_alloc_read_fn);
up_read(&c->gc_lock); up_read(&c->gc_lock);
...@@ -344,7 +344,7 @@ static int bch2_alloc_write_key(struct btree_trans *trans, ...@@ -344,7 +344,7 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
bch2_trans_begin(trans); bch2_trans_begin(trans);
ret = bch2_btree_key_cache_flush(trans, ret = bch2_btree_key_cache_flush(trans,
BTREE_ID_ALLOC, iter->pos); BTREE_ID_alloc, iter->pos);
if (ret) if (ret)
goto err; goto err;
...@@ -386,7 +386,7 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags) ...@@ -386,7 +386,7 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags)
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0); 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); BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
for_each_member_device(ca, c, i) { for_each_member_device(ca, c, i) {
...@@ -423,7 +423,7 @@ int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev, ...@@ -423,7 +423,7 @@ int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
u64 *time, now; u64 *time, now;
int ret = 0; 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|
BTREE_ITER_CACHED_NOFILL| BTREE_ITER_CACHED_NOFILL|
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
...@@ -927,7 +927,7 @@ static int bch2_invalidate_buckets(struct bch_fs *c, struct bch_dev *ca) ...@@ -927,7 +927,7 @@ static int bch2_invalidate_buckets(struct bch_fs *c, struct bch_dev *ca)
bch2_trans_init(&trans, c, 0, 0); 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), POS(ca->dev_idx, 0),
BTREE_ITER_CACHED| BTREE_ITER_CACHED|
BTREE_ITER_CACHED_NOFILL| BTREE_ITER_CACHED_NOFILL|
......
...@@ -369,14 +369,14 @@ enum gc_phase { ...@@ -369,14 +369,14 @@ enum gc_phase {
GC_PHASE_START, GC_PHASE_START,
GC_PHASE_SB, GC_PHASE_SB,
GC_PHASE_BTREE_EC, GC_PHASE_BTREE_stripes,
GC_PHASE_BTREE_EXTENTS, GC_PHASE_BTREE_extents,
GC_PHASE_BTREE_INODES, GC_PHASE_BTREE_inodes,
GC_PHASE_BTREE_DIRENTS, GC_PHASE_BTREE_dirents,
GC_PHASE_BTREE_XATTRS, GC_PHASE_BTREE_xattrs,
GC_PHASE_BTREE_ALLOC, GC_PHASE_BTREE_alloc,
GC_PHASE_BTREE_QUOTAS, GC_PHASE_BTREE_quotas,
GC_PHASE_BTREE_REFLINK, GC_PHASE_BTREE_reflink,
GC_PHASE_PENDING_DELETE, GC_PHASE_PENDING_DELETE,
GC_PHASE_ALLOC, GC_PHASE_ALLOC,
...@@ -722,7 +722,7 @@ struct bch_fs { ...@@ -722,7 +722,7 @@ struct bch_fs {
* Tracks GC's progress - everything in the range [ZERO_KEY..gc_cur_pos] * Tracks GC's progress - everything in the range [ZERO_KEY..gc_cur_pos]
* has been marked by GC. * 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 * Protected by gc_pos_lock. Only written to by GC thread, so GC thread
* can read without a lock. * can read without a lock.
......
...@@ -1658,18 +1658,18 @@ LE32_BITMASK(JSET_NO_FLUSH, struct jset, flags, 5, 6); ...@@ -1658,18 +1658,18 @@ LE32_BITMASK(JSET_NO_FLUSH, struct jset, flags, 5, 6);
/* Btree: */ /* Btree: */
#define BCH_BTREE_IDS() \ #define BCH_BTREE_IDS() \
x(EXTENTS, 0, "extents") \ x(extents, 0) \
x(INODES, 1, "inodes") \ x(inodes, 1) \
x(DIRENTS, 2, "dirents") \ x(dirents, 2) \
x(XATTRS, 3, "xattrs") \ x(xattrs, 3) \
x(ALLOC, 4, "alloc") \ x(alloc, 4) \
x(QUOTAS, 5, "quotas") \ x(quotas, 5) \
x(EC, 6, "stripes") \ x(stripes, 6) \
x(REFLINK, 7, "reflink") x(reflink, 7)
enum btree_id { enum btree_id {
#define x(kwd, val, name) BTREE_ID_##kwd = val, #define x(kwd, val) BTREE_ID_##kwd = val,
BCH_BTREE_IDS() BCH_BTREE_IDS()
#undef x #undef x
BTREE_ID_NR BTREE_ID_NR
......
...@@ -104,7 +104,7 @@ const char *__bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k, ...@@ -104,7 +104,7 @@ const char *__bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
if (k.k->u64s < BKEY_U64s) if (k.k->u64s < BKEY_U64s)
return "u64s too small"; 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) bkey_val_u64s(k.k) > BKEY_BTREE_PTR_VAL_U64s_MAX)
return "value too big"; return "value too big";
...@@ -122,7 +122,7 @@ const char *__bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k, ...@@ -122,7 +122,7 @@ const char *__bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
if (k.k->p.snapshot) if (k.k->p.snapshot)
return "nonzero snapshot"; return "nonzero snapshot";
if (type != BKEY_TYPE_BTREE && if (type != BKEY_TYPE_btree &&
!bkey_cmp(k.k->p, POS_MAX)) !bkey_cmp(k.k->p, POS_MAX))
return "POS_MAX key"; return "POS_MAX key";
...@@ -263,18 +263,18 @@ static const struct old_bkey_type { ...@@ -263,18 +263,18 @@ static const struct old_bkey_type {
u8 old; u8 old;
u8 new; u8 new;
} bkey_renumber_table[] = { } bkey_renumber_table[] = {
{BKEY_TYPE_BTREE, 128, KEY_TYPE_btree_ptr }, {BKEY_TYPE_btree, 128, KEY_TYPE_btree_ptr },
{BKEY_TYPE_EXTENTS, 128, KEY_TYPE_extent }, {BKEY_TYPE_extents, 128, KEY_TYPE_extent },
{BKEY_TYPE_EXTENTS, 129, KEY_TYPE_extent }, {BKEY_TYPE_extents, 129, KEY_TYPE_extent },
{BKEY_TYPE_EXTENTS, 130, KEY_TYPE_reservation }, {BKEY_TYPE_extents, 130, KEY_TYPE_reservation },
{BKEY_TYPE_INODES, 128, KEY_TYPE_inode }, {BKEY_TYPE_inodes, 128, KEY_TYPE_inode },
{BKEY_TYPE_INODES, 130, KEY_TYPE_inode_generation }, {BKEY_TYPE_inodes, 130, KEY_TYPE_inode_generation },
{BKEY_TYPE_DIRENTS, 128, KEY_TYPE_dirent }, {BKEY_TYPE_dirents, 128, KEY_TYPE_dirent },
{BKEY_TYPE_DIRENTS, 129, KEY_TYPE_hash_whiteout }, {BKEY_TYPE_dirents, 129, KEY_TYPE_hash_whiteout },
{BKEY_TYPE_XATTRS, 128, KEY_TYPE_xattr }, {BKEY_TYPE_xattrs, 128, KEY_TYPE_xattr },
{BKEY_TYPE_XATTRS, 129, KEY_TYPE_hash_whiteout }, {BKEY_TYPE_xattrs, 129, KEY_TYPE_hash_whiteout },
{BKEY_TYPE_ALLOC, 128, KEY_TYPE_alloc }, {BKEY_TYPE_alloc, 128, KEY_TYPE_alloc },
{BKEY_TYPE_QUOTAS, 128, KEY_TYPE_quota }, {BKEY_TYPE_quotas, 128, KEY_TYPE_quota },
}; };
void bch2_bkey_renumber(enum btree_node_type btree_node_type, 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, ...@@ -320,7 +320,7 @@ void __bch2_bkey_compat(unsigned level, enum btree_id btree_id,
break; break;
case 2: case 2:
if (version < bcachefs_metadata_version_inode_btree_change && if (version < bcachefs_metadata_version_inode_btree_change &&
btree_id == BTREE_ID_INODES) { btree_id == BTREE_ID_inodes) {
if (!bkey_packed(k)) { if (!bkey_packed(k)) {
struct bkey_i *u = packed_to_bkey(k); struct bkey_i *u = packed_to_bkey(k);
swap(u->k.p.inode, u->k.p.offset); swap(u->k.p.inode, u->k.p.offset);
......
...@@ -13,13 +13,6 @@ ...@@ -13,13 +13,6 @@
#include <linux/prefetch.h> #include <linux/prefetch.h>
#include <linux/sched/mm.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) void bch2_recalc_btree_reserve(struct bch_fs *c)
{ {
unsigned i, reserve = 16; unsigned i, reserve = 16;
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
struct btree_iter; struct btree_iter;
extern const char * const bch2_btree_ids[];
void bch2_recalc_btree_reserve(struct bch_fs *); void bch2_recalc_btree_reserve(struct bch_fs *);
void bch2_btree_node_hash_remove(struct btree_cache *, struct btree *); void bch2_btree_node_hash_remove(struct btree_cache *, struct btree *);
......
...@@ -57,7 +57,7 @@ static inline int gc_pos_cmp(struct gc_pos l, struct gc_pos r) ...@@ -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) static inline enum gc_phase btree_id_to_gc_phase(enum btree_id id)
{ {
switch (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() BCH_BTREE_IDS()
#undef x #undef x
default: default:
......
...@@ -1321,7 +1321,7 @@ static int validate_bset_for_write(struct bch_fs *c, struct btree *b, ...@@ -1321,7 +1321,7 @@ static int validate_bset_for_write(struct bch_fs *c, struct btree *b,
unsigned whiteout_u64s = 0; unsigned whiteout_u64s = 0;
int ret; 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; return -1;
ret = validate_bset(c, NULL, b, i, sectors, WRITE, false) ?: ret = validate_bset(c, NULL, b, i, sectors, WRITE, false) ?:
......
...@@ -193,7 +193,7 @@ static inline void compat_bformat(unsigned level, enum btree_id btree_id, ...@@ -193,7 +193,7 @@ static inline void compat_bformat(unsigned level, enum btree_id btree_id,
int write, struct bkey_format *f) int write, struct bkey_format *f)
{ {
if (version < bcachefs_metadata_version_inode_btree_change && 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], swap(f->bits_per_field[BKEY_FIELD_INODE],
f->bits_per_field[BKEY_FIELD_OFFSET]); f->bits_per_field[BKEY_FIELD_OFFSET]);
swap(f->field_offset[BKEY_FIELD_INODE], swap(f->field_offset[BKEY_FIELD_INODE],
...@@ -209,7 +209,7 @@ static inline void compat_bpos(unsigned level, enum btree_id btree_id, ...@@ -209,7 +209,7 @@ static inline void compat_bpos(unsigned level, enum btree_id btree_id,
bch2_bpos_swab(p); bch2_bpos_swab(p);
if (version < bcachefs_metadata_version_inode_btree_change && if (version < bcachefs_metadata_version_inode_btree_change &&
btree_id == BTREE_ID_INODES) btree_id == BTREE_ID_inodes)
swap(p->inode, p->offset); swap(p->inode, p->offset);
} }
......
...@@ -545,16 +545,16 @@ static inline unsigned bset_byte_offset(struct btree *b, void *i) ...@@ -545,16 +545,16 @@ static inline unsigned bset_byte_offset(struct btree *b, void *i)
} }
enum btree_node_type { enum btree_node_type {
#define x(kwd, val, name) BKEY_TYPE_##kwd = val, #define x(kwd, val) BKEY_TYPE_##kwd = val,
BCH_BTREE_IDS() BCH_BTREE_IDS()
#undef x #undef x
BKEY_TYPE_BTREE, BKEY_TYPE_btree,
}; };
/* Type of a key in btree @id at level @level: */ /* 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) 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: */ /* Type of keys @b contains: */
...@@ -566,8 +566,8 @@ static inline enum btree_node_type btree_node_type(struct btree *b) ...@@ -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) static inline bool btree_node_type_is_extents(enum btree_node_type type)
{ {
switch (type) { switch (type) {
case BKEY_TYPE_EXTENTS: case BKEY_TYPE_extents:
case BKEY_TYPE_REFLINK: case BKEY_TYPE_reflink:
return true; return true;
default: default:
return false; return false;
...@@ -590,18 +590,18 @@ static inline bool btree_iter_is_extents(struct btree_iter *iter) ...@@ -590,18 +590,18 @@ static inline bool btree_iter_is_extents(struct btree_iter *iter)
} }
#define BTREE_NODE_TYPE_HAS_TRIGGERS \ #define BTREE_NODE_TYPE_HAS_TRIGGERS \
((1U << BKEY_TYPE_EXTENTS)| \ ((1U << BKEY_TYPE_extents)| \
(1U << BKEY_TYPE_ALLOC)| \ (1U << BKEY_TYPE_alloc)| \
(1U << BKEY_TYPE_INODES)| \ (1U << BKEY_TYPE_inodes)| \
(1U << BKEY_TYPE_REFLINK)| \ (1U << BKEY_TYPE_reflink)| \
(1U << BKEY_TYPE_EC)| \ (1U << BKEY_TYPE_stripes)| \
(1U << BKEY_TYPE_BTREE)) (1U << BKEY_TYPE_btree))
#define BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS \ #define BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS \
((1U << BKEY_TYPE_EXTENTS)| \ ((1U << BKEY_TYPE_extents)| \
(1U << BKEY_TYPE_INODES)| \ (1U << BKEY_TYPE_inodes)| \
(1U << BKEY_TYPE_EC)| \ (1U << BKEY_TYPE_stripes)| \
(1U << BKEY_TYPE_REFLINK)) (1U << BKEY_TYPE_reflink))
enum btree_trigger_flags { enum btree_trigger_flags {
__BTREE_TRIGGER_NORUN, /* Don't run triggers at all */ __BTREE_TRIGGER_NORUN, /* Don't run triggers at all */
......
...@@ -1196,7 +1196,7 @@ static void btree_split_insert_keys(struct btree_update *as, struct btree *b, ...@@ -1196,7 +1196,7 @@ static void btree_split_insert_keys(struct btree_update *as, struct btree *b,
struct bkey_packed *src, *dst, *n; struct bkey_packed *src, *dst, *n;
struct bset *i; 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); bch2_btree_node_iter_init(&node_iter, b, &k->k.p);
......
...@@ -341,7 +341,7 @@ static inline bool iter_has_nontrans_triggers(struct btree_iter *iter) ...@@ -341,7 +341,7 @@ static inline bool iter_has_nontrans_triggers(struct btree_iter *iter)
{ {
return (((BTREE_NODE_TYPE_HAS_TRIGGERS & return (((BTREE_NODE_TYPE_HAS_TRIGGERS &
~BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS)) | ~BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS)) |
(1U << BTREE_ID_EC)) & (1U << BTREE_ID_stripes)) &
(1U << iter->btree_id); (1U << iter->btree_id);
} }
......
...@@ -1509,7 +1509,7 @@ static int trans_get_key(struct btree_trans *trans, ...@@ -1509,7 +1509,7 @@ static int trans_get_key(struct btree_trans *trans,
struct btree_iter **iter, struct btree_iter **iter,
struct bkey_s_c *k) struct bkey_s_c *k)
{ {
unsigned flags = btree_id != BTREE_ID_ALLOC unsigned flags = btree_id != BTREE_ID_alloc
? BTREE_ITER_SLOTS ? BTREE_ITER_SLOTS
: BTREE_ITER_CACHED; : BTREE_ITER_CACHED;
int ret; int ret;
...@@ -1545,11 +1545,11 @@ bch2_trans_start_alloc_update(struct btree_trans *trans, struct btree_iter **_it ...@@ -1545,11 +1545,11 @@ bch2_trans_start_alloc_update(struct btree_trans *trans, struct btree_iter **_it
if (IS_ERR(a)) if (IS_ERR(a))
return 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) { if (iter) {
*u = bch2_alloc_unpack(k); *u = bch2_alloc_unpack(k);
} else { } 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|
BTREE_ITER_CACHED_NOFILL| BTREE_ITER_CACHED_NOFILL|
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
...@@ -1606,7 +1606,7 @@ static int bch2_trans_mark_stripe_ptr(struct btree_trans *trans, ...@@ -1606,7 +1606,7 @@ static int bch2_trans_mark_stripe_ptr(struct btree_trans *trans,
struct bch_replicas_padded r; struct bch_replicas_padded r;
int ret = 0; 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) if (ret < 0)
return ret; return ret;
...@@ -1830,7 +1830,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans, ...@@ -1830,7 +1830,7 @@ static int __bch2_trans_mark_reflink_p(struct btree_trans *trans,
__le64 *refcount; __le64 *refcount;
s64 ret; s64 ret;
ret = trans_get_key(trans, BTREE_ID_REFLINK, ret = trans_get_key(trans, BTREE_ID_reflink,
POS(0, idx), &iter, &k); POS(0, idx), &iter, &k);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -64,7 +64,7 @@ static bool dirent_cmp_bkey(struct bkey_s_c _l, struct bkey_s_c _r) ...@@ -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 = { const struct bch_hash_desc bch2_dirent_hash_desc = {
.btree_id = BTREE_ID_DIRENTS, .btree_id = BTREE_ID_dirents,
.key_type = KEY_TYPE_dirent, .key_type = KEY_TYPE_dirent,
.hash_key = dirent_hash_key, .hash_key = dirent_hash_key,
.hash_bkey = dirent_hash_bkey, .hash_bkey = dirent_hash_bkey,
...@@ -332,7 +332,7 @@ int bch2_empty_dir_trans(struct btree_trans *trans, u64 dir_inum) ...@@ -332,7 +332,7 @@ int bch2_empty_dir_trans(struct btree_trans *trans, u64 dir_inum)
struct bkey_s_c k; struct bkey_s_c k;
int ret; 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) { POS(dir_inum, 0), 0, k, ret) {
if (k.k->p.inode > dir_inum) if (k.k->p.inode > dir_inum)
break; break;
...@@ -357,7 +357,7 @@ int bch2_readdir(struct bch_fs *c, u64 inum, struct dir_context *ctx) ...@@ -357,7 +357,7 @@ int bch2_readdir(struct bch_fs *c, u64 inum, struct dir_context *ctx)
bch2_trans_init(&trans, c, 0, 0); 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) { POS(inum, ctx->pos), 0, k, ret) {
if (k.k->p.inode > inum) if (k.k->p.inode > inum)
break; break;
......
...@@ -433,7 +433,7 @@ static int get_stripe_key(struct bch_fs *c, u64 idx, struct ec_stripe_buf *strip ...@@ -433,7 +433,7 @@ static int get_stripe_key(struct bch_fs *c, u64 idx, struct ec_stripe_buf *strip
int ret; int ret;
bch2_trans_init(&trans, c, 0, 0); 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); k = bch2_btree_iter_peek_slot(iter);
ret = bkey_err(k); ret = bkey_err(k);
if (ret) if (ret)
...@@ -668,7 +668,7 @@ void bch2_stripes_heap_update(struct bch_fs *c, ...@@ -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) 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),
POS(0, idx + 1), POS(0, idx + 1),
NULL); NULL);
...@@ -713,7 +713,7 @@ static int ec_stripe_bkey_insert(struct bch_fs *c, ...@@ -713,7 +713,7 @@ static int ec_stripe_bkey_insert(struct bch_fs *c,
retry: retry:
bch2_trans_begin(&trans); 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) { BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
if (bkey_cmp(k.k->p, POS(0, U32_MAX)) > 0) { if (bkey_cmp(k.k->p, POS(0, U32_MAX)) > 0) {
if (start_pos.offset) { if (start_pos.offset) {
...@@ -765,7 +765,7 @@ static int ec_stripe_bkey_update(struct btree_trans *trans, ...@@ -765,7 +765,7 @@ static int ec_stripe_bkey_update(struct btree_trans *trans,
unsigned i; unsigned i;
int ret; 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); new->k.p, BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter); k = bch2_btree_iter_peek_slot(iter);
ret = bkey_err(k); ret = bkey_err(k);
...@@ -831,7 +831,7 @@ static int ec_stripe_update_ptrs(struct bch_fs *c, ...@@ -831,7 +831,7 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
/* XXX this doesn't support the reflink btree */ /* 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), bkey_start_pos(pos),
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
...@@ -1604,7 +1604,7 @@ int bch2_stripes_write(struct bch_fs *c, unsigned flags) ...@@ -1604,7 +1604,7 @@ int bch2_stripes_write(struct bch_fs *c, unsigned flags)
bch2_trans_init(&trans, c, 0, 0); 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); BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
genradix_for_each(&c->stripes[0], giter, m) { 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, ...@@ -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 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); NULL, bch2_stripes_read_fn);
if (ret) if (ret)
bch_err(c, "error reading stripes: %i", ret); bch_err(c, "error reading stripes: %i", ret);
...@@ -1663,7 +1663,7 @@ int bch2_ec_mem_alloc(struct bch_fs *c, bool gc) ...@@ -1663,7 +1663,7 @@ int bch2_ec_mem_alloc(struct bch_fs *c, bool gc)
bch2_trans_init(&trans, c, 0, 0); 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); k = bch2_btree_iter_prev(iter);
if (!IS_ERR_OR_NULL(k.k)) if (!IS_ERR_OR_NULL(k.k))
......
...@@ -62,7 +62,7 @@ static int count_iters_for_insert(struct btree_trans *trans, ...@@ -62,7 +62,7 @@ static int count_iters_for_insert(struct btree_trans *trans,
struct bkey_s_c r_k; struct bkey_s_c r_k;
for_each_btree_key(trans, iter, 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) { BTREE_ITER_SLOTS, r_k, ret2) {
if (bkey_cmp(bkey_start_pos(r_k.k), if (bkey_cmp(bkey_start_pos(r_k.k),
POS(0, idx + sectors)) >= 0) POS(0, idx + sectors)) >= 0)
......
...@@ -676,7 +676,7 @@ bool bch2_check_range_allocated(struct bch_fs *c, struct bpos pos, u64 size, ...@@ -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); 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) { BTREE_ITER_SLOTS, k, err) {
if (bkey_cmp(bkey_start_pos(k.k), end) >= 0) if (bkey_cmp(bkey_start_pos(k.k), end) >= 0)
break; break;
......
...@@ -865,7 +865,7 @@ void bch2_readahead(struct readahead_control *ractl) ...@@ -865,7 +865,7 @@ void bch2_readahead(struct readahead_control *ractl)
bch2_trans_init(&trans, c, 0, 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); BTREE_ITER_SLOTS);
bch2_pagecache_add_get(&inode->ei_pagecache_lock); 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, ...@@ -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)); BUG_ON(!bio_add_page(&rbio->bio, page, PAGE_SIZE, 0));
bch2_trans_init(&trans, c, 0, 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); BTREE_ITER_SLOTS);
bchfs_read(&trans, iter, rbio, inum, NULL); bchfs_read(&trans, iter, rbio, inum, NULL);
...@@ -2144,7 +2144,7 @@ static inline int range_has_data(struct bch_fs *c, ...@@ -2144,7 +2144,7 @@ static inline int range_has_data(struct bch_fs *c,
bch2_trans_init(&trans, c, 0, 0); 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) if (bkey_cmp(bkey_start_pos(k.k), end) >= 0)
break; break;
...@@ -2520,7 +2520,7 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode, ...@@ -2520,7 +2520,7 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
goto err; 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), POS(inode->v.i_ino, src_start >> 9),
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
dst = bch2_trans_copy_iter(&trans, src); dst = bch2_trans_copy_iter(&trans, src);
...@@ -2675,7 +2675,7 @@ static long bchfs_fallocate(struct bch_inode_info *inode, int mode, ...@@ -2675,7 +2675,7 @@ static long bchfs_fallocate(struct bch_inode_info *inode, int mode,
truncate_pagecache_range(&inode->v, offset, end - 1); 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), POS(inode->v.i_ino, block_start >> 9),
BTREE_ITER_SLOTS|BTREE_ITER_INTENT); BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
end_pos = POS(inode->v.i_ino, block_end >> 9); 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) ...@@ -3006,7 +3006,7 @@ static loff_t bch2_seek_data(struct file *file, u64 offset)
bch2_trans_init(&trans, c, 0, 0); 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) { POS(inode->v.i_ino, offset >> 9), 0, k, ret) {
if (k.k->p.inode != inode->v.i_ino) { if (k.k->p.inode != inode->v.i_ino) {
break; break;
...@@ -3101,7 +3101,7 @@ static loff_t bch2_seek_hole(struct file *file, u64 offset) ...@@ -3101,7 +3101,7 @@ static loff_t bch2_seek_hole(struct file *file, u64 offset)
bch2_trans_init(&trans, c, 0, 0); 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), POS(inode->v.i_ino, offset >> 9),
BTREE_ITER_SLOTS, k, ret) { BTREE_ITER_SLOTS, k, ret) {
if (k.k->p.inode != inode->v.i_ino) { if (k.k->p.inode != inode->v.i_ino) {
......
...@@ -916,7 +916,7 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info, ...@@ -916,7 +916,7 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info,
bch2_bkey_buf_init(&prev); bch2_bkey_buf_init(&prev);
bch2_trans_init(&trans, c, 0, 0); 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); POS(ei->v.i_ino, start >> 9), 0);
retry: retry:
while ((k = bch2_btree_iter_peek(iter)).k && while ((k = bch2_btree_iter_peek(iter)).k &&
......
...@@ -24,7 +24,7 @@ static s64 bch2_count_inode_sectors(struct btree_trans *trans, u64 inum) ...@@ -24,7 +24,7 @@ static s64 bch2_count_inode_sectors(struct btree_trans *trans, u64 inum)
u64 sectors = 0; u64 sectors = 0;
int ret; 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) { POS(inum, 0), 0, k, ret) {
if (k.k->p.inode != inum) if (k.k->p.inode != inum)
break; break;
...@@ -396,7 +396,7 @@ static int check_dirent_hash(struct btree_trans *trans, struct hash_check *h, ...@@ -396,7 +396,7 @@ static int check_dirent_hash(struct btree_trans *trans, struct hash_check *h,
if (fsck_err(c, "cannot fix dirent by removing trailing garbage %s (%zu)\n" if (fsck_err(c, "cannot fix dirent by removing trailing garbage %s (%zu)\n"
"hash table key at wrong offset: btree %u, offset %llu, " "hash table key at wrong offset: btree %u, offset %llu, "
"hashed to %llu chain starts at %llu\n%s", "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, k->k->p.offset, hash, h->chain->pos.offset,
(bch2_bkey_val_to_text(&PBUF(buf), c, (bch2_bkey_val_to_text(&PBUF(buf), c,
*k), buf))) { *k), buf))) {
...@@ -415,7 +415,7 @@ static int check_dirent_hash(struct btree_trans *trans, struct hash_check *h, ...@@ -415,7 +415,7 @@ static int check_dirent_hash(struct btree_trans *trans, struct hash_check *h,
static int bch2_inode_truncate(struct bch_fs *c, u64 inode_nr, u64 new_size) 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, round_up(new_size, block_bytes(c)) >> 9),
POS(inode_nr + 1, 0), NULL); POS(inode_nr + 1, 0), NULL);
} }
...@@ -474,7 +474,7 @@ static int check_extents(struct bch_fs *c) ...@@ -474,7 +474,7 @@ static int check_extents(struct bch_fs *c)
bch_verbose(c, "checking extents"); 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), POS(BCACHEFS_ROOT_INO, 0),
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
retry: retry:
...@@ -537,7 +537,7 @@ static int check_extents(struct bch_fs *c) ...@@ -537,7 +537,7 @@ static int check_extents(struct bch_fs *c)
bch2_inode_pack(c, &p, &w.inode); 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, &p.inode.k_i, NULL, NULL,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW); BTREE_INSERT_LAZY_RW);
...@@ -595,7 +595,7 @@ static int check_dirents(struct bch_fs *c) ...@@ -595,7 +595,7 @@ static int check_dirents(struct bch_fs *c)
hash_check_init(&h); 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); POS(BCACHEFS_ROOT_INO, 0), 0);
retry: retry:
for_each_btree_key_continue(iter, 0, k, ret) { for_each_btree_key_continue(iter, 0, k, ret) {
...@@ -747,7 +747,7 @@ static int check_xattrs(struct bch_fs *c) ...@@ -747,7 +747,7 @@ static int check_xattrs(struct bch_fs *c)
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0); 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); POS(BCACHEFS_ROOT_INO, 0), 0);
retry: retry:
for_each_btree_key_continue(iter, 0, k, ret) { for_each_btree_key_continue(iter, 0, k, ret) {
...@@ -810,7 +810,7 @@ static int check_root(struct bch_fs *c, struct bch_inode_unpacked *root_inode) ...@@ -810,7 +810,7 @@ static int check_root(struct bch_fs *c, struct bch_inode_unpacked *root_inode)
bch2_inode_pack(c, &packed, root_inode); 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, NULL, NULL,
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_LAZY_RW); BTREE_INSERT_LAZY_RW);
...@@ -958,7 +958,7 @@ static int check_directory_structure(struct bch_fs *c, ...@@ -958,7 +958,7 @@ static int check_directory_structure(struct bch_fs *c,
if (e->offset == U64_MAX) if (e->offset == U64_MAX)
goto up; 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) { POS(e->inum, e->offset + 1), 0, k, ret) {
if (k.k->p.inode != e->inum) if (k.k->p.inode != e->inum)
break; break;
...@@ -1011,7 +1011,7 @@ static int check_directory_structure(struct bch_fs *c, ...@@ -1011,7 +1011,7 @@ static int check_directory_structure(struct bch_fs *c,
path.nr--; 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: retry:
for_each_btree_key_continue(iter, 0, k, ret) { for_each_btree_key_continue(iter, 0, k, ret) {
if (k.k->type != KEY_TYPE_inode) if (k.k->type != KEY_TYPE_inode)
...@@ -1108,7 +1108,7 @@ static int bch2_gc_walk_dirents(struct bch_fs *c, nlink_table *links, ...@@ -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); 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) { switch (k.k->type) {
case KEY_TYPE_dirent: case KEY_TYPE_dirent:
d = bkey_s_c_to_dirent(k); d = bkey_s_c_to_dirent(k);
...@@ -1349,7 +1349,7 @@ static int bch2_gc_walk_inodes(struct bch_fs *c, ...@@ -1349,7 +1349,7 @@ static int bch2_gc_walk_inodes(struct bch_fs *c,
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0); 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); POS(0, range_start), 0);
nlinks_iter = genradix_iter_init(links, 0); nlinks_iter = genradix_iter_init(links, 0);
...@@ -1475,7 +1475,7 @@ int bch2_fsck_walk_inodes_only(struct bch_fs *c) ...@@ -1475,7 +1475,7 @@ int bch2_fsck_walk_inodes_only(struct bch_fs *c)
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 0); 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) if (k.k->type != KEY_TYPE_inode)
continue; continue;
......
...@@ -300,7 +300,7 @@ struct btree_iter *bch2_inode_peek(struct btree_trans *trans, ...@@ -300,7 +300,7 @@ struct btree_iter *bch2_inode_peek(struct btree_trans *trans,
struct bkey_s_c k; struct bkey_s_c k;
int ret; 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); BTREE_ITER_CACHED|flags);
k = bch2_btree_iter_peek_cached(iter); k = bch2_btree_iter_peek_cached(iter);
ret = bkey_err(k); ret = bkey_err(k);
...@@ -498,7 +498,7 @@ int bch2_inode_create(struct btree_trans *trans, ...@@ -498,7 +498,7 @@ int bch2_inode_create(struct btree_trans *trans,
if (IS_ERR(inode_p)) if (IS_ERR(inode_p))
return PTR_ERR(inode_p); return PTR_ERR(inode_p);
again: 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) { BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
if (bkey_cmp(iter->pos, POS(0, max)) > 0) if (bkey_cmp(iter->pos, POS(0, max)) > 0)
break; break;
...@@ -513,7 +513,7 @@ int bch2_inode_create(struct btree_trans *trans, ...@@ -513,7 +513,7 @@ int bch2_inode_create(struct btree_trans *trans,
* cache before using a slot: * cache before using a slot:
*/ */
if (k.k->type != KEY_TYPE_inode && 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; goto found_slot;
} }
...@@ -560,11 +560,11 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached) ...@@ -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 * XXX: the dirent could ideally would delete whiteouts when they're no
* longer needed * 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) ?: start, end, NULL) ?:
bch2_btree_delete_range_trans(&trans, BTREE_ID_XATTRS, bch2_btree_delete_range_trans(&trans, BTREE_ID_xattrs,
start, end, NULL) ?: start, end, NULL) ?:
bch2_btree_delete_range_trans(&trans, BTREE_ID_DIRENTS, bch2_btree_delete_range_trans(&trans, BTREE_ID_dirents,
start, end, NULL); start, end, NULL);
if (ret) if (ret)
goto err; goto err;
...@@ -574,11 +574,11 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached) ...@@ -574,11 +574,11 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached)
bi_generation = 0; bi_generation = 0;
if (cached) { 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); BTREE_ITER_CACHED|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_cached(iter); k = bch2_btree_iter_peek_cached(iter);
} else { } 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); BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter); 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, ...@@ -636,7 +636,7 @@ int __bch2_inode_find_by_inum_trans(struct btree_trans *trans, u64 inode_nr,
struct bkey_s_c k; struct bkey_s_c k;
int ret; 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); POS(0, inode_nr), flags);
k = (flags & BTREE_ITER_TYPE) == BTREE_ITER_CACHED k = (flags & BTREE_ITER_TYPE) == BTREE_ITER_CACHED
? bch2_btree_iter_peek_cached(iter) ? bch2_btree_iter_peek_cached(iter)
......
...@@ -408,7 +408,7 @@ int bch2_fpunch(struct bch_fs *c, u64 inum, u64 start, u64 end, ...@@ -408,7 +408,7 @@ int bch2_fpunch(struct bch_fs *c, u64 inum, u64 start, u64 end,
int ret = 0; int ret = 0;
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 1024); 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), POS(inum, start),
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
...@@ -435,7 +435,7 @@ int bch2_write_index_default(struct bch_write_op *op) ...@@ -435,7 +435,7 @@ int bch2_write_index_default(struct bch_write_op *op)
bch2_bkey_buf_init(&sk); bch2_bkey_buf_init(&sk);
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 1024); 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), bkey_start_pos(&k->k),
BTREE_ITER_SLOTS|BTREE_ITER_INTENT); BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
...@@ -1530,8 +1530,8 @@ static struct promote_op *promote_alloc(struct bch_fs *c, ...@@ -1530,8 +1530,8 @@ static struct promote_op *promote_alloc(struct bch_fs *c,
promote = __promote_alloc(c, promote = __promote_alloc(c,
k.k->type == KEY_TYPE_reflink_v k.k->type == KEY_TYPE_reflink_v
? BTREE_ID_REFLINK ? BTREE_ID_reflink
: BTREE_ID_EXTENTS, : BTREE_ID_extents,
k, pos, pick, opts, sectors, rbio); k, pos, pick, opts, sectors, rbio);
if (!promote) if (!promote)
return NULL; return NULL;
...@@ -1627,7 +1627,7 @@ static void bch2_read_retry_nodecode(struct bch_fs *c, struct bch_read_bio *rbio ...@@ -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_bkey_buf_init(&sk);
bch2_trans_init(&trans, c, 0, 0); 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); rbio->pos, BTREE_ITER_SLOTS);
retry: retry:
rbio->bio.bi_status = 0; rbio->bio.bi_status = 0;
...@@ -1682,7 +1682,7 @@ static void bch2_read_retry(struct bch_fs *c, struct bch_read_bio *rbio, ...@@ -1682,7 +1682,7 @@ static void bch2_read_retry(struct bch_fs *c, struct bch_read_bio *rbio,
retry: retry:
bch2_trans_begin(&trans); 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), POS(inode, bvec_iter.bi_sector),
BTREE_ITER_SLOTS, k, ret) { BTREE_ITER_SLOTS, k, ret) {
unsigned bytes, sectors, offset_into_extent; unsigned bytes, sectors, offset_into_extent;
...@@ -1801,7 +1801,7 @@ static int __bch2_rbio_narrow_crcs(struct btree_trans *trans, ...@@ -1801,7 +1801,7 @@ static int __bch2_rbio_narrow_crcs(struct btree_trans *trans,
if (crc_is_compressed(rbio->pick.crc)) if (crc_is_compressed(rbio->pick.crc))
return 0; 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); BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter); k = bch2_btree_iter_peek_slot(iter);
if ((ret = bkey_err(k))) if ((ret = bkey_err(k)))
...@@ -2011,7 +2011,7 @@ int __bch2_read_indirect_extent(struct btree_trans *trans, ...@@ -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) + reflink_offset = le64_to_cpu(bkey_i_to_reflink_p(orig_k->k)->v.idx) +
*offset_into_extent; *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), POS(0, reflink_offset),
BTREE_ITER_SLOTS); BTREE_ITER_SLOTS);
k = bch2_btree_iter_peek_slot(iter); 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) ...@@ -2319,7 +2319,7 @@ void bch2_read(struct bch_fs *c, struct bch_read_bio *rbio, u64 inode)
retry: retry:
bch2_trans_begin(&trans); 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), POS(inode, rbio->bio.bi_iter.bi_sector),
BTREE_ITER_SLOTS); BTREE_ITER_SLOTS);
while (1) { while (1) {
......
...@@ -99,8 +99,8 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags ...@@ -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) 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) ?: return __bch2_dev_usrdata_drop(c, dev_idx, flags, BTREE_ID_extents) ?:
__bch2_dev_usrdata_drop(c, dev_idx, flags, BTREE_ID_REFLINK); __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) static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
......
...@@ -578,7 +578,7 @@ static int __bch2_move_data(struct bch_fs *c, ...@@ -578,7 +578,7 @@ static int __bch2_move_data(struct bch_fs *c,
if (!bkey_extent_is_direct_data(k.k)) if (!bkey_extent_is_direct_data(k.k))
goto next_nondata; goto next_nondata;
if (btree_id == BTREE_ID_EXTENTS && if (btree_id == BTREE_ID_extents &&
cur_inum != k.k->p.inode) { cur_inum != k.k->p.inode) {
struct bch_inode_unpacked inode; struct bch_inode_unpacked inode;
...@@ -668,8 +668,8 @@ int bch2_move_data(struct bch_fs *c, ...@@ -668,8 +668,8 @@ int bch2_move_data(struct bch_fs *c,
id++) { id++) {
stats->btree_id = id; stats->btree_id = id;
if (id != BTREE_ID_EXTENTS && if (id != BTREE_ID_extents &&
id != BTREE_ID_REFLINK) id != BTREE_ID_reflink)
continue; continue;
ret = __bch2_move_data(c, &ctxt, rate, wp, ret = __bch2_move_data(c, &ctxt, rate, wp,
......
...@@ -30,6 +30,13 @@ const char * const bch2_sb_compat[] = { ...@@ -30,6 +30,13 @@ const char * const bch2_sb_compat[] = {
NULL NULL
}; };
const char * const bch2_btree_ids[] = {
#define x(name, ...) #name,
BCH_BTREE_IDS()
#undef x
NULL
};
const char * const bch2_csum_opts[] = { const char * const bch2_csum_opts[] = {
"none", "none",
"crc32c", "crc32c",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
extern const char * const bch2_error_actions[]; extern const char * const bch2_error_actions[];
extern const char * const bch2_sb_features[]; extern const char * const bch2_sb_features[];
extern const char * const bch2_sb_compat[]; 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_csum_opts[];
extern const char * const bch2_compression_opts[]; extern const char * const bch2_compression_opts[];
extern const char * const bch2_str_hash_types[]; extern const char * const bch2_str_hash_types[];
......
...@@ -363,7 +363,7 @@ static int bch2_quota_init_type(struct bch_fs *c, enum quota_types type) ...@@ -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); 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) { BTREE_ITER_PREFETCH, k, ret) {
if (k.k->p.inode != type) if (k.k->p.inode != type)
break; break;
...@@ -435,7 +435,7 @@ int bch2_fs_quota_read(struct bch_fs *c) ...@@ -435,7 +435,7 @@ int bch2_fs_quota_read(struct bch_fs *c)
bch2_trans_init(&trans, c, 0, 0); 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) { BTREE_ITER_PREFETCH, k, ret) {
switch (k.k->type) { switch (k.k->type) {
case KEY_TYPE_inode: case KEY_TYPE_inode:
...@@ -526,7 +526,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags) ...@@ -526,7 +526,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
if (c->opts.usrquota) if (c->opts.usrquota)
return -EINVAL; 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, 0),
POS(QTYP_USR + 1, 0), POS(QTYP_USR + 1, 0),
NULL); NULL);
...@@ -538,7 +538,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags) ...@@ -538,7 +538,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
if (c->opts.grpquota) if (c->opts.grpquota)
return -EINVAL; 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, 0),
POS(QTYP_GRP + 1, 0), POS(QTYP_GRP + 1, 0),
NULL); NULL);
...@@ -550,7 +550,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags) ...@@ -550,7 +550,7 @@ static int bch2_quota_remove(struct super_block *sb, unsigned uflags)
if (c->opts.prjquota) if (c->opts.prjquota)
return -EINVAL; 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, 0),
POS(QTYP_PRJ + 1, 0), POS(QTYP_PRJ + 1, 0),
NULL); NULL);
...@@ -718,7 +718,7 @@ static int bch2_set_quota_trans(struct btree_trans *trans, ...@@ -718,7 +718,7 @@ static int bch2_set_quota_trans(struct btree_trans *trans,
struct bkey_s_c k; struct bkey_s_c k;
int ret; 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); BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
k = bch2_btree_iter_peek_slot(iter); k = bch2_btree_iter_peek_slot(iter);
......
...@@ -33,7 +33,7 @@ static void drop_alloc_keys(struct journal_keys *keys) ...@@ -33,7 +33,7 @@ static void drop_alloc_keys(struct journal_keys *keys)
size_t src, dst; size_t src, dst;
for (src = 0, dst = 0; src < keys->nr; src++) 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->d[dst++] = keys->d[src];
keys->nr = dst; keys->nr = dst;
...@@ -554,7 +554,7 @@ static int __bch2_alloc_replay_key(struct btree_trans *trans, struct bkey_i *k) ...@@ -554,7 +554,7 @@ static int __bch2_alloc_replay_key(struct btree_trans *trans, struct bkey_i *k)
struct btree_iter *iter; struct btree_iter *iter;
int ret; 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|
BTREE_ITER_CACHED_NOFILL| BTREE_ITER_CACHED_NOFILL|
BTREE_ITER_INTENT); BTREE_ITER_INTENT);
...@@ -606,7 +606,7 @@ static int bch2_journal_replay(struct bch_fs *c, ...@@ -606,7 +606,7 @@ static int bch2_journal_replay(struct bch_fs *c,
for_each_journal_key(keys, i) { for_each_journal_key(keys, i) {
cond_resched(); 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; j->replay_journal_seq = keys.journal_seq_base + i->journal_seq;
ret = bch2_alloc_replay_key(c, i->k); ret = bch2_alloc_replay_key(c, i->k);
if (ret) if (ret)
...@@ -645,7 +645,7 @@ static int bch2_journal_replay(struct bch_fs *c, ...@@ -645,7 +645,7 @@ static int bch2_journal_replay(struct bch_fs *c,
for_each_journal_key(keys, i) { for_each_journal_key(keys, i) {
cond_resched(); cond_resched();
if (i->level || i->btree_id == BTREE_ID_ALLOC) if (i->level || i->btree_id == BTREE_ID_alloc)
continue; continue;
replay_now_at(j, keys.journal_seq_base + i->journal_seq); replay_now_at(j, keys.journal_seq_base + i->journal_seq);
...@@ -931,28 +931,28 @@ static int read_btree_roots(struct bch_fs *c) ...@@ -931,28 +931,28 @@ static int read_btree_roots(struct bch_fs *c)
if (!r->alive) if (!r->alive)
continue; continue;
if (i == BTREE_ID_ALLOC && if (i == BTREE_ID_alloc &&
c->opts.reconstruct_alloc) { c->opts.reconstruct_alloc) {
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info); c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
continue; continue;
} }
if (r->error) { if (r->error) {
__fsck_err(c, i == BTREE_ID_ALLOC __fsck_err(c, i == BTREE_ID_alloc
? FSCK_CAN_IGNORE : 0, ? FSCK_CAN_IGNORE : 0,
"invalid btree root %s", "invalid btree root %s",
bch2_btree_ids[i]); bch2_btree_ids[i]);
if (i == BTREE_ID_ALLOC) if (i == BTREE_ID_alloc)
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info); c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
} }
ret = bch2_btree_root_read(c, i, &r->key, r->level); ret = bch2_btree_root_read(c, i, &r->key, r->level);
if (ret) { if (ret) {
__fsck_err(c, i == BTREE_ID_ALLOC __fsck_err(c, i == BTREE_ID_alloc
? FSCK_CAN_IGNORE : 0, ? FSCK_CAN_IGNORE : 0,
"error reading btree root %s", "error reading btree root %s",
bch2_btree_ids[i]); bch2_btree_ids[i]);
if (i == BTREE_ID_ALLOC) if (i == BTREE_ID_alloc)
c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info); c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info);
} }
} }
...@@ -1346,7 +1346,7 @@ int bch2_fs_initialize(struct bch_fs *c) ...@@ -1346,7 +1346,7 @@ int bch2_fs_initialize(struct bch_fs *c)
bch2_inode_pack(c, &packed_inode, &root_inode); bch2_inode_pack(c, &packed_inode, &root_inode);
err = "error creating root directory"; 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, &packed_inode.inode.k_i,
NULL, NULL, 0); NULL, NULL, 0);
if (ret) if (ret)
......
...@@ -119,7 +119,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans, ...@@ -119,7 +119,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
if (orig->k.type == KEY_TYPE_inline_data) if (orig->k.type == KEY_TYPE_inline_data)
bch2_check_set_feature(c, BCH_FEATURE_reflink_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), POS(0, c->reflink_hint),
BTREE_ITER_INTENT|BTREE_ITER_SLOTS, k, ret) { BTREE_ITER_INTENT|BTREE_ITER_SLOTS, k, ret) {
if (reflink_iter->pos.inode) { if (reflink_iter->pos.inode) {
...@@ -219,9 +219,9 @@ s64 bch2_remap_range(struct bch_fs *c, ...@@ -219,9 +219,9 @@ s64 bch2_remap_range(struct bch_fs *c,
bch2_bkey_buf_init(&new_src); bch2_bkey_buf_init(&new_src);
bch2_trans_init(&trans, c, BTREE_ITER_MAX, 4096); 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); 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); BTREE_ITER_INTENT);
while (1) { while (1) {
......
...@@ -945,7 +945,7 @@ void bch2_sb_clean_renumber(struct bch_sb_field_clean *clean, int write) ...@@ -945,7 +945,7 @@ void bch2_sb_clean_renumber(struct bch_sb_field_clean *clean, int write)
for (entry = clean->start; for (entry = clean->start;
entry < (struct jset_entry *) vstruct_end(&clean->field); entry < (struct jset_entry *) vstruct_end(&clean->field);
entry = vstruct_next(entry)) 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) int bch2_fs_mark_dirty(struct bch_fs *c)
......
...@@ -1436,7 +1436,7 @@ int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca) ...@@ -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++) { for (i = 0; i < ca->mi.nbuckets; i++) {
ret = bch2_btree_key_cache_flush(&trans, 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) if (ret)
break; break;
} }
...@@ -1445,7 +1445,7 @@ int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca) ...@@ -1445,7 +1445,7 @@ int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
if (ret) if (ret)
return 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, 0),
POS(ca->dev_idx + 1, 0), POS(ca->dev_idx + 1, 0),
NULL); NULL);
......
...@@ -259,7 +259,7 @@ static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *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); 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) { if (k.k->type == KEY_TYPE_extent) {
struct bkey_s_c_extent e = bkey_s_c_to_extent(k); struct bkey_s_c_extent e = bkey_s_c_to_extent(k);
const union bch_extent_entry *entry; const union bch_extent_entry *entry;
......
...@@ -13,12 +13,12 @@ static void delete_test_keys(struct bch_fs *c) ...@@ -13,12 +13,12 @@ static void delete_test_keys(struct bch_fs *c)
{ {
int ret; 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), POS(0, 0), POS(0, U64_MAX),
NULL); NULL);
BUG_ON(ret); 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), POS(0, 0), POS(0, U64_MAX),
NULL); NULL);
BUG_ON(ret); BUG_ON(ret);
...@@ -37,7 +37,7 @@ static int test_delete(struct bch_fs *c, u64 nr) ...@@ -37,7 +37,7 @@ static int test_delete(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0); 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); BTREE_ITER_INTENT);
ret = bch2_btree_iter_traverse(iter); ret = bch2_btree_iter_traverse(iter);
...@@ -82,7 +82,7 @@ static int test_delete_written(struct bch_fs *c, u64 nr) ...@@ -82,7 +82,7 @@ static int test_delete_written(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0); 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); BTREE_ITER_INTENT);
ret = bch2_btree_iter_traverse(iter); ret = bch2_btree_iter_traverse(iter);
...@@ -130,7 +130,7 @@ static int test_iterate(struct bch_fs *c, u64 nr) ...@@ -130,7 +130,7 @@ static int test_iterate(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p.offset = 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); NULL, NULL, 0);
if (ret) { if (ret) {
bch_err(c, "insert error in test_iterate: %i", 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) ...@@ -142,7 +142,7 @@ static int test_iterate(struct bch_fs *c, u64 nr)
i = 0; 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) { POS_MIN, 0, k, ret) {
if (k.k->p.inode) if (k.k->p.inode)
break; break;
...@@ -184,7 +184,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr) ...@@ -184,7 +184,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
k.k.p.offset = i + 8; k.k.p.offset = i + 8;
k.k.size = 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); NULL, NULL, 0);
if (ret) { if (ret) {
bch_err(c, "insert error in test_iterate_extents: %i", 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) ...@@ -196,7 +196,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr)
i = 0; 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) { POS_MIN, 0, k, ret) {
BUG_ON(bkey_start_offset(k.k) != i); BUG_ON(bkey_start_offset(k.k) != i);
i = k.k->p.offset; i = k.k->p.offset;
...@@ -237,7 +237,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr) ...@@ -237,7 +237,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
bkey_cookie_init(&k.k_i); bkey_cookie_init(&k.k_i);
k.k.p.offset = i * 2; 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); NULL, NULL, 0);
if (ret) { if (ret) {
bch_err(c, "insert error in test_iterate_slots: %i", 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) ...@@ -249,7 +249,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
i = 0; 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) { 0, k, ret) {
if (k.k->p.inode) if (k.k->p.inode)
break; break;
...@@ -265,7 +265,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr) ...@@ -265,7 +265,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr)
i = 0; 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) { BTREE_ITER_SLOTS, k, ret) {
BUG_ON(k.k->p.offset != i); BUG_ON(k.k->p.offset != i);
BUG_ON(bkey_deleted(k.k) != (i & 1)); BUG_ON(bkey_deleted(k.k) != (i & 1));
...@@ -300,7 +300,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr) ...@@ -300,7 +300,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
k.k.p.offset = i + 16; k.k.p.offset = i + 16;
k.k.size = 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); NULL, NULL, 0);
if (ret) { if (ret) {
bch_err(c, "insert error in test_iterate_slots_extents: %i", 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) ...@@ -312,7 +312,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
i = 0; 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) { 0, k, ret) {
BUG_ON(bkey_start_offset(k.k) != i + 8); BUG_ON(bkey_start_offset(k.k) != i + 8);
BUG_ON(k.k->size != 8); BUG_ON(k.k->size != 8);
...@@ -326,7 +326,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr) ...@@ -326,7 +326,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr)
i = 0; 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) { BTREE_ITER_SLOTS, k, ret) {
BUG_ON(bkey_deleted(k.k) != !(i % 16)); BUG_ON(bkey_deleted(k.k) != !(i % 16));
...@@ -354,7 +354,7 @@ static int test_peek_end(struct bch_fs *c, u64 nr) ...@@ -354,7 +354,7 @@ static int test_peek_end(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0); 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); k = bch2_btree_iter_peek(iter);
BUG_ON(k.k); BUG_ON(k.k);
...@@ -374,7 +374,7 @@ static int test_peek_end_extents(struct bch_fs *c, u64 nr) ...@@ -374,7 +374,7 @@ static int test_peek_end_extents(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0); 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); k = bch2_btree_iter_peek(iter);
BUG_ON(k.k); BUG_ON(k.k);
...@@ -403,7 +403,7 @@ static int insert_test_extent(struct bch_fs *c, ...@@ -403,7 +403,7 @@ static int insert_test_extent(struct bch_fs *c,
k.k_i.k.size = end - start; k.k_i.k.size = end - start;
k.k_i.k.version.lo = test_version++; 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); NULL, NULL, 0);
if (ret) if (ret)
bch_err(c, "insert error in insert_test_extent: %i", 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) ...@@ -475,7 +475,7 @@ static int rand_insert(struct bch_fs *c, u64 nr)
k.k.p.offset = test_rand(); k.k.p.offset = test_rand();
ret = __bch2_trans_do(&trans, NULL, NULL, 0, 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) { if (ret) {
bch_err(c, "error in rand_insert: %i", ret); bch_err(c, "error in rand_insert: %i", ret);
break; break;
...@@ -495,7 +495,7 @@ static int rand_lookup(struct bch_fs *c, u64 nr) ...@@ -495,7 +495,7 @@ static int rand_lookup(struct bch_fs *c, u64 nr)
u64 i; u64 i;
bch2_trans_init(&trans, c, 0, 0); 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++) { for (i = 0; i < nr; i++) {
bch2_btree_iter_set_pos(iter, POS(0, test_rand())); bch2_btree_iter_set_pos(iter, POS(0, test_rand()));
...@@ -522,7 +522,7 @@ static int rand_mixed(struct bch_fs *c, u64 nr) ...@@ -522,7 +522,7 @@ static int rand_mixed(struct bch_fs *c, u64 nr)
u64 i; u64 i;
bch2_trans_init(&trans, c, 0, 0); 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++) { for (i = 0; i < nr; i++) {
bch2_btree_iter_set_pos(iter, POS(0, test_rand())); 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) ...@@ -561,7 +561,7 @@ static int __do_delete(struct btree_trans *trans, struct bpos pos)
struct bkey_s_c k; struct bkey_s_c k;
int ret = 0; 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); BTREE_ITER_INTENT);
k = bch2_btree_iter_peek(iter); k = bch2_btree_iter_peek(iter);
ret = bkey_err(k); ret = bkey_err(k);
...@@ -616,7 +616,7 @@ static int seq_insert(struct bch_fs *c, u64 nr) ...@@ -616,7 +616,7 @@ static int seq_insert(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0); 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) { BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
insert.k.p = iter->pos; insert.k.p = iter->pos;
...@@ -643,7 +643,7 @@ static int seq_lookup(struct bch_fs *c, u64 nr) ...@@ -643,7 +643,7 @@ static int seq_lookup(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0); 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); bch2_trans_exit(&trans);
return ret; return ret;
...@@ -658,7 +658,7 @@ static int seq_overwrite(struct bch_fs *c, u64 nr) ...@@ -658,7 +658,7 @@ static int seq_overwrite(struct bch_fs *c, u64 nr)
bch2_trans_init(&trans, c, 0, 0); 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) { BTREE_ITER_INTENT, k, ret) {
struct bkey_i_cookie u; struct bkey_i_cookie u;
...@@ -679,7 +679,7 @@ static int seq_delete(struct bch_fs *c, u64 nr) ...@@ -679,7 +679,7 @@ static int seq_delete(struct bch_fs *c, u64 nr)
{ {
int ret; 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), POS(0, 0), POS(0, U64_MAX),
NULL); NULL);
if (ret) if (ret)
......
...@@ -61,7 +61,7 @@ static bool xattr_cmp_bkey(struct bkey_s_c _l, struct bkey_s_c _r) ...@@ -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 = { const struct bch_hash_desc bch2_xattr_hash_desc = {
.btree_id = BTREE_ID_XATTRS, .btree_id = BTREE_ID_xattrs,
.key_type = KEY_TYPE_xattr, .key_type = KEY_TYPE_xattr,
.hash_key = xattr_hash_key, .hash_key = xattr_hash_key,
.hash_bkey = xattr_hash_bkey, .hash_bkey = xattr_hash_bkey,
...@@ -279,7 +279,7 @@ ssize_t bch2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) ...@@ -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); 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) { POS(inum, 0), 0, k, ret) {
BUG_ON(k.k->p.inode < inum); BUG_ON(k.k->p.inode < inum);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment