* [PATCH v2 1/4] gfs2: make the log page pool per superblock
2026-11-24 21:04 [PATCH v2 0/4] gfs2: stop using struct page in the log code Tal Zussman
@ 2026-11-24 21:04 ` Tal Zussman
2026-11-24 21:16 ` sashiko-bot
2026-11-24 21:04 ` [PATCH v2 2/4] gfs2: stop using pages for log buffers Tal Zussman
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Tal Zussman @ 2026-11-24 21:04 UTC (permalink / raw)
To: Andreas Gruenbacher
Cc: gfs2, linux-kernel, Matthew Wilcox (Oracle), Tal Zussman
The log headers, descriptors, revoke blocks, and escaped block copies
come from gfs2_page_pool, a single mempool shared by every mounted
filesystem. Give each superblock a pool of its own, sd_log_buf_pool. A
per-superblock pool can hold buffers of the filesystem's block size,
which a global one cannot.
The pool is set up in gfs2_fill_super() once the superblock has been
read and is destroyed in free_sbd(). Its elements are still pages, so
each mount now reserves 64 pages of its own.
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/gfs2/incore.h | 2 ++
fs/gfs2/log.c | 2 +-
fs/gfs2/lops.c | 10 +++++-----
fs/gfs2/main.c | 8 --------
fs/gfs2/ops_fstype.c | 5 +++++
fs/gfs2/util.c | 1 -
fs/gfs2/util.h | 3 ---
7 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 1ff19f87d3bd..60748b99d39a 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -21,6 +21,7 @@
#include <linux/lockref.h>
#include <linux/rhashtable.h>
#include <linux/mutex.h>
+#include <linux/mempool.h>
#define DIO_WAIT 0x00000010
#define DIO_METADATA 0x00000020
@@ -846,6 +847,7 @@ struct gfs2_sbd {
struct rw_semaphore sd_log_flush_lock;
atomic_t sd_log_in_flight;
wait_queue_head_t sd_log_flush_wait;
+ mempool_t sd_log_buf_pool;
int sd_log_error; /* First log error */
unsigned int sd_log_tail;
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 1baaaf30c4fa..e7076db3ba46 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -850,7 +850,7 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
if (gfs2_withdrawn(sdp))
return;
- page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
+ page = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
lh = page_address(page);
clear_page(lh);
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 657edd406dd1..7a2c29652fec 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -229,7 +229,7 @@ static void gfs2_end_log_write(struct bio *bio)
gfs2_end_log_write_bh(sdp, folio, bvec->bv_offset,
bvec->bv_len, bio->bi_status);
else
- mempool_free(page, gfs2_page_pool);
+ mempool_free(page, &sdp->sd_log_buf_pool);
}
bio_put(bio);
@@ -377,7 +377,7 @@ static void gfs2_log_write_bh(struct gfs2_sbd *sdp, struct buffer_head *bh)
* @page: The struct page
*
* This writes the first block-sized part of the page into the log. Note
- * that the page must have been allocated from the gfs2_page_pool mempool
+ * that the page must have been allocated from the sd_log_buf_pool mempool
* and that after this has been called, ownership has been transferred and
* the page may be freed at any time.
*/
@@ -607,7 +607,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
static struct page *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type,
u32 ld_length, u32 ld_data1)
{
- struct page *page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
+ struct page *page = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
struct gfs2_log_descriptor *ld = page_address(page);
clear_page(ld);
ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
@@ -696,7 +696,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
if (buffer_escaped(bd2->bd_bh)) {
void *p;
- page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
+ page = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
p = page_address(page);
memcpy_from_folio(p, bd2->bd_bh->b_folio,
bh_offset(bd2->bd_bh),
@@ -872,7 +872,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) {
gfs2_log_write_page(sdp, page);
- page = mempool_alloc(gfs2_page_pool, GFP_NOIO);
+ page = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
mh = page_address(page);
clear_page(mh);
mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index a607e98eb45f..8a45b2e9b618 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -16,7 +16,6 @@
#include <linux/rcupdate.h>
#include <linux/rculist_bl.h>
#include <linux/atomic.h>
-#include <linux/mempool.h>
#include "gfs2.h"
#include "incore.h"
@@ -166,10 +165,6 @@ static int __init init_gfs2_fs(void)
if (!gfs2_freeze_wq)
goto fail_wq3;
- gfs2_page_pool = mempool_create_page_pool(64, 0);
- if (!gfs2_page_pool)
- goto fail_mempool;
-
gfs2_register_debugfs();
error = register_filesystem(&gfs2_fs_type);
if (error)
@@ -187,8 +182,6 @@ static int __init init_gfs2_fs(void)
fail_fs2:
unregister_filesystem(&gfs2_fs_type);
fail_fs1:
- mempool_destroy(gfs2_page_pool);
-fail_mempool:
destroy_workqueue(gfs2_freeze_wq);
fail_wq3:
destroy_workqueue(gfs2_control_wq);
@@ -240,7 +233,6 @@ static void __exit exit_gfs2_fs(void)
rcu_barrier();
- mempool_destroy(gfs2_page_pool);
kmem_cache_destroy(gfs2_trans_cachep);
kmem_cache_destroy(gfs2_qadata_cachep);
kmem_cache_destroy(gfs2_quotad_cachep);
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 6ec47376aecf..f62a893ce5a2 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -67,6 +67,7 @@ void free_sbd(struct gfs2_sbd *sdp)
{
struct super_block *sb = sdp->sd_vfs;
+ mempool_exit(&sdp->sd_log_buf_pool);
free_percpu(sdp->sd_lkstats);
sb->s_fs_info = NULL;
kfree(sdp);
@@ -1218,6 +1219,10 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
if (error)
goto fail_locking;
+ error = mempool_init_page_pool(&sdp->sd_log_buf_pool, 64, 0);
+ if (error)
+ goto fail_sb;
+
/* Turn rgrplvb on by default if fs format is recent enough */
if (!sdp->sd_args.ar_got_rgrplvb && sdp->sd_sb.sb_fs_format > 1801)
sdp->sd_args.ar_rgrplvb = 1;
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c
index 529c3ec37a18..d42db8a9f5aa 100644
--- a/fs/gfs2/util.c
+++ b/fs/gfs2/util.c
@@ -34,7 +34,6 @@ struct kmem_cache *gfs2_rgrpd_cachep __read_mostly;
struct kmem_cache *gfs2_quotad_cachep __read_mostly;
struct kmem_cache *gfs2_qadata_cachep __read_mostly;
struct kmem_cache *gfs2_trans_cachep __read_mostly;
-mempool_t *gfs2_page_pool __read_mostly;
void gfs2_assert_i(struct gfs2_sbd *sdp)
{
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h
index ffcc47d6b0b4..0179ddcd4c22 100644
--- a/fs/gfs2/util.h
+++ b/fs/gfs2/util.h
@@ -12,8 +12,6 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#endif
-#include <linux/mempool.h>
-
#include "incore.h"
#define fs_emerg(fs, fmt, ...) \
@@ -165,7 +163,6 @@ extern struct kmem_cache *gfs2_rgrpd_cachep;
extern struct kmem_cache *gfs2_quotad_cachep;
extern struct kmem_cache *gfs2_qadata_cachep;
extern struct kmem_cache *gfs2_trans_cachep;
-extern mempool_t *gfs2_page_pool;
extern struct workqueue_struct *gfs2_control_wq;
static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 2/4] gfs2: stop using pages for log buffers
2026-11-24 21:04 [PATCH v2 0/4] gfs2: stop using struct page in the log code Tal Zussman
2026-11-24 21:04 ` [PATCH v2 1/4] gfs2: make the log page pool per superblock Tal Zussman
@ 2026-11-24 21:04 ` Tal Zussman
2026-11-24 21:21 ` sashiko-bot
2026-11-24 21:04 ` [PATCH v2 3/4] gfs2: plug the log writes of a flush Tal Zussman
2026-11-24 21:04 ` [PATCH v2 4/4] gfs2: remove the remaining page references in the log code Tal Zussman
3 siblings, 1 reply; 8+ messages in thread
From: Tal Zussman @ 2026-11-24 21:04 UTC (permalink / raw)
To: Andreas Gruenbacher
Cc: gfs2, linux-kernel, Matthew Wilcox (Oracle), Tal Zussman
The log headers, descriptors, revoke blocks, and escaped block copies
come from a mempool of pages and share a bio with the buffer heads being
journaled. The completion handler tells the two apart by checking each
segment for buffers, which treats a pool page as a folio. That won't
work once memdescs give these pages a type of their own.
Make the per-superblock pool a kmalloc mempool of block-sized buffers
instead, and add them to the bio with bio_add_virt_nofail(). Give the
pool blocks their own completion handler, and start a new bio whenever
the handler changes so that a bio only holds one kind of segment.
gfs2_log_write() now takes a folio, so the log write path no longer uses
struct page.
Each descriptor and each escaped block copy is now a bio of its own.
They are contiguous and merge under an I/O scheduler, but the flush
path doesn't plug, so without a scheduler they reach the device as
separate writes.
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
fs/gfs2/log.c | 10 +--
fs/gfs2/lops.c | 204 ++++++++++++++++++++++++++++++++-------------------
fs/gfs2/lops.h | 6 +-
fs/gfs2/ops_fstype.c | 3 +-
4 files changed, 136 insertions(+), 87 deletions(-)
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index e7076db3ba46..2f9f20b40adc 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -841,7 +841,6 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
{
struct gfs2_log_header *lh;
u32 hash, crc;
- struct page *page;
struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
struct timespec64 tv;
struct super_block *sb = sdp->sd_vfs;
@@ -850,9 +849,8 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
if (gfs2_withdrawn(sdp))
return;
- page = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
- lh = page_address(page);
- clear_page(lh);
+ lh = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
+ memset(lh, 0, sb->s_blocksize);
lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH);
@@ -905,8 +903,8 @@ void gfs2_write_log_header(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
sb->s_blocksize - LH_V1_SIZE - 4);
lh->lh_crc = cpu_to_be32(crc);
- gfs2_log_write(sdp, jd, page, sb->s_blocksize, 0, dblock,
- REQ_OP_WRITE | op_flags);
+ gfs2_log_write_buf(sdp, jd, lh, sb->s_blocksize, dblock,
+ REQ_OP_WRITE | op_flags);
gfs2_log_submit_write(&jd->jd_log_bio);
}
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 7a2c29652fec..156d7c6341ca 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -196,45 +196,70 @@ static void gfs2_end_log_write_bh(struct gfs2_sbd *sdp, struct folio *folio,
} while (bh && size);
}
+static void gfs2_log_write_error(struct bio *bio)
+{
+ struct gfs2_sbd *sdp = bio->bi_private;
+ int err = blk_status_to_errno(bio->bi_status);
+
+ if (!cmpxchg(&sdp->sd_log_error, 0, err))
+ fs_err(sdp, "Error %d writing to journal, jid=%u\n",
+ err, sdp->sd_jdesc->jd_jid);
+ gfs2_withdraw(sdp);
+}
+
+static void gfs2_log_write_done(struct bio *bio)
+{
+ struct gfs2_sbd *sdp = bio->bi_private;
+
+ bio_put(bio);
+ if (atomic_dec_and_test(&sdp->sd_log_in_flight))
+ wake_up(&sdp->sd_log_flush_wait);
+}
+
/**
- * gfs2_end_log_write - end of i/o to the log
+ * gfs2_end_log_write - end of I/O to the log for buffers
* @bio: The bio
*
- * Each bio_vec contains either data from the pagecache or data
- * relating to the log itself. Here we iterate over the bio_vec
- * array, processing both kinds of data.
- *
+ * Every folio in the bio comes from the page cache. Unlock the buffers
+ * that were written.
*/
static void gfs2_end_log_write(struct bio *bio)
{
struct gfs2_sbd *sdp = bio->bi_private;
- struct bio_vec *bvec;
- struct bvec_iter_all iter_all;
+ struct folio_iter fi;
- if (bio->bi_status) {
- int err = blk_status_to_errno(bio->bi_status);
+ if (bio->bi_status)
+ gfs2_log_write_error(bio);
- if (!cmpxchg(&sdp->sd_log_error, 0, err))
- fs_err(sdp, "Error %d writing to journal, jid=%u\n",
- err, sdp->sd_jdesc->jd_jid);
- gfs2_withdraw(sdp);
- }
+ bio_for_each_folio_all(fi, bio)
+ gfs2_end_log_write_bh(sdp, fi.folio, fi.offset, fi.length,
+ bio->bi_status);
- bio_for_each_segment_all(bvec, bio, iter_all) {
- struct page *page = bvec->bv_page;
- struct folio *folio = page_folio(page);
+ gfs2_log_write_done(bio);
+}
- if (folio && folio_buffers(folio))
- gfs2_end_log_write_bh(sdp, folio, bvec->bv_offset,
- bvec->bv_len, bio->bi_status);
- else
- mempool_free(page, &sdp->sd_log_buf_pool);
- }
+/**
+ * gfs2_end_log_write_buf - end of I/O to the log for log blocks
+ * @bio: The bio
+ *
+ * Every segment in the bio is a block from the log buffer mempool.
+ * Return them to the pool.
+ */
- bio_put(bio);
- if (atomic_dec_and_test(&sdp->sd_log_in_flight))
- wake_up(&sdp->sd_log_flush_wait);
+static void gfs2_end_log_write_buf(struct bio *bio)
+{
+ struct gfs2_sbd *sdp = bio->bi_private;
+ struct bio_vec *bvec;
+ struct bvec_iter_all iter_all;
+
+ if (bio->bi_status)
+ gfs2_log_write_error(bio);
+
+ bio_for_each_segment_all(bvec, bio, iter_all)
+ mempool_free(bvec_virt(bvec), &sdp->sd_log_buf_pool);
+
+ gfs2_log_write_done(bio);
}
/**
@@ -291,9 +316,9 @@ static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno,
* @flush: Always flush the current bio and allocate a new one?
*
* If there is a cached bio, then if the next block number is sequential
- * with the previous one, return it, otherwise flush the bio to the
- * device. If there is no cached bio, or we just flushed it, then
- * allocate a new one.
+ * with the previous one and the bio has the same completion handler,
+ * return it, otherwise flush the bio to the device. If there is no
+ * cached bio, or we just flushed it, then allocate a new one.
*
* Returns: The bio to use for log writes
*/
@@ -309,7 +334,7 @@ static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno,
nblk = bio_end_sector(bio);
nblk >>= sdp->sd_fsb2bb_shift;
- if (blkno == nblk && !flush)
+ if (blkno == nblk && bio->bi_end_io == end_io && !flush)
return bio;
gfs2_log_submit_write(biop);
}
@@ -319,38 +344,63 @@ static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno,
}
/**
- * gfs2_log_write - write to log
+ * gfs2_log_write - write a folio segment to the log
* @sdp: the filesystem
* @jd: The journal descriptor
- * @page: the page to write
+ * @folio: the folio to write
* @size: the size of the data to write
- * @offset: the offset within the page
+ * @offset: the offset within the folio
* @blkno: block number of the log entry
* @opf: REQ_OP | op_flags
*
- * Try and add the page segment to the current bio. If that fails,
+ * Try and add the folio segment to the current bio. If that fails,
* submit the current bio to the device and create a new one, and
- * then add the page segment to that.
+ * then add the folio segment to that.
*/
-void gfs2_log_write(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
- struct page *page, unsigned size, unsigned offset,
- u64 blkno, blk_opf_t opf)
+static void gfs2_log_write(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
+ struct folio *folio, unsigned int size,
+ unsigned int offset, u64 blkno, blk_opf_t opf)
{
struct bio *bio;
- int ret;
bio = gfs2_log_get_bio(sdp, blkno, &jd->jd_log_bio, opf,
gfs2_end_log_write, false);
- ret = bio_add_page(bio, page, size, offset);
- if (ret == 0) {
+ if (!bio_add_folio(bio, folio, size, offset)) {
bio = gfs2_log_get_bio(sdp, blkno, &jd->jd_log_bio,
opf, gfs2_end_log_write, true);
- ret = bio_add_page(bio, page, size, offset);
- WARN_ON(ret == 0);
+ WARN_ON(!bio_add_folio(bio, folio, size, offset));
}
}
+/**
+ * gfs2_log_write_buf - write a log buffer to the log
+ * @sdp: the filesystem
+ * @jd: The journal descriptor
+ * @buf: the buffer to write, from the log buffer mempool
+ * @size: the size of the data to write
+ * @blkno: block number of the log entry
+ * @opf: REQ_OP | op_flags
+ *
+ * Like gfs2_log_write(), for a block allocated from sd_log_buf_pool.
+ * Ownership of the buffer passes to the bio, which returns it to the
+ * pool on completion.
+ */
+
+void gfs2_log_write_buf(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
+ void *buf, unsigned int size, u64 blkno,
+ blk_opf_t opf)
+{
+ struct bio *bio;
+
+ bio = gfs2_log_get_bio(sdp, blkno, &jd->jd_log_bio, opf,
+ gfs2_end_log_write_buf, false);
+ if (bio->bi_vcnt >= bio->bi_max_vecs)
+ bio = gfs2_log_get_bio(sdp, blkno, &jd->jd_log_bio,
+ opf, gfs2_end_log_write_buf, true);
+ bio_add_virt_nofail(bio, buf, size);
+}
+
/**
* gfs2_log_write_bh - write a buffer's content to the log
* @sdp: The super block
@@ -367,30 +417,30 @@ static void gfs2_log_write_bh(struct gfs2_sbd *sdp, struct buffer_head *bh)
dblock = gfs2_log_bmap(sdp->sd_jdesc, sdp->sd_log_flush_head);
gfs2_log_incr_head(sdp);
- gfs2_log_write(sdp, sdp->sd_jdesc, folio_page(bh->b_folio, 0),
- bh->b_size, bh_offset(bh), dblock, REQ_OP_WRITE);
+ gfs2_log_write(sdp, sdp->sd_jdesc, bh->b_folio, bh->b_size,
+ bh_offset(bh), dblock, REQ_OP_WRITE);
}
/**
- * gfs2_log_write_page - write one block stored in a page, into the log
+ * gfs2_log_write_block - write one block stored in a log buffer, into the log
* @sdp: The superblock
- * @page: The struct page
+ * @buf: The buffer
*
- * This writes the first block-sized part of the page into the log. Note
- * that the page must have been allocated from the sd_log_buf_pool mempool
- * and that after this has been called, ownership has been transferred and
- * the page may be freed at any time.
+ * This writes the first block-sized part of the buffer into the log. Note
+ * that the buffer must have been allocated from the sd_log_buf_pool
+ * mempool and that after this has been called, ownership has been
+ * transferred and the buffer may be freed at any time.
*/
-static void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page)
+static void gfs2_log_write_block(struct gfs2_sbd *sdp, void *buf)
{
struct super_block *sb = sdp->sd_vfs;
u64 dblock;
dblock = gfs2_log_bmap(sdp->sd_jdesc, sdp->sd_log_flush_head);
gfs2_log_incr_head(sdp);
- gfs2_log_write(sdp, sdp->sd_jdesc, page, sb->s_blocksize, 0, dblock,
- REQ_OP_WRITE);
+ gfs2_log_write_buf(sdp, sdp->sd_jdesc, buf, sb->s_blocksize, dblock,
+ REQ_OP_WRITE);
}
/**
@@ -604,12 +654,14 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
return ret;
}
-static struct page *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type,
- u32 ld_length, u32 ld_data1)
+static struct gfs2_log_descriptor *gfs2_get_log_desc(struct gfs2_sbd *sdp,
+ u32 ld_type, u32 ld_length,
+ u32 ld_data1)
{
- struct page *page = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
- struct gfs2_log_descriptor *ld = page_address(page);
- clear_page(ld);
+ struct gfs2_log_descriptor *ld;
+
+ ld = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
+ memset(ld, 0, sdp->sd_sb.sb_bsize);
ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
@@ -617,7 +669,7 @@ static struct page *gfs2_get_log_desc(struct gfs2_sbd *sdp, u32 ld_type,
ld->ld_length = cpu_to_be32(ld_length);
ld->ld_data1 = cpu_to_be32(ld_data1);
ld->ld_data2 = 0;
- return page;
+ return ld;
}
static void gfs2_check_magic(struct buffer_head *bh)
@@ -652,7 +704,6 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
{
struct gfs2_log_descriptor *ld;
struct gfs2_bufdata *bd1 = NULL, *bd2;
- struct page *page;
unsigned int num;
unsigned n;
__be64 *ptr;
@@ -665,10 +716,9 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
if (total > limit)
num = limit;
spin_unlock(&sdp->sd_log_lock);
- page = gfs2_get_log_desc(sdp,
- is_databuf ? GFS2_LOG_DESC_JDATA :
- GFS2_LOG_DESC_METADATA, num + 1, num);
- ld = page_address(page);
+ ld = gfs2_get_log_desc(sdp,
+ is_databuf ? GFS2_LOG_DESC_JDATA :
+ GFS2_LOG_DESC_METADATA, num + 1, num);
spin_lock(&sdp->sd_log_lock);
ptr = (__be64 *)(ld + 1);
@@ -684,7 +734,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
}
spin_unlock(&sdp->sd_log_lock);
- gfs2_log_write_page(sdp, page);
+ gfs2_log_write_block(sdp, ld);
spin_lock(&sdp->sd_log_lock);
n = 0;
@@ -696,8 +746,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
if (buffer_escaped(bd2->bd_bh)) {
void *p;
- page = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
- p = page_address(page);
+ p = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
memcpy_from_folio(p, bd2->bd_bh->b_folio,
bh_offset(bd2->bd_bh),
bd2->bd_bh->b_size);
@@ -705,7 +754,7 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
clear_buffer_escaped(bd2->bd_bh);
unlock_buffer(bd2->bd_bh);
brelse(bd2->bd_bh);
- gfs2_log_write_page(sdp, page);
+ gfs2_log_write_block(sdp, p);
} else {
gfs2_log_write_bh(sdp, bd2->bd_bh);
}
@@ -856,7 +905,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
struct gfs2_meta_header *mh;
unsigned int offset;
struct gfs2_bufdata *bd;
- struct page *page;
+ void *buf;
unsigned int length;
gfs2_flush_revokes(sdp);
@@ -864,29 +913,30 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
return;
length = gfs2_struct2blk(sdp, sdp->sd_log_num_revoke);
- page = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE, length, sdp->sd_log_num_revoke);
+ buf = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE, length,
+ sdp->sd_log_num_revoke);
offset = sizeof(struct gfs2_log_descriptor);
list_for_each_entry(bd, &sdp->sd_log_revokes, bd_list) {
sdp->sd_log_num_revoke--;
if (offset + sizeof(u64) > sdp->sd_sb.sb_bsize) {
- gfs2_log_write_page(sdp, page);
- page = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
- mh = page_address(page);
- clear_page(mh);
+ gfs2_log_write_block(sdp, buf);
+ buf = mempool_alloc(&sdp->sd_log_buf_pool, GFP_NOIO);
+ mh = buf;
+ memset(mh, 0, sdp->sd_sb.sb_bsize);
mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
mh->mh_type = cpu_to_be32(GFS2_METATYPE_LB);
mh->mh_format = cpu_to_be32(GFS2_FORMAT_LB);
offset = sizeof(struct gfs2_meta_header);
}
- *(__be64 *)(page_address(page) + offset) = cpu_to_be64(bd->bd_blkno);
+ *(__be64 *)(buf + offset) = cpu_to_be64(bd->bd_blkno);
offset += sizeof(u64);
}
gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke);
- gfs2_log_write_page(sdp, page);
+ gfs2_log_write_block(sdp, buf);
}
void gfs2_drain_revokes(struct gfs2_sbd *sdp)
diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h
index 772557b63b48..c1d9e6fef7ac 100644
--- a/fs/gfs2/lops.h
+++ b/fs/gfs2/lops.h
@@ -14,9 +14,9 @@ extern const struct gfs2_log_operations *gfs2_log_ops[];
void gfs2_log_incr_head(struct gfs2_sbd *sdp);
u64 gfs2_log_bmap(struct gfs2_jdesc *jd, unsigned int lbn);
-void gfs2_log_write(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
- struct page *page, unsigned size, unsigned offset,
- u64 blkno, blk_opf_t opf);
+void gfs2_log_write_buf(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,
+ void *buf, unsigned int size, u64 blkno,
+ blk_opf_t opf);
void gfs2_log_submit_write(struct bio **biop);
void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
int gfs2_find_jhead(struct gfs2_jdesc *jd,
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index f62a893ce5a2..f71174273abf 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1219,7 +1219,8 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
if (error)
goto fail_locking;
- error = mempool_init_page_pool(&sdp->sd_log_buf_pool, 64, 0);
+ error = mempool_init_kmalloc_pool(&sdp->sd_log_buf_pool, 64,
+ sdp->sd_sb.sb_bsize);
if (error)
goto fail_sb;
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread