bcachefs: rebalance writes use BCH_WRITE_ONLY_SPECIFIED_DEVS
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 1 Sep 2024 20:55:35 +0000 (16:55 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Sep 2024 15:35:20 +0000 (11:35 -0400)
this was an oversight: rebalance is moving data to a specific device, so
we don't want it falling back to the full filesystem

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_foreground.c
fs/bcachefs/rebalance.c

index 7ab1200..bf8fb9c 100644 (file)
@@ -1389,8 +1389,6 @@ int bch2_alloc_sectors_start_trans(struct btree_trans *trans,
        if (!IS_ENABLED(CONFIG_BCACHEFS_ERASURE_CODING))
                erasure_code = false;
 
-       BUG_ON(flags & BCH_WRITE_ONLY_SPECIFIED_DEVS);
-
        BUG_ON(!nr_replicas || !nr_replicas_required);
 retry:
        ptrs.nr         = 0;
index cf81e51..2d299a3 100644 (file)
@@ -13,6 +13,7 @@
 #include "errcode.h"
 #include "error.h"
 #include "inode.h"
+#include "io_write.h"
 #include "move.h"
 #include "rebalance.h"
 #include "subvolume.h"
@@ -156,6 +157,7 @@ static struct bkey_s_c next_rebalance_extent(struct btree_trans *trans,
        data_opts->rewrite_ptrs         =
                bch2_bkey_ptrs_need_rebalance(c, k, r->target, r->compression);
        data_opts->target               = r->target;
+       data_opts->write_flags          |= BCH_WRITE_ONLY_SPECIFIED_DEVS;
 
        if (!data_opts->rewrite_ptrs) {
                /*
@@ -263,6 +265,7 @@ static bool rebalance_pred(struct bch_fs *c, void *arg,
 
        data_opts->rewrite_ptrs         = bch2_bkey_ptrs_need_rebalance(c, k, target, compression);
        data_opts->target               = target;
+       data_opts->write_flags          |= BCH_WRITE_ONLY_SPECIFIED_DEVS;
        return data_opts->rewrite_ptrs != 0;
 }