Skip to content

Commit

Permalink
bcachefs: Rereplicate now moves data off of durability=0 devices
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kent Overstreet committed Jun 5, 2024
1 parent 9a64e1b commit fdccb24
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion fs/bcachefs/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fdccb24

Please sign in to comment.