bcachefs: Only allocate buckets_nouse when requested
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 14 Feb 2022 06:42:31 +0000 (01:42 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:24 +0000 (17:09 -0400)
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>
fs/bcachefs/buckets.c
fs/bcachefs/opts.h

index 7ca1087b5bb3faca100d9a2ff104c95093746d28..edc1918cf140314cb9837eba7fd5632f87452416 100644 (file)
@@ -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);
index 4b438098aecb8322f61c2d3505d50e70b1f63dc1..57c829b6eee1e61ec0daf3f188516799fa36eb79 100644 (file)
@@ -365,6 +365,11 @@ enum opt_type {
          NO_SB_OPT,                    false,                          \
          NULL,         "Set superblock to latest version,\n"           \
                        "allowing any new features to be used")         \
+       x(buckets_nouse,                u8,                             \
+         0,                                                            \
+         OPT_BOOL(),                                                   \
+         NO_SB_OPT,                    false,                          \
+         NULL,         "Allocate the buckets_nouse bitmap")            \
        x(project,                      u8,                             \
          OPT_INODE,                                                    \
          OPT_BOOL(),                                                   \