[PATCH 0/3] mm/zram: route block swap I/O through swap_ops

From: Jianyue Wu

Date: Sun Jun 14 2026 - 11:35:53 EST


This series builds on Christoph Hellwig's swap batching rework that
moves block swap onto struct swap_iocb and per-backend struct
swap_ops handlers [1]. Christoph's patches unify batching for
ordinary block devices and swap files. zram still needs a custom
path because swap slots map to compressed pages, not disk sectors.

The first patch adds swap_register_block_ops() so a block driver can
install custom submit_read/submit_write handlers when swapon targets
its block device. The default swap_bdev_ops path is unchanged for
devices that do not register.

The second patch registers zram_swap_ops at module init. On write,
the swap core still batches folios into a swap_iocb. zram maps each
folio to a slot index and stores it through zram_write_page() instead
of building one bio per page. Read handling keeps slot_lock and
mark_slot_accessed() in one critical section. Writeback-enabled zram
falls back to swap_bdev_submit_read() for ZRAM_WB slots.

The third patch moves slot_free_notify into swap_ops next to the
other zram swap callbacks, and documents the locking contract for
that hook.

Applied on top of Christoph Hellwig's "better block swap batching and
a different take on swap_ops" series [1].

[1] https://lore.kernel.org/linux-mm/?q=better+block+swap+batching

To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Chris Li <chrisl@xxxxxxxxxx>
Cc: Baoquan He <bhe@xxxxxxxxxx>
Cc: Nhat Pham <nphamcs@xxxxxxxxx>
Cc: Barry Song <baohua@xxxxxxxxxx>
Cc: Kairui Song <kasong@xxxxxxxxxxx>
Cc: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
Cc: Youngjun Park <youngjun.park@xxxxxxx>
Cc: Minchan Kim <minchan@xxxxxxxxxx>
Cc: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
Cc: Jan Kara <jack@xxxxxxx>
Cc: linux-mm@xxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-block@xxxxxxxxxxxxxxx
Cc: linux-doc@xxxxxxxxxxxxxxx

Signed-off-by: Jianyue Wu <wujianyue000@xxxxxxxxx>
---
Jianyue Wu (3):
mm/page_io: let block drivers register custom swap I/O ops
mm/zram: handle swap read/write via swap_ops
mm/swap: route slot free notifications through swap_ops

Documentation/filesystems/locking.rst | 5 -
drivers/block/zram/zram_drv.c | 215 +++++++++++++++++++++++++++-------
include/linux/blkdev.h | 2 -
include/linux/swap.h | 47 ++++++++
mm/page_io.c | 187 ++++++++++++++++++++++++++++-
mm/swap.h | 18 +--
mm/swapfile.c | 17 +--
rust/kernel/block/mq/gen_disk.rs | 1 -
8 files changed, 414 insertions(+), 78 deletions(-)
---
base-commit: 842f51deada6449843f811bfa22e536a01ae5a0c
change-id: 20260614-zram-swap-ops-block-register-a1b2c3d4e5f6

Best regards,
--
Jianyue Wu <wujianyue000@xxxxxxxxx>