Skip to content

Commit 86dbf8c

Browse files
author
Kent Overstreet
committed
bcachefs: Fix btree node merging on write buffer btrees
The btree write buffer flush fastpath that avoids the main transaction commit path had the unfortunate side effect of not doing btree node merging. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 3f10048 commit 86dbf8c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

fs/bcachefs/btree_write_buffer.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,16 @@ static int bch2_btree_write_buffer_flush_locked(struct btree_trans *trans)
316316
bpos_gt(k->k.k.p, path->l[0].b->key.k.p)) {
317317
bch2_btree_node_unlock_write(trans, path, path->l[0].b);
318318
write_locked = false;
319+
320+
ret = lockrestart_do(trans,
321+
bch2_btree_iter_traverse(&iter) ?:
322+
bch2_foreground_maybe_merge(trans, iter.path, 0,
323+
BCH_WATERMARK_reclaim|
324+
BCH_TRANS_COMMIT_journal_reclaim|
325+
BCH_TRANS_COMMIT_no_check_rw|
326+
BCH_TRANS_COMMIT_no_enospc));
327+
if (ret)
328+
goto err;
319329
}
320330
}
321331

@@ -382,10 +392,10 @@ static int bch2_btree_write_buffer_flush_locked(struct btree_trans *trans)
382392

383393
ret = commit_do(trans, NULL, NULL,
384394
BCH_WATERMARK_reclaim|
395+
BCH_TRANS_COMMIT_journal_reclaim|
385396
BCH_TRANS_COMMIT_no_check_rw|
386397
BCH_TRANS_COMMIT_no_enospc|
387-
BCH_TRANS_COMMIT_no_journal_res|
388-
BCH_TRANS_COMMIT_journal_reclaim,
398+
BCH_TRANS_COMMIT_no_journal_res ,
389399
btree_write_buffered_insert(trans, i));
390400
if (ret)
391401
goto err;

0 commit comments

Comments
 (0)