diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-02-14 01:42:31 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:24 -0400 |
commit | 2232fa397c2be92ed80ee48d52de98a1a2916b06 (patch) | |
tree | 91ad7707921c84789dd01f662e4976e0d677bff7 /fs/bcachefs/buckets.c | |
parent | c929f2306e61500bf68a39cb2a16006bfe844d52 (diff) | |
download | lwn-2232fa397c2be92ed80ee48d52de98a1a2916b06.tar.gz lwn-2232fa397c2be92ed80ee48d52de98a1a2916b06.zip |
bcachefs: Only allocate buckets_nouse when requested
It's only needed by the migrate tool - this patch adds an option to
enable allocating it.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/buckets.c')
-rw-r--r-- | fs/bcachefs/buckets.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 7ca1087b5bb3..edc1918cf140 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -2136,9 +2136,10 @@ int bch2_dev_buckets_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets) GFP_KERNEL|__GFP_ZERO)) || !(bucket_gens = kvpmalloc(sizeof(struct bucket_gens) + nbuckets, GFP_KERNEL|__GFP_ZERO)) || - !(buckets_nouse = kvpmalloc(BITS_TO_LONGS(nbuckets) * + (c->opts.buckets_nouse && + !(buckets_nouse = kvpmalloc(BITS_TO_LONGS(nbuckets) * sizeof(unsigned long), - GFP_KERNEL|__GFP_ZERO)) || + GFP_KERNEL|__GFP_ZERO))) || !init_fifo(&free[RESERVE_MOVINGGC], copygc_reserve, GFP_KERNEL) || !init_fifo(&free[RESERVE_NONE], reserve_none, GFP_KERNEL) || @@ -2171,9 +2172,10 @@ int bch2_dev_buckets_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets) memcpy(bucket_gens->b, old_bucket_gens->b, n); - memcpy(buckets_nouse, - ca->buckets_nouse, - BITS_TO_LONGS(n) * sizeof(unsigned long)); + if (buckets_nouse) + memcpy(buckets_nouse, + ca->buckets_nouse, + BITS_TO_LONGS(n) * sizeof(unsigned long)); } rcu_assign_pointer(ca->buckets[0], buckets); |