summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-07-07 19:53:54 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-07-07 19:54:48 -0400
commita0f12e09b6e8a5c04855883565a5f93dd808d6f1 (patch)
treec5422815a27418571617fa0f19abcffd04d89f16
parent03d7318c317e1c3a191bdd335ebc189966abbfd8 (diff)
cmd_image: Flush journal before moving btree
We need the key cache to be flushed before moving btree nodes - key cache flushing won't obey the target we're moving btree nodes to. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--c_src/cmd_image.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/c_src/cmd_image.c b/c_src/cmd_image.c
index 12478b1f..b79d36d1 100644
--- a/c_src/cmd_image.c
+++ b/c_src/cmd_image.c
@@ -28,6 +28,7 @@
#include "libbcachefs/alloc_foreground.h"
#include "libbcachefs/data_update.h"
#include "libbcachefs/errcode.h"
+#include "libbcachefs/journal_reclaim.h"
#include "libbcachefs/move.h"
#include "libbcachefs/opts.h"
#include "libbcachefs/super-io.h"
@@ -91,6 +92,12 @@ static bool move_btree_pred(struct bch_fs *c, void *_arg,
static int move_btree(struct bch_fs *c, bool move_alloc, unsigned target_dev)
{
+ /*
+ * Flush the key cache first, otherwise key cache flushing later will do
+ * btree updates to the wrong device
+ */
+ bch2_journal_flush_all_pins(&c->journal);
+
struct move_btree_args args = {
.move_alloc = move_alloc,
.target = dev_to_target(target_dev),