80 lines
2.9 KiB
Diff
80 lines
2.9 KiB
Diff
From 53f02a6929c291960b8d44540a7085940b82366d Mon Sep 17 00:00:00 2001
|
|
From: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Date: Thu, 7 Nov 2024 19:15:38 -0500
|
|
Subject: [PATCH 074/233] bcachefs: Don't use page allocator for
|
|
sb_read_scratch
|
|
Content-Type: text/plain; charset="utf-8"
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Kill another unnecessary dependency on PAGE_SIZE
|
|
|
|
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
|
|
---
|
|
fs/bcachefs/super-io.c | 7 ++++---
|
|
fs/bcachefs/super-io.h | 2 ++
|
|
fs/bcachefs/super.c | 4 ++--
|
|
3 files changed, 8 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
|
|
index c83bd3dedb1b..4c29f8215d54 100644
|
|
--- a/fs/bcachefs/super-io.c
|
|
+++ b/fs/bcachefs/super-io.c
|
|
@@ -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);
|
|
diff --git a/fs/bcachefs/super-io.h b/fs/bcachefs/super-io.h
|
|
index fadd364e2802..90e7b176cdd0 100644
|
|
--- a/fs/bcachefs/super-io.h
|
|
+++ b/fs/bcachefs/super-io.h
|
|
@@ -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) &&
|
|
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
|
|
index ab678231afd4..6ab93db52eca 100644
|
|
--- a/fs/bcachefs/super.c
|
|
+++ b/fs/bcachefs/super.c
|
|
@@ -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;
|
|
--
|
|
2.45.2
|
|
|