]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Don't use page allocator for sb_read_scratch
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 8 Nov 2024 00:15:38 +0000 (19:15 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:17 +0000 (01:36 -0500)
Kill another unnecessary dependency on PAGE_SIZE

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/super-io.c
fs/bcachefs/super-io.h
fs/bcachefs/super.c

index c83bd3dedb1b9ea7bafb7612b31a0fadfe5fe5e5..4c29f8215d54a235fd0faf0c8e3b5e8d12f82514 100644 (file)
@@ -892,14 +892,15 @@ static void read_back_super(struct bch_fs *c, struct bch_dev *ca)
        struct bch_sb *sb = ca->disk_sb.sb;
        struct bio *bio = ca->disk_sb.bio;
 
+       memset(ca->sb_read_scratch, 0, BCH_SB_READ_SCRATCH_BUF_SIZE);
+
        bio_reset(bio, ca->disk_sb.bdev, REQ_OP_READ|REQ_SYNC|REQ_META);
        bio->bi_iter.bi_sector  = le64_to_cpu(sb->layout.sb_offset[0]);
        bio->bi_end_io          = write_super_endio;
        bio->bi_private         = ca;
-       bch2_bio_map(bio, ca->sb_read_scratch, PAGE_SIZE);
+       bch2_bio_map(bio, ca->sb_read_scratch, BCH_SB_READ_SCRATCH_BUF_SIZE);
 
-       this_cpu_add(ca->io_done->sectors[READ][BCH_DATA_sb],
-                    bio_sectors(bio));
+       this_cpu_add(ca->io_done->sectors[READ][BCH_DATA_sb], bio_sectors(bio));
 
        percpu_ref_get(&ca->io_ref);
        closure_bio_submit(bio, &c->sb_write);
index fadd364e2802a9e22d582e3004a88ac312f7da5d..90e7b176cdd06f62964610bfc80aa80592e1a1de 100644 (file)
@@ -10,6 +10,8 @@
 
 #include <asm/byteorder.h>
 
+#define BCH_SB_READ_SCRATCH_BUF_SIZE           4096
+
 static inline bool bch2_version_compatible(u16 version)
 {
        return BCH_VERSION_MAJOR(version) <= BCH_VERSION_MAJOR(bcachefs_metadata_version_current) &&
index ab678231afd4689d7fd181514fd5a5deecbe50d1..6ab93db52eca84d1a46641aa1c99aab92913f97e 100644 (file)
@@ -1201,7 +1201,7 @@ static void bch2_dev_free(struct bch_dev *ca)
 
        free_percpu(ca->io_done);
        bch2_dev_buckets_free(ca);
-       free_page((unsigned long) ca->sb_read_scratch);
+       kfree(ca->sb_read_scratch);
 
        bch2_time_stats_quantiles_exit(&ca->io_latency[WRITE]);
        bch2_time_stats_quantiles_exit(&ca->io_latency[READ]);
@@ -1340,7 +1340,7 @@ static struct bch_dev *__bch2_dev_alloc(struct bch_fs *c,
 
        if (percpu_ref_init(&ca->io_ref, bch2_dev_io_ref_complete,
                            PERCPU_REF_INIT_DEAD, GFP_KERNEL) ||
-           !(ca->sb_read_scratch = (void *) __get_free_page(GFP_KERNEL)) ||
+           !(ca->sb_read_scratch = kmalloc(BCH_SB_READ_SCRATCH_BUF_SIZE, GFP_KERNEL)) ||
            bch2_dev_buckets_alloc(c, ca) ||
            !(ca->io_done       = alloc_percpu(*ca->io_done)))
                goto err;