On Thu, 16 Dec 2021 at 23:56, NeilBrown <neilb@xxxxxxx> wrote: > > swap_writepage() is given one page at a time, but may be called repeatedly > in succession. > For block-device swapspace, the blk_plug functionality allows the > multiple pages to be combined together at lower layers. > That cannot be used for SWP_FS_OPS as blk_plug may not exist - it is > only active when CONFIG_BLOCK=y. Consequently all swap reads over NFS > are single page reads. > > With this patch we pass a pointer-to-pointer via the wbc. > swap_writepage can store state between calls - much like the pointer > passed explicitly to swap_readpage. After calling swap_writepage() some > number of times, the state will be passed to swap_write_unplug() which > can submit the combined request. > > Signed-off-by: NeilBrown <neilb@xxxxxxx> > --- > include/linux/writeback.h | 7 +++ > mm/page_io.c | 98 ++++++++++++++++++++++++++++++--------------- > mm/swap.h | 1 > mm/vmscan.c | 9 +++- > 4 files changed, 80 insertions(+), 35 deletions(-) ... > +void swap_write_unplug(struct swap_iocb *sio) > +{ > + struct iov_iter from; > + struct address_space *mapping = sio->iocb.ki_filp->f_mapping; > + int ret; > + > + iov_iter_bvec(&from, WRITE, sio->bvec, sio->pages, > + PAGE_SIZE * sio->pages); > + ret = mapping->a_ops->swap_rw(&sio->iocb, &from); > + if (ret != -EIOCBQUEUED) > + sio_write_complete(&sio->iocb, ret); > +} > + As swap_write_unplug() is called from vmscan.c, need an 'no-op' version (in "swap.h") for when !CONFIG_SWAP Mark