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>
This commit is contained in:
Kent Overstreet 2025-07-07 19:53:54 -04:00
parent 03d7318c31
commit a0f12e09b6

View File

@ -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),