]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bcachefs: Rereplicate now moves data off of durability=0 devices
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 3 Jun 2024 02:25:18 +0000 (22:25 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 5 Jun 2024 14:44:08 +0000 (10:44 -0400)
This fixes an issue where setting a device to durability=0 after it's
been used makes it impossible to remove.

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

index 8171f947fac8f8d75f376d2df4a4ac341a0645d1..2706d82423450cff4688e2470a17c80cde1e827e 100644 (file)
@@ -920,7 +920,20 @@ static bool rereplicate_pred(struct bch_fs *c, void *arg,
                ? c->opts.metadata_replicas
                : io_opts->data_replicas;
 
-       if (!nr_good || nr_good >= replicas)
+       rcu_read_lock();
+       struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
+       unsigned i = 0;
+       bkey_for_each_ptr(ptrs, ptr) {
+               struct bch_dev *ca = bch2_dev_rcu(c, ptr->dev);
+               if (!ptr->cached &&
+                   (!ca || !ca->mi.durability))
+                       data_opts->kill_ptrs |= BIT(i);
+               i++;
+       }
+       rcu_read_unlock();
+
+       if (!data_opts->kill_ptrs &&
+           (!nr_good || nr_good >= replicas))
                return false;
 
        data_opts->target               = 0;