Merge branch 'iov-extract' of https://git.kernel.org/pub/scm/linux/kernel/git/dhowell...
authorJens Axboe <axboe@kernel.dk>
Tue, 14 Feb 2023 23:03:03 +0000 (16:03 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 14 Feb 2023 23:03:03 +0000 (16:03 -0700)
commit651d77d89c16b6b8deb487ff66dc894cd99ba888
treed4820287369d8eb0cfdca284df12aba93599e915
parenta06377c5d01eeeaa52ad979b62c3c72efcc3eff0
parent07a646708a57a42b395bd2874862e613cec86fc0
Merge branch 'iov-extract' of https://git./linux/kernel/git/dhowells/linux-fs into for-6.3/iov-extract

Pull iov-extract from David:

"Here are patches to provide support for extracting pages from an iov_iter
 and to use this in the extraction functions in the block layer bio code.

 The patches make the following changes:

 (1) Change generic_file_splice_read() to no longer use ITER_PIPE for doing
     a read from an O_DIRECT file fd, but rather load up an ITER_BVEC
     iterator with sufficient pages and use that rather than using an
     ITER_PIPE.  This avoids a problem[2] when __iomap_dio_rw() calls
     iov_iter_revert() to shorten an iterator when it races with
     truncation.  The reversion causes the pipe iterator to prematurely
     release the pages it was retaining - despite the read still being in
     progress.  This caused memory corruption.

 (2) Change generic_file_splice_read() to no longer use ITER_PIPE for doing
     a read from a buffered file fd, but rather get pages directly from the
     pagecache using filemap_get_pages() do all the readahead, reading,
     waiting and extraction, and then feed the pages directly into the
     pipe.

 (3) filemap_get_pages() is altered so that it doesn't take an iterator
     (which we don't have in (2)), but rather the count and a flag
     indicating if we can handle partially uptodate pages are passed in and
     down to its subsidiary functions.

 (4) Remove ITER_PIPE and its paraphernalia as generic_file_splice_read()
     was the only user.

 (5) Add a function, iov_iter_extract_pages() to replace
     iov_iter_get_pages*() that gets refs, pins or just lists the pages as
     appropriate to the iterator type.

     Add a function, iov_iter_extract_will_pin() that will indicate from
     the iterator type how the cleanup is to be performed, returning true
     if the pages will need unpinning, false otherwise.

 (6) Make the bio struct carry a pair of flags to indicate the cleanup
     mode.  BIO_NO_PAGE_REF is replaced with BIO_PAGE_REFFED (indicating
     FOLL_GET was used) and BIO_PAGE_PINNED (indicating FOLL_PIN was used)
     is added.

     BIO_PAGE_REFFED will go away, but at the moment fs/direct-io.c sets it
     and this series does not fully address that file.

 (7) Add a function, bio_release_page(), to release a page appropriately to
     the cleanup mode indicated by the BIO_PAGE_* flags.

 (8) Make the iter-to-bio code use iov_iter_extract_pages() to retain the
     pages appropriately and clean them up later.

 (9) Fix bio_flagged() so that it doesn't prevent a gcc optimisation."

* 'iov-extract' of https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: (299 commits)
  block: convert bio_map_user_iov to use iov_iter_extract_pages
  block: Convert bio_iov_iter_get_pages to use iov_iter_extract_pages
  block: Add BIO_PAGE_PINNED and associated infrastructure
  block: Replace BIO_NO_PAGE_REF with BIO_PAGE_REFFED with inverted logic
  block: Fix bio_flagged() so that gcc can better optimise it
  iomap: Don't get an reference on ZERO_PAGE for direct I/O block zeroing
  iov_iter: Add a function to extract a page list from an iterator
  iov_iter: Define flags to qualify page extraction.
  iov_iter: Kill ITER_PIPE
  splice: Do splice read from a file without using ITER_PIPE
  tty, proc, kernfs, random: Use direct_splice_read()
  coda: Implement splice-read
  overlayfs: Implement splice-read
  shmem: Implement splice-read
  splice: Add a func to do a splice from an O_DIRECT file without ITER_PIPE
  splice: Add a func to do a splice from a buffered file without ITER_PIPE
  mm: Pass info, not iter, into filemap_get_pages()
  Linux 6.2-rc7
  fbcon: Check font dimension limits
  efi: fix potential NULL deref in efi_mem_reserve_persistent
  ...

Signed-off-by: Jens Axboe <axboe@kernel.dk>
12 files changed:
MAINTAINERS
block/bfq-iosched.c
block/bio.c
block/blk-cgroup.c
block/blk-map.c
block/blk-mq.c
drivers/block/ublk_drv.c
drivers/nvme/host/auth.c
drivers/nvme/host/core.c
fs/ceph/file.c
fs/splice.c
mm/swapfile.c