Hi Jens, Christoph,
Here are some patches to switch from using the I/O direction indication in the
iov_iter struct to using the I/O direction flags to be found in the kiocb
struct, the iomap_iter struct and the request struct. The iterator's I/O
direction is then only used in some internal checks.
The patches also add direction flags into iov_iter_extract_pages() so that it
can perform some checks. New constants are defined rather than using READ and
WRITE so that a check can be made that one of them is specified. The problem
with the READ constant is that it is zero and is thus the same as no direction
being specified - but if we're modifying the buffer contents (ie. reading into
it), we need to know to set FOLL_WRITE. Granted this would be the default if
unspecified, but it seems better that this case should be explicit.
There are also patches to make 9P and SCSI use iov_iter_extract_pages().
I've pushed the patches here also:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=iov-extract
David
David Howells (11):
iov_iter: Fix comment refs to iov_iter_get_pages/pages_alloc()
vfs: Set IOCB_WRITE in iocbs that we're going to write from
vfs: Use init_kiocb() to initialise new IOCBs
iov_iter: Use IOCB_WRITE rather than iterator direction
iov_iter: Use IOMAP_WRITE rather than iterator direction
iov_iter: Use op_is_write() rather than iterator direction
cifs: Drop the check using iov_iter_rw()
iov_iter: Drop iov_iter_rw() and fold in last user
iov_iter: Use I/O dir flags with iov_iter_extract_pages()
9p: Pin pages rather than ref'ing if appropriate
scsi: Use extract_iter_to_sg()
block/bio.c | 6 ++
block/blk-map.c | 5 +-
block/fops.c | 8 +--
crypto/af_alg.c | 5 +-
crypto/algif_hash.c | 3 +-
drivers/block/loop.c | 11 ++--
drivers/nvme/target/io-cmd-file.c | 5 +-
drivers/target/target_core_file.c | 2 +-
drivers/vhost/scsi.c | 79 ++++++++------------------
fs/9p/vfs_addr.c | 2 +-
fs/affs/file.c | 4 +-
fs/aio.c | 9 ++-
fs/btrfs/ioctl.c | 4 +-
fs/cachefiles/io.c | 10 ++--
fs/ceph/file.c | 6 +-
fs/dax.c | 6 +-
fs/direct-io.c | 28 ++++++----
fs/exfat/inode.c | 6 +-
fs/ext2/inode.c | 2 +-
fs/f2fs/file.c | 10 ++--
fs/fat/inode.c | 4 +-
fs/fuse/dax.c | 2 +-
fs/fuse/file.c | 8 +--
fs/hfs/inode.c | 2 +-
fs/hfsplus/inode.c | 2 +-
fs/iomap/direct-io.c | 4 +-
fs/jfs/inode.c | 2 +-
fs/nfs/direct.c | 2 +-
fs/nilfs2/inode.c | 2 +-
fs/ntfs3/inode.c | 2 +-
fs/ocfs2/aops.c | 2 +-
fs/orangefs/inode.c | 2 +-
fs/read_write.c | 10 ++--
fs/reiserfs/inode.c | 2 +-
fs/seq_file.c | 2 +-
fs/smb/client/smbdirect.c | 9 ---
fs/splice.c | 2 +-
fs/udf/inode.c | 2 +-
include/linux/bio.h | 18 +++++-
include/linux/fs.h | 16 +++++-
include/linux/mm_types.h | 2 +-
include/linux/uio.h | 10 ++--
io_uring/rw.c | 10 ++--
lib/iov_iter.c | 14 ++++-
lib/scatterlist.c | 12 +++-
mm/filemap.c | 2 +-
mm/page_io.c | 4 +-
net/9p/trans_common.c | 8 +--
net/9p/trans_common.h | 2 +-
net/9p/trans_virtio.c | 92 ++++++++++---------------------
50 files changed, 221 insertions(+), 241 deletions(-)
Fix references to iov_iter_get_pages/pages_alloc() in comments to refer to
the *2 interfaces instead.
Signed-off-by: David Howells <[email protected]>
cc: Christoph Hellwig <[email protected]>
cc: Jens Axboe <[email protected]>
cc: Christian Brauner <[email protected]>
cc: Alexander Viro <[email protected]>
cc: [email protected]
cc: [email protected]
---
fs/ceph/file.c | 4 ++--
include/linux/mm_types.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index b1925232dc08..3bb27b9ce751 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -75,7 +75,7 @@ static __le32 ceph_flags_sys2wire(u32 flags)
*/
/*
- * How many pages to get in one call to iov_iter_get_pages(). This
+ * How many pages to get in one call to iov_iter_get_pages2(). This
* determines the size of the on-stack array used as a buffer.
*/
#define ITER_GET_BVECS_PAGES 64
@@ -115,7 +115,7 @@ static ssize_t __iter_get_bvecs(struct iov_iter *iter, size_t maxsize,
}
/*
- * iov_iter_get_pages() only considers one iov_iter segment, no matter
+ * iov_iter_get_pages2() only considers one iov_iter segment, no matter
* what maxsize or maxpages are given. For ITER_BVEC that is a single
* page.
*
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index de10fc797c8e..f49029c943b0 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -1249,7 +1249,7 @@ enum {
/*
* FOLL_LONGTERM indicates that the page will be held for an indefinite
* time period _often_ under userspace control. This is in contrast to
- * iov_iter_get_pages(), whose usages are transient.
+ * iov_iter_get_pages2(), whose usages are transient.
*/
FOLL_LONGTERM = 1 << 8,
/* split huge pmd before returning */