summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/data_update.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-03-29 22:47:30 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:58 -0400
commit25d8f40560e75aea107b0e773f8712931173ded6 (patch)
treefeabd5ad0f9cd10d8105b8f291c4b8f9382eb135 /fs/bcachefs/data_update.c
parent32de2ea0d5b7e2bc2a4eeac47e38aceb0ff25cc9 (diff)
downloadlinux-25d8f40560e75aea107b0e773f8712931173ded6.tar.gz
linux-25d8f40560e75aea107b0e773f8712931173ded6.tar.bz2
linux-25d8f40560e75aea107b0e773f8712931173ded6.zip
bcachefs: Data update path no longer leaves cached replicas
It turns out that it's currently impossible to invalidate buckets containing only cached data if they're part of a stripe. The normal bucket invalidate path can't do it because we have to be able to incerement the bucket's gen, which isn't correct becasue it's still a member of the stripe - and the bucket invalidate path makes the bucket availabel for reuse right away, which also isn't correct for buckets in stripes. What would work is invalidating cached data by following backpointers, except that cached replicas don't currently get backpointers - because they would be awkward for the existing bucket invalidate path to delete and they haven't been needed elsewhere. So for the time being, to prevent running out of space in stripes, switch the data update path to not leave cached replicas; we may revisit this in the future. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/data_update.c')
-rw-r--r--fs/bcachefs/data_update.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c
index 5ec884a222f8..865514dd2aa9 100644
--- a/fs/bcachefs/data_update.c
+++ b/fs/bcachefs/data_update.c
@@ -162,7 +162,11 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
if (((1U << i) & m->data_opts.rewrite_ptrs) &&
(ptr = bch2_extent_has_ptr(old, p, bkey_i_to_s(insert))) &&
!ptr->cached) {
+ bch2_bkey_drop_ptr_noerror(bkey_i_to_s(insert), ptr);
+ /*
+ * See comment below:
bch2_extent_ptr_set_cached(bkey_i_to_s(insert), ptr);
+ */
rewrites_found |= 1U << i;
}
i++;
@@ -204,7 +208,14 @@ restart_drop_extra_replicas:
if (!p.ptr.cached &&
durability - ptr_durability >= m->op.opts.data_replicas) {
durability -= ptr_durability;
+ bch2_bkey_drop_ptr_noerror(bkey_i_to_s(insert), &entry->ptr);
+ /*
+ * Currently, we're dropping unneeded replicas
+ * instead of marking them as cached, since
+ * cached data in stripe buckets prevents them
+ * from being reused:
bch2_extent_ptr_set_cached(bkey_i_to_s(insert), &entry->ptr);
+ */
goto restart_drop_extra_replicas;
}
}