diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-07 16:42:53 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-01 17:47:37 +0100 |
commit | e17b93eb36729c7f889264ebe7e46817a8253560 (patch) | |
tree | 8b566d7d6e25b1f8eee146f09afd1965e630193d /fs/bcachefs/btree_write_buffer.c | |
parent | bcachefs: Make journal replay more efficient (diff) | |
download | linux-e17b93eb36729c7f889264ebe7e46817a8253560.tar.xz linux-e17b93eb36729c7f889264ebe7e46817a8253560.zip |
bcachefs: Avoiding dropping/retaking write locks in bch2_btree_write_buffer_flush_one()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_write_buffer.c')
-rw-r--r-- | fs/bcachefs/btree_write_buffer.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/fs/bcachefs/btree_write_buffer.c b/fs/bcachefs/btree_write_buffer.c index 7f3147e064a5..f40ac365620f 100644 --- a/fs/bcachefs/btree_write_buffer.c +++ b/fs/bcachefs/btree_write_buffer.c @@ -48,6 +48,13 @@ static int bch2_btree_write_buffer_flush_one(struct btree_trans *trans, if (ret) return ret; + /* + * We can't clone a path that has write locks: unshare it now, before + * set_pos and traverse(): + */ + if (iter->path->ref > 1) + iter->path = __bch2_btree_path_make_mut(trans, iter->path, true, _THIS_IP_); + path = iter->path; if (!*write_locked) { @@ -67,15 +74,6 @@ static int bch2_btree_write_buffer_flush_one(struct btree_trans *trans, bch2_btree_insert_key_leaf(trans, path, &wb->k, wb->journal_seq); (*fast)++; - - if (path->ref > 1) { - /* - * We can't clone a path that has write locks: if the path is - * shared, unlock before set_pos(), traverse(): - */ - bch2_btree_node_unlock_write(trans, path, path->l[0].b); - *write_locked = false; - } return 0; trans_commit: trans->journal_res.seq = wb->journal_seq; |