From: Kent Overstreet Date: Fri, 28 May 2021 09:06:18 +0000 (-0400) Subject: bcachefs: Fix pathalogical behaviour with inode sharding by cpu ID X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=bff796ae6539b50bb3fe595e8db7b72e3255a34d;p=linux.git bcachefs: Fix pathalogical behaviour with inode sharding by cpu ID If the transactior restarts on a different CPU, it could end up needing to read in a different btree node, which makes another transaction restart more likely... Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c index 08c6af886df7b..00a63fecb976e 100644 --- a/fs/bcachefs/fs-common.c +++ b/fs/bcachefs/fs-common.c @@ -23,6 +23,7 @@ int bch2_create_trans(struct btree_trans *trans, u64 dir_inum, struct btree_iter *inode_iter = NULL; struct bch_hash_info hash = bch2_hash_info_init(c, new_inode); u64 now = bch2_current_time(c); + u64 cpu = raw_smp_processor_id(); u64 dir_offset = 0; int ret; @@ -36,7 +37,7 @@ int bch2_create_trans(struct btree_trans *trans, u64 dir_inum, if (!name) new_inode->bi_flags |= BCH_INODE_UNLINKED; - inode_iter = bch2_inode_create(trans, new_inode, U32_MAX); + inode_iter = bch2_inode_create(trans, new_inode, U32_MAX, cpu); ret = PTR_ERR_OR_ZERO(inode_iter); if (ret) goto err; diff --git a/fs/bcachefs/inode.c b/fs/bcachefs/inode.c index 0af493c8669d5..524da018e9d94 100644 --- a/fs/bcachefs/inode.c +++ b/fs/bcachefs/inode.c @@ -472,7 +472,7 @@ static inline u32 bkey_generation(struct bkey_s_c k) struct btree_iter *bch2_inode_create(struct btree_trans *trans, struct bch_inode_unpacked *inode_u, - u32 snapshot) + u32 snapshot, u64 cpu) { struct bch_fs *c = trans->c; struct btree_iter *iter = NULL; @@ -482,8 +482,6 @@ struct btree_iter *bch2_inode_create(struct btree_trans *trans, unsigned bits = (c->opts.inodes_32bit ? 31 : 63); if (c->opts.shard_inode_numbers) { - u64 cpu = raw_smp_processor_id(); - bits -= c->inode_shard_bits; min = (cpu << bits); diff --git a/fs/bcachefs/inode.h b/fs/bcachefs/inode.h index 558d5464095d2..2cb081ae44d92 100644 --- a/fs/bcachefs/inode.h +++ b/fs/bcachefs/inode.h @@ -70,7 +70,7 @@ void bch2_inode_init(struct bch_fs *, struct bch_inode_unpacked *, struct bch_inode_unpacked *); struct btree_iter *bch2_inode_create(struct btree_trans *, - struct bch_inode_unpacked *, u32); + struct bch_inode_unpacked *, u32, u64); int bch2_inode_rm(struct bch_fs *, u64, bool);