summaryrefslogtreecommitdiff
path: root/fs/bcachefs/inode.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-05-27 20:20:20 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:04 -0400
commitb282a74faebc9475355179aff40b98b5dbe0ae01 (patch)
tree43dc0e62f3cbd3b4f551bac10526f6f051ca8481 /fs/bcachefs/inode.c
parent9f311f2166eb969dbe3d69ab24cd78567a30d62c (diff)
downloadlwn-b282a74faebc9475355179aff40b98b5dbe0ae01.tar.gz
lwn-b282a74faebc9475355179aff40b98b5dbe0ae01.zip
bcachefs: Add an option to control sharding new inode numbers
We're seeing a bug where inode creates end up spinning in bch2_inode_create - disabling sharding will simplify what we're testing. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/inode.c')
-rw-r--r--fs/bcachefs/inode.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c
index 2ae55467c583..0af493c8669d 100644
--- a/fs/bcachefs/inode.c
+++ b/fs/bcachefs/inode.c
@@ -479,16 +479,23 @@ struct btree_iter *bch2_inode_create(struct btree_trans *trans,
struct bkey_s_c k;
u64 min, max, start, pos, *hint;
int ret = 0;
+ unsigned bits = (c->opts.inodes_32bit ? 31 : 63);
- u64 cpu = raw_smp_processor_id();
- unsigned bits = (c->opts.inodes_32bit
- ? 31 : 63) - c->inode_shard_bits;
+ if (c->opts.shard_inode_numbers) {
+ u64 cpu = raw_smp_processor_id();
- min = (cpu << bits);
- max = (cpu << bits) | ~(ULLONG_MAX << bits);
+ bits -= c->inode_shard_bits;
- min = max_t(u64, min, BLOCKDEV_INODE_MAX);
- hint = c->unused_inode_hints + cpu;
+ min = (cpu << bits);
+ max = (cpu << bits) | ~(ULLONG_MAX << bits);
+
+ min = max_t(u64, min, BLOCKDEV_INODE_MAX);
+ hint = c->unused_inode_hints + cpu;
+ } else {
+ min = BLOCKDEV_INODE_MAX;
+ max = ~(ULLONG_MAX << bits);
+ hint = c->unused_inode_hints;
+ }
start = READ_ONCE(*hint);