Commit bff796ae authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent d797ca3d
...@@ -23,6 +23,7 @@ int bch2_create_trans(struct btree_trans *trans, u64 dir_inum, ...@@ -23,6 +23,7 @@ int bch2_create_trans(struct btree_trans *trans, u64 dir_inum,
struct btree_iter *inode_iter = NULL; struct btree_iter *inode_iter = NULL;
struct bch_hash_info hash = bch2_hash_info_init(c, new_inode); struct bch_hash_info hash = bch2_hash_info_init(c, new_inode);
u64 now = bch2_current_time(c); u64 now = bch2_current_time(c);
u64 cpu = raw_smp_processor_id();
u64 dir_offset = 0; u64 dir_offset = 0;
int ret; int ret;
...@@ -36,7 +37,7 @@ int bch2_create_trans(struct btree_trans *trans, u64 dir_inum, ...@@ -36,7 +37,7 @@ int bch2_create_trans(struct btree_trans *trans, u64 dir_inum,
if (!name) if (!name)
new_inode->bi_flags |= BCH_INODE_UNLINKED; 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); ret = PTR_ERR_OR_ZERO(inode_iter);
if (ret) if (ret)
goto err; goto err;
......
...@@ -472,7 +472,7 @@ static inline u32 bkey_generation(struct bkey_s_c k) ...@@ -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 btree_iter *bch2_inode_create(struct btree_trans *trans,
struct bch_inode_unpacked *inode_u, struct bch_inode_unpacked *inode_u,
u32 snapshot) u32 snapshot, u64 cpu)
{ {
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct btree_iter *iter = NULL; struct btree_iter *iter = NULL;
...@@ -482,8 +482,6 @@ struct btree_iter *bch2_inode_create(struct btree_trans *trans, ...@@ -482,8 +482,6 @@ struct btree_iter *bch2_inode_create(struct btree_trans *trans,
unsigned bits = (c->opts.inodes_32bit ? 31 : 63); unsigned bits = (c->opts.inodes_32bit ? 31 : 63);
if (c->opts.shard_inode_numbers) { if (c->opts.shard_inode_numbers) {
u64 cpu = raw_smp_processor_id();
bits -= c->inode_shard_bits; bits -= c->inode_shard_bits;
min = (cpu << bits); min = (cpu << bits);
......
...@@ -70,7 +70,7 @@ void bch2_inode_init(struct bch_fs *, struct bch_inode_unpacked *, ...@@ -70,7 +70,7 @@ void bch2_inode_init(struct bch_fs *, struct bch_inode_unpacked *,
struct bch_inode_unpacked *); struct bch_inode_unpacked *);
struct btree_iter *bch2_inode_create(struct btree_trans *, 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); int bch2_inode_rm(struct bch_fs *, u64, bool);
......
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