Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit fdccb24

Browse files
author
Kent Overstreet
committed
bcachefs: Rereplicate now moves data off of durability=0 devices
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>
1 parent 9a64e1b commit fdccb24

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

fs/bcachefs/move.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,20 @@ static bool rereplicate_pred(struct bch_fs *c, void *arg,
920920
? c->opts.metadata_replicas
921921
: io_opts->data_replicas;
922922

923-
if (!nr_good || nr_good >= replicas)
923+
rcu_read_lock();
924+
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
925+
unsigned i = 0;
926+
bkey_for_each_ptr(ptrs, ptr) {
927+
struct bch_dev *ca = bch2_dev_rcu(c, ptr->dev);
928+
if (!ptr->cached &&
929+
(!ca || !ca->mi.durability))
930+
data_opts->kill_ptrs |= BIT(i);
931+
i++;
932+
}
933+
rcu_read_unlock();
934+
935+
if (!data_opts->kill_ptrs &&
936+
(!nr_good || nr_good >= replicas))
924937
return false;
925938

926939
data_opts->target = 0;

0 commit comments

Comments
 (0)