diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-09 05:04:38 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:43 -0400 |
commit | 1ff7849f3b2478a4b4ec8abf77ce5e35acac70be (patch) | |
tree | 5d32bf4cd9931c104f5118b6cc285023cd699713 | |
parent | a8eefbd324cd40fab57ab8eef88347d4f745db93 (diff) |
bcachefs: bch2_btree_insert_node() no longer uses lock_write_nofail
Now that we have an error path plumbed through, there's no need to be
using bch2_btree_node_lock_write_nofail().
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/btree_update.h | 4 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_interior.c | 7 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 14 |
3 files changed, 11 insertions, 14 deletions
diff --git a/fs/bcachefs/btree_update.h b/fs/bcachefs/btree_update.h index 89941fb8caa0..1c2e7b2b4ed5 100644 --- a/fs/bcachefs/btree_update.h +++ b/fs/bcachefs/btree_update.h @@ -8,8 +8,8 @@ struct bch_fs; struct btree; -void bch2_btree_node_lock_for_insert(struct btree_trans *, struct btree_path *, - struct btree *); +void bch2_btree_node_prep_for_write(struct btree_trans *, + struct btree_path *, struct btree *); bool bch2_btree_bset_insert_key(struct btree_trans *, struct btree_path *, struct btree *, struct btree_node_iter *, struct bkey_i *); diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index b0a15757aaea..7619890d9df1 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -1695,6 +1695,7 @@ static int bch2_btree_insert_node(struct btree_update *as, struct btree_trans *t int old_u64s = le16_to_cpu(btree_bset_last(b)->u64s); int old_live_u64s = b->nr.live_u64s; int live_u64s_added, u64s_added; + int ret; lockdep_assert_held(&c->gc_lock); BUG_ON(!btree_node_intent_locked(path, btree_node_root(c, b)->c.level)); @@ -1705,7 +1706,11 @@ static int bch2_btree_insert_node(struct btree_update *as, struct btree_trans *t if (!(local_clock() & 63)) return btree_trans_restart(trans, BCH_ERR_transaction_restart_split_race); - bch2_btree_node_lock_for_insert(trans, path, b); + ret = bch2_btree_node_lock_write(trans, path, &b->c); + if (ret) + return ret; + + bch2_btree_node_prep_for_write(trans, path, b); if (!bch2_btree_node_insert_fits(c, b, bch2_keylist_u64s(keys))) { bch2_btree_node_unlock_write(trans, path, b); diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 98030f22ee05..cf4a7093f1e9 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -56,9 +56,9 @@ static inline bool same_leaf_as_next(struct btree_trans *trans, insert_l(&i[0])->b == insert_l(&i[1])->b; } -static inline void bch2_btree_node_prep_for_write(struct btree_trans *trans, - struct btree_path *path, - struct btree *b) +inline void bch2_btree_node_prep_for_write(struct btree_trans *trans, + struct btree_path *path, + struct btree *b) { struct bch_fs *c = trans->c; @@ -77,14 +77,6 @@ static inline void bch2_btree_node_prep_for_write(struct btree_trans *trans, bch2_btree_init_next(trans, b); } -void bch2_btree_node_lock_for_insert(struct btree_trans *trans, - struct btree_path *path, - struct btree *b) -{ - bch2_btree_node_lock_write_nofail(trans, path, &b->c); - bch2_btree_node_prep_for_write(trans, path, b); -} - /* Inserting into a given leaf node (last stage of insert): */ /* Handle overwrites and do insert, for non extents: */ |