Skip to content

Commit 0971a72

Browse files
author
Kent Overstreet
committed
bcachefs: bch2_trans_unlock_write()
New helper for dropping all write locks; which is distinct from the helper the transaction commit path uses, which is faster and only touches updates. Signed-off-by: Kent Overstreet <[email protected]>
1 parent e1911d7 commit 0971a72

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

fs/bcachefs/btree_locking.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,17 @@ void bch2_trans_unlock_long(struct btree_trans *trans)
818818
bch2_trans_srcu_unlock(trans);
819819
}
820820

821+
void bch2_trans_unlock_write(struct btree_trans *trans)
822+
{
823+
struct btree_path *path;
824+
unsigned i;
825+
826+
trans_for_each_path(trans, path, i)
827+
for (unsigned l = 0; l < BTREE_MAX_DEPTH; l++)
828+
if (btree_node_write_locked(path, l))
829+
bch2_btree_node_unlock_write(trans, path, path->l[l].b);
830+
}
831+
821832
int __bch2_trans_mutex_lock(struct btree_trans *trans,
822833
struct mutex *lock)
823834
{

fs/bcachefs/btree_locking.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
void bch2_btree_lock_init(struct btree_bkey_cached_common *, enum six_lock_init_flags);
1717

1818
void bch2_trans_unlock_noassert(struct btree_trans *);
19+
void bch2_trans_unlock_write(struct btree_trans *);
1920

2021
static inline bool is_btree_node(struct btree_path *path, unsigned l)
2122
{

fs/bcachefs/btree_trans_commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static inline int bch2_trans_lock_write(struct btree_trans *trans)
133133
return 0;
134134
}
135135

136-
static inline void bch2_trans_unlock_write(struct btree_trans *trans)
136+
static inline void bch2_trans_unlock_updates_write(struct btree_trans *trans)
137137
{
138138
if (likely(trans->write_locked)) {
139139
trans_for_each_update(trans, i)
@@ -384,7 +384,7 @@ btree_key_can_insert_cached_slowpath(struct btree_trans *trans, unsigned flags,
384384
struct bkey_i *new_k;
385385
int ret;
386386

387-
bch2_trans_unlock_write(trans);
387+
bch2_trans_unlock_updates_write(trans);
388388
bch2_trans_unlock(trans);
389389

390390
new_k = kmalloc(new_u64s * sizeof(u64), GFP_KERNEL);
@@ -868,7 +868,7 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, unsigned flags
868868
if (!ret && unlikely(trans->journal_replay_not_finished))
869869
bch2_drop_overwrites_from_journal(trans);
870870

871-
bch2_trans_unlock_write(trans);
871+
bch2_trans_unlock_updates_write(trans);
872872

873873
if (!ret && trans->journal_pin)
874874
bch2_journal_pin_add(&c->journal, trans->journal_res.seq,

0 commit comments

Comments
 (0)