David Howells
a450f49708
iomap: Don't get an reference on ZERO_PAGE for direct I/O block zeroing
...
ZERO_PAGE can't go away, no need to hold an extra reference.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: David Hildenbrand <[email protected] >
Reviewed-by: John Hubbard <[email protected] >
Reviewed-by: Dave Chinner <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: [email protected]
Reviewed-by: Christian Brauner <[email protected] >
Reviewed-by: Jan Kara <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:44 -06:00
Jens Axboe
bbeb087e5a
Merge branch 'for-6.5/splice' into for-6.5/block
...
Merge splice bits as subsequent block cleanups and improvements for DIO
depend on them.
* for-6.5/splice: (31 commits)
splice: kdoc for filemap_splice_read() and copy_splice_read()
iov_iter: Kill ITER_PIPE
splice: Remove generic_file_splice_read()
splice: Use filemap_splice_read() instead of generic_file_splice_read()
cifs: Use filemap_splice_read()
trace: Convert trace/seq to use copy_splice_read()
zonefs: Provide a splice-read wrapper
xfs: Provide a splice-read wrapper
orangefs: Provide a splice-read wrapper
ocfs2: Provide a splice-read wrapper
ntfs3: Provide a splice-read wrapper
nfs: Provide a splice-read wrapper
f2fs: Provide a splice-read wrapper
ext4: Provide a splice-read wrapper
ecryptfs: Provide a splice-read wrapper
ceph: Provide a splice-read wrapper
afs: Provide a splice-read wrapper
9p: Add splice_read wrapper
net: Make sock_splice_read() use copy_splice_read() by default
tty, proc, kernfs, random: Use copy_splice_read()
...
2023-05-24 08:42:22 -06:00
David Howells
9eee8bd814
splice: kdoc for filemap_splice_read() and copy_splice_read()
...
Provide kerneldoc comments for filemap_splice_read() and
copy_splice_read().
Signed-off-by: David Howells <[email protected] >
cc: Christian Brauner <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Steve French <[email protected] >
cc: Al Viro <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:17 -06:00
David Howells
3fc40265ae
iov_iter: Kill ITER_PIPE
...
The ITER_PIPE-type iterator was only used by generic_file_splice_read() and
that has been replaced and removed. This leaves ITER_PIPE unused - so
remove it too.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: John Hubbard <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:17 -06:00
David Howells
c6585011bc
splice: Remove generic_file_splice_read()
...
Remove generic_file_splice_read() as it has been replaced with calls to
filemap_splice_read() and copy_splice_read().
With this, ITER_PIPE is no longer used.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Steve French <[email protected] >
cc: Al Viro <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: John Hubbard <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:17 -06:00
David Howells
2cb1e08985
splice: Use filemap_splice_read() instead of generic_file_splice_read()
...
Replace pointers to generic_file_splice_read() with calls to
filemap_splice_read().
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: John Hubbard <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:17 -06:00
David Howells
ab82513126
cifs: Use filemap_splice_read()
...
Make cifs use filemap_splice_read() rather than doing its own version of
generic_file_splice_read().
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Paulo Alcantara (SUSE) <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Steve French <[email protected] >
cc: Al Viro <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: John Hubbard <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
5bd4990f19
trace: Convert trace/seq to use copy_splice_read()
...
For the splice from the trace seq buffer, just use copy_splice_read().
In the future, something better can probably be done by gifting pages from
seq->buf into the pipe, but that would require changing seq->buf into a
vmap over an array of pages.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Steven Rostedt <[email protected] >
cc: Masami Hiramatsu <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
6ef48ec391
zonefs: Provide a splice-read wrapper
...
Provide a splice_read wrapper for zonefs. This does some checks before
proceeding and locks the inode across the call to filemap_splice_read() and
a size check in case of truncation. Splicing from direct I/O is handled by
the caller.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Darrick J. Wong <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Acked-by: Damien Le Moal <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
54919f94ec
xfs: Provide a splice-read wrapper
...
Provide a splice_read wrapper for XFS. This does a stat count and a
shutdown check before proceeding, then emits a new trace line and locks the
inode across the call to filemap_splice_read() and adds to the stats
afterwards. Splicing from direct I/O or DAX is handled by the caller.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Darrick J. Wong <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
6bbf64beab
orangefs: Provide a splice-read wrapper
...
Provide a splice_read wrapper for ocfs2. This increments the read stats
and then locks the inode across the call to filemap_splice_read() and a
revalidation of the mapping. Splicing from direct I/O is done by the
caller.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Mike Marshall <[email protected] >
cc: Martin Brandenburg <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
94aca682a4
ocfs2: Provide a splice-read wrapper
...
Provide a splice_read wrapper for ocfs2. This emits trace lines and does
an atime lock/update before calling filemap_splice_read(). Splicing from
direct I/O is handled by the caller.
A couple of new tracepoints are added for this purpose.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Joseph Qi <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Mark Fasheh <[email protected] >
cc: Joel Becker <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
5149439880
ntfs3: Provide a splice-read wrapper
...
Provide a splice_read wrapper for NTFS3 to perform various checks before
allowing the operation to proceed.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Konstantin Komarov <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
a7db503401
nfs: Provide a splice-read wrapper
...
Provide a splice_read wrapper for NFS. This locks the inode around
filemap_splice_read() and revalidates the mapping. Splicing from direct
I/O is handled by the caller.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Trond Myklebust <[email protected] >
cc: Anna Schumaker <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
ceb11d0e2d
f2fs: Provide a splice-read wrapper
...
Provide a splice_read wrapper for f2fs. This does some checks and tracing
before calling filemap_splice_read() and will update the iostats
afterwards. Direct I/O is handled by the caller.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Jaegeuk Kim <[email protected] >
cc: Chao Yu <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
fa6c46e7c2
ext4: Provide a splice-read wrapper
...
Provide a splice_read wrapper for Ext4. This does the inode shutdown check
before proceeding. Splicing from DAX files and O_DIRECT fds is handled by
the caller.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Acked-by: Theodore Ts'o <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Andreas Dilger <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
390df3b830
ecryptfs: Provide a splice-read wrapper
...
Provide a splice_read wrapper for ecryptfs to update the access time on the
lower file after the operation. Splicing from a direct I/O fd will update
the access time when ->read_iter() is called.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Tyler Hicks <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
ccfdf7cbb5
ceph: Provide a splice-read wrapper
...
Provide a splice_read wrapper for Ceph. This does the inode shutdown check
before proceeding and jumps to copy_splice_read() if the file has inline
data or is a synchronous file.
We try and get FILE_RD and either FILE_CACHE and/or FILE_LAZYIO caps and
hold them across filemap_splice_read(). If we fail to get FILE_CACHE or
FILE_LAZYIO capabilities, we use copy_splice_read() instead.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Xiubo Li <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Ilya Dryomov <[email protected] >
cc: Jeff Layton <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
d96d96eebb
afs: Provide a splice-read wrapper
...
Provide a splice_read wrapper for AFS to call afs_validate() before going
into generic_file_splice_read() so that we're likely to have a callback
promise from the server.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Marc Dionne <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
c829d0bd33
9p: Add splice_read wrapper
...
Add a splice_read wrapper for 9p. We should use copy_splice_read() if
9PL_DIRECT is set and filemap_splice_read() otherwise. Note that this
doesn't seem to be particularly related to O_DIRECT.
Signed-off-by: David Howells <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Dominique Martinet <[email protected] >
cc: Eric Van Hensbergen <[email protected] >
cc: Latchesar Ionkov <[email protected] >
cc: Christian Schoenebeck <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
67178fd066
net: Make sock_splice_read() use copy_splice_read() by default
...
Make sock_splice_read() use copy_splice_read() by default as
file_splice_read() will return immediately with 0 as a socket has no
pagecache and is a zero-size file.
Signed-off-by: David Howells <[email protected] >
cc: "David S. Miller" <[email protected] >
cc: Eric Dumazet <[email protected] >
cc: Jakub Kicinski <[email protected] >
cc: Paolo Abeni <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
b0072734ff
tty, proc, kernfs, random: Use copy_splice_read()
...
Use copy_splice_read() for tty, procfs, kernfs and random files rather
than going through generic_file_splice_read() as they just copy the file
into the output buffer and don't splice pages. This avoids the need for
them to have a ->read_folio() to satisfy filemap_splice_read().
Signed-off-by: David Howells <[email protected] >
Acked-by: Greg Kroah-Hartman <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: John Hubbard <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: Matthew Wilcox <[email protected] >
cc: Miklos Szeredi <[email protected] >
cc: Arnd Bergmann <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
a1be2935d0
coda: Implement splice-read
...
Implement splice-read for coda by passing the request down a layer rather
than going through generic_file_splice_read() which is going to be changed
to assume that ->read_folio() is present on buffered files.
Signed-off-by: David Howells <[email protected] >
Acked-by: Jan Harkes <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: John Hubbard <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: Matthew Wilcox <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
d4120d87a0
overlayfs: Implement splice-read
...
Implement splice-read for overlayfs by passing the request down a layer
rather than going through generic_file_splice_read() which is going to be
changed to assume that ->read_folio() is present on buffered files.
Signed-off-by: David Howells <[email protected] >
Acked-by: Christian Brauner <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: John Hubbard <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: Matthew Wilcox <[email protected] >
cc: Miklos Szeredi <[email protected] >
cc: Amir Goldstein <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
bd194b1871
shmem: Implement splice-read
...
The new filemap_splice_read() has an implicit expectation via
filemap_get_pages() that ->read_folio() exists if ->readahead() doesn't
fully populate the pagecache of the file it is reading from[1], potentially
leading to a jump to NULL if this doesn't exist. shmem, however, (and by
extension, tmpfs, ramfs and rootfs), doesn't have ->read_folio(),
Work around this by equipping shmem with its own splice-read
implementation, based on filemap_splice_read(), but able to paste in
zero_page when there's a page missing.
Signed-off-by: David Howells <[email protected] >
cc: Daniel Golle <[email protected] >
cc: Guenter Roeck <[email protected] >
cc: Christoph Hellwig <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: John Hubbard <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: Matthew Wilcox <[email protected] >
cc: Hugh Dickins <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected] / [1]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
b85930a077
splice: Make splice from a DAX file use copy_splice_read()
...
Make a read splice from a DAX file go directly to copy_splice_read() to do
the reading as filemap_splice_read() is unlikely to find any pagecache to
splice.
I think this affects only erofs, Ext2, Ext4, fuse and XFS.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
Reviewed-by: Theodore Ts'o <[email protected] >
Reviewed-by: Gao Xiang <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
aa3dbde878
splice: Make splice from an O_DIRECT fd use copy_splice_read()
...
Make a read splice from a file descriptor that's open O_DIRECT use
copy_splice_read() to do the reading as filemap_splice_read() is unlikely
to find any pagecache to splice.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Al Viro <[email protected] >
cc: Jens Axboe <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
123856f0e8
splice: Check for zero count in vfs_splice_read()
...
Make vfs_splice_read() return immediately if the length is 0.
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
6a3f30b8bd
splice: Make do_splice_to() generic and export it
...
Rename do_splice_to() to vfs_splice_read() and export it so that it can be
used as a helper when calling down to a lower layer filesystem as it
performs all the necessary checks[1].
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Miklos Szeredi <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: John Hubbard <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: Matthew Wilcox <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/CAJfpeguGksS3sCigmRi9hJdUec8qtM9f+_9jC1rJhsXT+dV01w@mail.gmail.com/ [1]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:16 -06:00
David Howells
e69f37bce1
splice: Clean up copy_splice_read() a bit
...
Do a couple of cleanups to copy_splice_read():
(1) Cast to struct page **, not void *.
(2) Simplify the calculation of the number of pages to keep/reclaim in
copy_splice_read().
Suggested-by: Christoph Hellwig <[email protected] >
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: John Hubbard <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:15 -06:00
David Howells
69df79a451
splice: Rename direct_splice_read() to copy_splice_read()
...
Rename direct_splice_read() to copy_splice_read() to better reflect as to
what it does.
Suggested-by: Christoph Hellwig <[email protected] >
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Steve French <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:15 -06:00
David Howells
83aeff881e
splice: Make filemap_splice_read() check s_maxbytes
...
Make filemap_splice_read() check s_maxbytes analogously to filemap_read().
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Steve French <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: John Hubbard <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:15 -06:00
David Howells
c37222082f
splice: Fix filemap_splice_read() to use the correct inode
...
Fix filemap_splice_read() to use file->f_mapping->host, not file->f_inode,
as the source of the file size because in the case of a block device,
file->f_inode points to the block-special file (which is typically 0
length) and not the backing store.
Fixes: 07073eb01c ("splice: Add a func to do a splice from a buffered file without ITER_PIPE")
Signed-off-by: David Howells <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Christian Brauner <[email protected] >
cc: Steve French <[email protected] >
cc: Jens Axboe <[email protected] >
cc: Al Viro <[email protected] >
cc: David Hildenbrand <[email protected] >
cc: John Hubbard <[email protected] >
cc: [email protected]
cc: [email protected]
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:42:15 -06:00
Hengqi Chen
5a80bd075f
block: introduce block_io_start/block_io_done tracepoints
...
Currently, several BCC ([0]) tools (biosnoop/biostacks/biotop) use
kprobes to blk_account_io_start/blk_account_io_done to implement
their functionalities. This is fragile because the target kernel
functions may be renamed ([1]) or inlined ([2]). So introduce two
new tracepoints for such use cases.
[0]: https://github.com/iovisor/bcc
[1]: https://github.com/iovisor/bcc/issues/3954
[2]: https://github.com/iovisor/bcc/issues/4261
Tested-by: Francis Laniel <[email protected] >
Signed-off-by: Hengqi Chen <[email protected] >
Tested-by: Yonghong Song <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-24 08:38:59 -06:00
Yu Kuai
a13bd91be2
block/rq_qos: protect rq_qos apis with a new lock
...
commit 50e34d7881 ("block: disable the elevator int del_gendisk")
move rq_qos_exit() from disk_release() to del_gendisk(), this will
introduce some problems:
1) If rq_qos_add() is triggered by enabling iocost/iolatency through
cgroupfs, then it can concurrent with del_gendisk(), it's not safe to
write 'q->rq_qos' concurrently.
2) Activate cgroup policy that is relied on rq_qos will call
rq_qos_add() and blkcg_activate_policy(), and if rq_qos_exit() is
called in the middle, null-ptr-dereference will be triggered in
blkcg_activate_policy().
3) blkg_conf_open_bdev() can call blkdev_get_no_open() first to find the
disk, then if rq_qos_exit() from del_gendisk() is done before
rq_qos_add(), then memory will be leaked.
This patch add a new disk level mutex 'rq_qos_mutex':
1) The lock will protect rq_qos_exit() directly.
2) For wbt that doesn't relied on blk-cgroup, rq_qos_add() can only be
called from disk initialization for now because wbt can't be
destructed until rq_qos_exit(), so it's safe not to protect wbt for
now. Hoever, in case that rq_qos dynamically destruction is supported
in the furture, this patch also protect rq_qos_add() from wbt_init()
directly, this is enough because blk-sysfs already synchronize
writers with disk removal.
3) For iocost and iolatency, in order to synchronize disk removal and
cgroup configuration, the lock is held after blkdev_get_no_open()
from blkg_conf_open_bdev(), and is released in blkg_conf_exit().
In order to fix the above memory leak, disk_live() is checked after
holding the new lock.
Fixes: 50e34d7881 ("block: disable the elevator int del_gendisk")
Signed-off-by: Yu Kuai <[email protected] >
Acked-by: Tejun Heo <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-23 11:13:19 -06:00
Li Nan
712fd23a90
block: remove redundant req_op in blk_rq_is_passthrough
...
op &= REQ_OP_MASK in blk_op_is_passthrough() is exactly what req_op() do.
Therefore, it is redundant to call req_op() for blk_op_is_passthrough().
Signed-off-by: Li Nan <[email protected] >
Reviewed-by: Christoph Hellwig <[email protected] >
Reviewed-by: Chaitanya Kulkarni <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-23 11:09:26 -06:00
Ming Lei
b8b637d770
ublk: fix build warning on iov_iter_get_pages2
...
Return type of iov_iter_get_pages2() is ssize_t instead of size_t, so
fix it.
Fixes: 981f95a571 ("ublk: cleanup ublk_copy_user_pages")
Reported-by: kernel test robot <[email protected] >
Reported-by: Julia Lawall <[email protected] >
Signed-off-by: Ming Lei <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-20 20:18:32 -06:00
Christoph Hellwig
712c736465
block: don't plug in blkdev_write_iter
...
For direct I/O writes that issues more than a single bio, the plugging
is already done in __blkdev_direct_IO.
For synchronous buffered writes the plugging is done deep down in
writeback_inodes_wb / wb_writeback.
For the other cases there is no point in plugging as as single bio or no
bio at all is submitted.
Signed-off-by: Christoph Hellwig <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-20 05:42:41 -06:00
Bart Van Assche
f80dd11dd1
block: BFQ: Move an invariant check
...
Check bfqq->dispatched for each BFQ queue instead of checking it for an
invalid bfqq pointer.
Fixes: 3e49c1e4a6 ("block: BFQ: Add several invariant checks")
Signed-off-by: Bart Van Assche <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:59:52 -06:00
Ming Lei
1172d5b8be
ublk: support user copy
...
Currently copy between io request buffer(pages) and userspace buffer is
done inside ublk_map_io() or ublk_unmap_io(). This way performs very
well in case of pre-allocated userspace io buffer.
For dynamically allocated or external userspace backend io buffer,
UBLK_F_NEED_GET_DATA is added for ublk server to provide buffer by one
extra command communication for WRITE request. For READ, userspace
simply provides buffer, but can't know when the buffer is done[1].
Add UBLK_F_USER_COPY by moving io data copy out of kernel by providing
read()/write() on /dev/ublkcN, and simply let ublk server do the io
data copy. This way makes both side cleaner, the cost is that one extra
syscall for copy io data between request and backend buffer.
With UBLK_F_USER_COPY, it actually becomes possible to run per-io zero
copy now, such as, only do zero copy for big size IO, so it can be
thought as one prep patch for supporting zero copy. Meantime zero copy
still needs to expose read()/write() buffer for some corner case, such
as passthrough IO.
[1] READ buffer in UBLK_F_NEED_GET_DATA
https://lore.kernel.org/linux-block/[email protected] /T/#m23bd4b8634c0a054e6797063167b469949a247bb
ublksrv loop usercopy code:
https://github.com/ming1/ubdsrv/commits/usercopy
Signed-off-by: Ming Lei <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:59:17 -06:00
Ming Lei
62fe99cef9
ublk: add read()/write() support for ublk char device
...
Support pread()/pwrite() on ublk char device for reading/writing request
io buffer, so data copy between io request buffer and userspace buffer
can be moved to ublk server from ublk driver. Then UBLK_F_NEED_GET_DATA
becomes not necessary, so ublk server can allocate buffer without one
extra round uring command communication for userspace to provide buffer.
IO buffer can be located by iocb->ki_pos which encodes buffer offset, io
tag and queue id info, and type of iocb->ki_pos is u64, so it is big
enough for holding reasonable queue depth, nr_queues and max io buffer
size.
Signed-off-by: Ming Lei <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:59:17 -06:00
Ming Lei
38f2dd3441
ublk: support to copy any part of request pages
...
Add 'offset' to 'struct ublk_map_data', so that ublk_copy_user_pages()
can be used to copy any sub-buffer(linear mapped) of the request.
Signed-off-by: Ming Lei <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:59:17 -06:00
Ming Lei
8284066946
ublk: grab request reference when the request is handled by userspace
...
Add one reference counter into request pdu data, and hold this reference
in the request's lifetime.
Prepare for supporting to move request data copy into userspace, which
needs to copy request data by read()/write() on /dev/ublkcN, so we have
to guarantee that read()/write() is done on one valid/active request,
and that will be enhanced by holding the io request reference in
read()/write().
Signed-off-by: Ming Lei <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:59:17 -06:00
Ming Lei
981f95a571
ublk: cleanup ublk_copy_user_pages
...
Clean up ublk_copy_user_pages() by using iov_iter_get_pages2, and code
gets simplified a lot and becomes much more readable than before.
Signed-off-by: Ming Lei <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:59:17 -06:00
Ming Lei
f236a21459
ublk: cleanup io cmd code path by adding ublk_fill_io_cmd()
...
Add one small helper to cleanup io command hanlding code path.
Signed-off-by: Ming Lei <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:59:17 -06:00
Ming Lei
29dc5d0661
ublk: kill queuing request by task_work_add
...
task_work_add() is used from early ublk development stage for handling
request in batch. However, since commit 7d4a93176e ("ublk_drv: don't
forward io commands in reserve order"), we can get similar batch
processing with io_uring_cmd_complete_in_task(), and similar performance
data is observed between task_work_add() and
io_uring_cmd_complete_in_task().
Meantime we can kill one fast code path, which is actually seldom used
given it is common to build ublk driver as module.
Signed-off-by: Ming Lei <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:59:16 -06:00
Christoph Hellwig
9a67aa52a4
blk-mq: don't use the requeue list to queue flush commands
...
Currently both requeues of commands that were already sent to the driver
and flush commands submitted from the flush state machine share the same
requeue_list struct request_queue, despite requeues doing head
insertions and flushes not. Switch to using two separate lists instead.
Signed-off-by: Christoph Hellwig <[email protected] >
Reviewed-by: Damien Le Moal <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:52:42 -06:00
Christoph Hellwig
1e82fadfc6
blk-mq: do not do head insertions post-pre-flush commands
...
blk_flush_complete_seq currently queues requests that write data after
a pre-flush from the flush state machine at the head of the queue.
This doesn't really make sense, as the original request bypassed all
queue lists by directly diverting to blk_insert_flush from
blk_mq_submit_bio.
Signed-off-by: Christoph Hellwig <[email protected] >
Reviewed-by: Bart Van Assche <[email protected] >
Reviewed-by: Damien Le Moal <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:52:29 -06:00
Christoph Hellwig
615939a2ae
blk-mq: defer to the normal submission path for post-flush requests
...
Requests with the FUA bit on hardware without FUA support need a post
flush before returning to the caller, but they can still be sent using
the normal I/O path after initializing the flush-related fields and
end I/O handler.
Signed-off-by: Christoph Hellwig <[email protected] >
Reviewed-by: Bart Van Assche <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:52:29 -06:00
Bart Van Assche
be4c427809
blk-mq: use the I/O scheduler for writes from the flush state machine
...
Send write requests issued by the flush state machine through the normal
I/O submission path including the I/O scheduler (if present) so that I/O
scheduler policies are applied to writes with the FUA flag set.
Separate the I/O scheduler members from the flush members in struct
request since now a request may pass through both an I/O scheduler
and the flush machinery.
Note that the actual flush requests, which have no bio attached to the
request still bypass the I/O schedulers.
Signed-off-by: Bart Van Assche <[email protected] >
[hch: rebased]
Signed-off-by: Christoph Hellwig <[email protected] >
Reviewed-by: Damien Le Moal <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected] >
2023-05-19 19:52:29 -06:00