Commit 996fb577 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Add an option for whether inodes use the key cache

We probably don't ever want to flip this off in production, but it may
be useful for certain kinds of testing.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 9f6e1f7b
...@@ -1350,6 +1350,7 @@ LE64_BITMASK(BCH_SB_GC_RESERVE_BYTES, struct bch_sb, flags[2], 4, 64); ...@@ -1350,6 +1350,7 @@ LE64_BITMASK(BCH_SB_GC_RESERVE_BYTES, struct bch_sb, flags[2], 4, 64);
LE64_BITMASK(BCH_SB_ERASURE_CODE, struct bch_sb, flags[3], 0, 16); LE64_BITMASK(BCH_SB_ERASURE_CODE, struct bch_sb, flags[3], 0, 16);
LE64_BITMASK(BCH_SB_METADATA_TARGET, struct bch_sb, flags[3], 16, 28); LE64_BITMASK(BCH_SB_METADATA_TARGET, struct bch_sb, flags[3], 16, 28);
LE64_BITMASK(BCH_SB_SHARD_INUMS, struct bch_sb, flags[3], 28, 29); LE64_BITMASK(BCH_SB_SHARD_INUMS, struct bch_sb, flags[3], 28, 29);
LE64_BITMASK(BCH_SB_INODES_USE_KEY_CACHE,struct bch_sb, flags[3], 29, 30);
/* /*
* Features: * Features:
......
...@@ -300,8 +300,10 @@ struct btree_iter *bch2_inode_peek(struct btree_trans *trans, ...@@ -300,8 +300,10 @@ 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), if (trans->c->opts.inodes_use_key_cache)
BTREE_ITER_CACHED|flags); flags |= BTREE_ITER_CACHED;
iter = bch2_trans_get_iter(trans, BTREE_ID_inodes, POS(0, inum), flags);
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)
...@@ -577,8 +579,12 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached) ...@@ -577,8 +579,12 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached)
struct bpos end = POS(inode_nr + 1, 0); struct bpos end = POS(inode_nr + 1, 0);
struct bch_inode_unpacked inode_u; struct bch_inode_unpacked inode_u;
struct bkey_s_c k; struct bkey_s_c k;
unsigned iter_flags = BTREE_ITER_INTENT;
int ret; int ret;
if (cached && c->opts.inodes_use_key_cache)
iter_flags |= BTREE_ITER_CACHED;
bch2_trans_init(&trans, c, 0, 1024); bch2_trans_init(&trans, c, 0, 1024);
/* /*
...@@ -600,11 +606,8 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached) ...@@ -600,11 +606,8 @@ int bch2_inode_rm(struct bch_fs *c, u64 inode_nr, bool cached)
retry: retry:
bch2_trans_begin(&trans); bch2_trans_begin(&trans);
iter = bch2_trans_get_iter(&trans, BTREE_ID_inodes, POS(0, inode_nr), iter = bch2_trans_get_iter(&trans, BTREE_ID_inodes,
(cached POS(0, inode_nr), iter_flags);
? BTREE_ITER_CACHED
: BTREE_ITER_SLOTS)|
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);
......
...@@ -173,6 +173,11 @@ enum opt_type { ...@@ -173,6 +173,11 @@ enum opt_type {
OPT_BOOL(), \ OPT_BOOL(), \
BCH_SB_SHARD_INUMS, false, \ BCH_SB_SHARD_INUMS, false, \
NULL, "Shard new inode numbers by CPU id") \ NULL, "Shard new inode numbers by CPU id") \
x(inodes_use_key_cache, u8, \
OPT_FORMAT|OPT_MOUNT, \
OPT_BOOL(), \
BCH_SB_INODES_USE_KEY_CACHE, true, \
NULL, "Use the btree key cache for the inodes btree") \
x(gc_reserve_percent, u8, \ x(gc_reserve_percent, u8, \
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
OPT_UINT(5, 21), \ OPT_UINT(5, 21), \
......
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