Re: [PATCH 1/3] mm/page_io: let block drivers register custom swap I/O ops
From: YoungJun Park
Date: Sun Jun 14 2026 - 21:50:49 EST
On Sun, Jun 14, 2026 at 11:35:29PM +0800, Jianyue Wu wrote:
...
Hello Jianyue.
Currently, the patch commit log indicates only a single custom swap
registration is supported. Shouldn't we allow multiple block drivers to
register their custom ops simultaneously from the beginning?
> int shmem_writeout(struct swap_io_ctx *ctx, struct folio *folio,
> struct list_head *folio_list);
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 284eebc40a70..ebdc96092961 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -2849,6 +2849,10 @@ static int setup_swap_extents(struct swap_info_struct *sis,
> sis->ops = &swap_bdev_ops;
>
> if (S_ISBLK(inode->i_mode)) {
> + const struct swap_ops *block_ops = lookup_swap_block_ops(sis);
Also, just a personal thought on this part.
Instead of using `block_device_fops` as a lookup key, what if we handle
this similarly to how filesystems use the `a_ops->swap_activate` callback?
We could add a `swap_activate` callback directly into
struct block_device_operations (zram's zram_devops). This way, the
block device itself can set up and replace the swap `ops` directly without
needing a separate registration/lookup mechanism.
What are your thoughts on this approach?
Thanks,
Youngjun Park