diff options
| author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-09 16:25:21 -0400 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-05-21 20:14:52 -0400 |
| commit | 13ffcbae86dadbf7711f42e4940bafae88a87e1f (patch) | |
| tree | f166b4bec472bd7006a80d78dcae47dc3602baa4 /fs/bcachefs/buckets.c | |
| parent | bcachefs: delete dead items in bch_dev (diff) | |
| download | linux-13ffcbae86dadbf7711f42e4940bafae88a87e1f.tar.gz linux-13ffcbae86dadbf7711f42e4940bafae88a87e1f.zip | |
bcachefs: "buckets with backpointer mismatches" now allocated on demand
More self healing work: we're going to be calling
check_bucket_backpointer_mismatch() at runtime, outside of fsck.
Then when we need to we'll kick off the full
check_extents_to_backpointers recovery pass.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.c')
| -rw-r--r-- | fs/bcachefs/buckets.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 596edc7bba2f..8d6955ef631b 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1324,6 +1324,28 @@ int bch2_dev_buckets_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets) sizeof(bucket_gens->b[0]) * copy); } + for (unsigned i = 0; i < ARRAY_SIZE(ca->bucket_backpointer_mismatches); i++) { + struct bucket_bitmap *bitmap = &ca->bucket_backpointer_mismatches[i]; + + mutex_lock(&bitmap->lock); + if (bitmap->buckets) { + unsigned long *n = kvcalloc(BITS_TO_LONGS(nbuckets), + sizeof(unsigned long), GFP_KERNEL); + if (!n) { + mutex_unlock(&bitmap->lock); + ret = -BCH_ERR_ENOMEM_backpointer_mismatches_bitmap; + goto err; + } + + memcpy(n, bitmap->buckets, + BITS_TO_LONGS(ca->mi.nbuckets) * sizeof(unsigned long)); + kvfree(bitmap->buckets); + bitmap->buckets = n; + + } + mutex_unlock(&bitmap->lock); + } + rcu_assign_pointer(ca->bucket_gens, bucket_gens); bucket_gens = old_bucket_gens; |
