* [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read()
[not found] <20230520000049.2226926-1-dhowells@redhat.com>
@ 2023-05-20 0:00 ` David Howells
2023-05-20 4:09 ` Christoph Hellwig
2023-05-20 9:23 ` Christian Brauner
2023-05-20 0:00 ` [PATCH v21 27/30] cifs: Use filemap_splice_read() David Howells
2023-05-20 0:00 ` [PATCH v21 29/30] splice: Remove generic_file_splice_read() David Howells
2 siblings, 2 replies; 10+ messages in thread
From: David Howells @ 2023-05-20 0:00 UTC (permalink / raw)
To: Jens Axboe, Al Viro, Christoph Hellwig
Cc: David Howells, Matthew Wilcox, Jan Kara, Jeff Layton,
David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe, Hillf Danton,
Christian Brauner, Linus Torvalds, linux-fsdevel, linux-block,
linux-kernel, linux-mm, Christoph Hellwig, Steve French,
linux-cifs
Rename direct_splice_read() to copy_splice_read() to better reflect as to
what it does.
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Steve French <sfrench@samba.org>
cc: Jens Axboe <axboe@kernel.dk>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: linux-cifs@vger.kernel.org
cc: linux-mm@kvack.org
cc: linux-block@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
fs/cifs/cifsfs.c | 4 ++--
fs/cifs/file.c | 2 +-
fs/splice.c | 11 +++++------
include/linux/fs.h | 6 +++---
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 43a4d8603db3..fa2477bbcc86 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -1416,7 +1416,7 @@ const struct file_operations cifs_file_direct_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
- .splice_read = direct_splice_read,
+ .splice_read = copy_splice_read,
.splice_write = iter_file_splice_write,
.unlocked_ioctl = cifs_ioctl,
.copy_file_range = cifs_copy_file_range,
@@ -1470,7 +1470,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
- .splice_read = direct_splice_read,
+ .splice_read = copy_splice_read,
.splice_write = iter_file_splice_write,
.unlocked_ioctl = cifs_ioctl,
.copy_file_range = cifs_copy_file_range,
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index c5fcefdfd797..023496207c18 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -5091,6 +5091,6 @@ ssize_t cifs_splice_read(struct file *in, loff_t *ppos,
if (unlikely(!len))
return 0;
if (in->f_flags & O_DIRECT)
- return direct_splice_read(in, ppos, pipe, len, flags);
+ return copy_splice_read(in, ppos, pipe, len, flags);
return filemap_splice_read(in, ppos, pipe, len, flags);
}
diff --git a/fs/splice.c b/fs/splice.c
index 3e06611d19ae..2478e065bc53 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -300,12 +300,11 @@ void splice_shrink_spd(struct splice_pipe_desc *spd)
}
/*
- * Splice data from an O_DIRECT file into pages and then add them to the output
- * pipe.
+ * Copy data from a file into pages and then splice those into the output pipe.
*/
-ssize_t direct_splice_read(struct file *in, loff_t *ppos,
- struct pipe_inode_info *pipe,
- size_t len, unsigned int flags)
+ssize_t copy_splice_read(struct file *in, loff_t *ppos,
+ struct pipe_inode_info *pipe,
+ size_t len, unsigned int flags)
{
struct iov_iter to;
struct bio_vec *bv;
@@ -390,7 +389,7 @@ ssize_t direct_splice_read(struct file *in, loff_t *ppos,
kfree(bv);
return ret;
}
-EXPORT_SYMBOL(direct_splice_read);
+EXPORT_SYMBOL(copy_splice_read);
/**
* generic_file_splice_read - splice data from file to a pipe
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 21a981680856..e3c22efa413e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2752,9 +2752,9 @@ ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb,
ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags);
-ssize_t direct_splice_read(struct file *in, loff_t *ppos,
- struct pipe_inode_info *pipe,
- size_t len, unsigned int flags);
+ssize_t copy_splice_read(struct file *in, loff_t *ppos,
+ struct pipe_inode_info *pipe,
+ size_t len, unsigned int flags);
extern ssize_t generic_file_splice_read(struct file *, loff_t *,
struct pipe_inode_info *, size_t, unsigned int);
extern ssize_t iter_file_splice_write(struct pipe_inode_info *,
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read()
2023-05-20 0:00 ` [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read() David Howells
@ 2023-05-20 4:09 ` Christoph Hellwig
2023-05-20 9:23 ` Christian Brauner
1 sibling, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2023-05-20 4:09 UTC (permalink / raw)
To: David Howells
Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
Hillf Danton, Christian Brauner, Linus Torvalds, linux-fsdevel,
linux-block, linux-kernel, linux-mm, Christoph Hellwig,
Steve French, linux-cifs
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read()
2023-05-20 0:00 ` [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read() David Howells
2023-05-20 4:09 ` Christoph Hellwig
@ 2023-05-20 9:23 ` Christian Brauner
2023-05-20 9:51 ` David Howells
2023-05-22 7:55 ` David Howells
1 sibling, 2 replies; 10+ messages in thread
From: Christian Brauner @ 2023-05-20 9:23 UTC (permalink / raw)
To: David Howells
Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
Hillf Danton, Linus Torvalds, linux-fsdevel, linux-block,
linux-kernel, linux-mm, Christoph Hellwig, Steve French,
linux-cifs
On Sat, May 20, 2023 at 01:00:22AM +0100, David Howells wrote:
> Rename direct_splice_read() to copy_splice_read() to better reflect as to
> what it does.
>
> Suggested-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Christoph Hellwig <hch@lst.de>
> cc: Steve French <sfrench@samba.org>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: linux-cifs@vger.kernel.org
> cc: linux-mm@kvack.org
> cc: linux-block@vger.kernel.org
> cc: linux-fsdevel@vger.kernel.org
> ---
For the future it'd be nice if exported functions would always get
proper kernel doc,
Reviewed-by: Christian Brauner <brauner@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read()
2023-05-20 9:23 ` Christian Brauner
@ 2023-05-20 9:51 ` David Howells
2023-05-22 7:55 ` David Howells
1 sibling, 0 replies; 10+ messages in thread
From: David Howells @ 2023-05-20 9:51 UTC (permalink / raw)
To: Christian Brauner
Cc: dhowells, Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox,
Jan Kara, Jeff Layton, David Hildenbrand, Jason Gunthorpe,
Logan Gunthorpe, Hillf Danton, Linus Torvalds, linux-fsdevel,
linux-block, linux-kernel, linux-mm, Christoph Hellwig,
Steve French, linux-cifs
Christian Brauner <brauner@kernel.org> wrote:
> For the future it'd be nice if exported functions would always get
> proper kernel doc,
Good point. It wasn't meant to remain exported originally. I'll add a patch
to add that.
David
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read()
2023-05-20 9:23 ` Christian Brauner
2023-05-20 9:51 ` David Howells
@ 2023-05-22 7:55 ` David Howells
2023-05-22 12:53 ` Christian Brauner
1 sibling, 1 reply; 10+ messages in thread
From: David Howells @ 2023-05-22 7:55 UTC (permalink / raw)
To: Christian Brauner
Cc: dhowells, Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox,
Jan Kara, Jeff Layton, David Hildenbrand, Jason Gunthorpe,
Logan Gunthorpe, Hillf Danton, Linus Torvalds, linux-fsdevel,
linux-block, linux-kernel, linux-mm, Christoph Hellwig,
Steve French, linux-cifs
> For the future it'd be nice if exported functions would always get
> proper kernel doc,
Something like the attached?
David
---
commit 0362042ba0751fc5457b0548fb9006f9d7dfbeca
Author: David Howells <dhowells@redhat.com>
Date: Mon May 22 08:34:24 2023 +0100
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 <dhowells@redhat.com>
cc: Christian Brauner <brauner@kernel.org>
cc: Christoph Hellwig <hch@lst.de>
cc: Jens Axboe <axboe@kernel.dk>
cc: Steve French <smfrench@gmail.com>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: linux-mm@kvack.org
cc: linux-block@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
diff --git a/fs/splice.c b/fs/splice.c
index 9be4cb3b9879..5292a8fa929d 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -299,8 +299,25 @@ void splice_shrink_spd(struct splice_pipe_desc *spd)
kfree(spd->partial);
}
-/*
- * Copy data from a file into pages and then splice those into the output pipe.
+/**
+ * copy_splice_read - Copy data from a file and splice the copy into a pipe
+ * @in: The file to read from
+ * @ppos: Pointer to the file position to read from
+ * @pipe: The pipe to splice into
+ * @len: The amount to splice
+ * @flags: The SPLICE_F_* flags
+ *
+ * This function allocates a bunch of pages sufficient to hold the requested
+ * amount of data (but limited by the remaining pipe capacity), passes it to
+ * the file's ->read_iter() to read into and then splices the used pages into
+ * the pipe.
+ *
+ * On success, the number of bytes read will be returned and *@ppos will be
+ * updated if appropriate; 0 will be returned if there is no more data to be
+ * read; -EAGAIN will be returned if the pipe had no space, and some other
+ * negative error code will be returned on error. A short read may occur if
+ * the pipe has insufficient space, we reach the end of the data or we hit a
+ * hole.
*/
ssize_t copy_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
diff --git a/mm/filemap.c b/mm/filemap.c
index 603b562d69b1..1f235a6430fd 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2871,9 +2871,24 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
return spliced;
}
-/*
- * Splice folios from the pagecache of a buffered (ie. non-O_DIRECT) file into
- * a pipe.
+/**
+ * filemap_splice_read - Splice data from a file's pagecache into a pipe
+ * @in: The file to read from
+ * @ppos: Pointer to the file position to read from
+ * @pipe: The pipe to splice into
+ * @len: The amount to splice
+ * @flags: The SPLICE_F_* flags
+ *
+ * This function gets folios from a file's pagecache and splices them into the
+ * pipe. Readahead will be called as necessary to fill more folios. This may
+ * be used for blockdevs also.
+ *
+ * On success, the number of bytes read will be returned and *@ppos will be
+ * updated if appropriate; 0 will be returned if there is no more data to be
+ * read; -EAGAIN will be returned if the pipe had no space, and some other
+ * negative error code will be returned on error. A short read may occur if
+ * the pipe has insufficient space, we reach the end of the data or we hit a
+ * hole.
*/
ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read()
2023-05-22 7:55 ` David Howells
@ 2023-05-22 12:53 ` Christian Brauner
0 siblings, 0 replies; 10+ messages in thread
From: Christian Brauner @ 2023-05-22 12:53 UTC (permalink / raw)
To: David Howells
Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
Hillf Danton, Linus Torvalds, linux-fsdevel, linux-block,
linux-kernel, linux-mm, Christoph Hellwig, Steve French,
linux-cifs
On Mon, May 22, 2023 at 08:55:14AM +0100, David Howells wrote:
> > For the future it'd be nice if exported functions would always get
> > proper kernel doc,
>
> Something like the attached?
>
> David
> ---
> commit 0362042ba0751fc5457b0548fb9006f9d7dfbeca
> Author: David Howells <dhowells@redhat.com>
> Date: Mon May 22 08:34:24 2023 +0100
>
> 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 <dhowells@redhat.com>
> cc: Christian Brauner <brauner@kernel.org>
> cc: Christoph Hellwig <hch@lst.de>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: Steve French <smfrench@gmail.com>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: linux-mm@kvack.org
> cc: linux-block@vger.kernel.org
> cc: linux-cifs@vger.kernel.org
> cc: linux-fsdevel@vger.kernel.org
>
> diff --git a/fs/splice.c b/fs/splice.c
> index 9be4cb3b9879..5292a8fa929d 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -299,8 +299,25 @@ void splice_shrink_spd(struct splice_pipe_desc *spd)
> kfree(spd->partial);
> }
>
> -/*
> - * Copy data from a file into pages and then splice those into the output pipe.
> +/**
> + * copy_splice_read - Copy data from a file and splice the copy into a pipe
> + * @in: The file to read from
> + * @ppos: Pointer to the file position to read from
> + * @pipe: The pipe to splice into
> + * @len: The amount to splice
> + * @flags: The SPLICE_F_* flags
> + *
> + * This function allocates a bunch of pages sufficient to hold the requested
> + * amount of data (but limited by the remaining pipe capacity), passes it to
> + * the file's ->read_iter() to read into and then splices the used pages into
> + * the pipe.
> + *
> + * On success, the number of bytes read will be returned and *@ppos will be
> + * updated if appropriate; 0 will be returned if there is no more data to be
> + * read; -EAGAIN will be returned if the pipe had no space, and some other
> + * negative error code will be returned on error. A short read may occur if
> + * the pipe has insufficient space, we reach the end of the data or we hit a
> + * hole.
> */
I think kdoc expects:
* Return: On success, the number of bytes read will be returned and *@ppos will be
* updated if appropriate; 0 will be returned if there is no more data to be
* read; -EAGAIN will be returned if the pipe had no space, and some other
* negative error code will be returned on error. A short read may occur if
* the pipe has insufficient space, we reach the end of the data or we hit a
* hole.
and similar for filemap_splice_read() other than that this looks good!
> ssize_t copy_splice_read(struct file *in, loff_t *ppos,
> struct pipe_inode_info *pipe,
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 603b562d69b1..1f235a6430fd 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -2871,9 +2871,24 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
> return spliced;
> }
>
> -/*
> - * Splice folios from the pagecache of a buffered (ie. non-O_DIRECT) file into
> - * a pipe.
> +/**
> + * filemap_splice_read - Splice data from a file's pagecache into a pipe
> + * @in: The file to read from
> + * @ppos: Pointer to the file position to read from
> + * @pipe: The pipe to splice into
> + * @len: The amount to splice
> + * @flags: The SPLICE_F_* flags
> + *
> + * This function gets folios from a file's pagecache and splices them into the
> + * pipe. Readahead will be called as necessary to fill more folios. This may
> + * be used for blockdevs also.
> + *
> + * On success, the number of bytes read will be returned and *@ppos will be
> + * updated if appropriate; 0 will be returned if there is no more data to be
> + * read; -EAGAIN will be returned if the pipe had no space, and some other
> + * negative error code will be returned on error. A short read may occur if
> + * the pipe has insufficient space, we reach the end of the data or we hit a
> + * hole.
> */
> ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
> struct pipe_inode_info *pipe,
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v21 27/30] cifs: Use filemap_splice_read()
[not found] <20230520000049.2226926-1-dhowells@redhat.com>
2023-05-20 0:00 ` [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read() David Howells
@ 2023-05-20 0:00 ` David Howells
2023-05-20 0:00 ` [PATCH v21 29/30] splice: Remove generic_file_splice_read() David Howells
2 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2023-05-20 0:00 UTC (permalink / raw)
To: Jens Axboe, Al Viro, Christoph Hellwig
Cc: David Howells, Matthew Wilcox, Jan Kara, Jeff Layton,
David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe, Hillf Danton,
Christian Brauner, Linus Torvalds, linux-fsdevel, linux-block,
linux-kernel, linux-mm, Christoph Hellwig, Paulo Alcantara,
Steve French, John Hubbard, linux-cifs
Make cifs use filemap_splice_read() rather than doing its own version of
generic_file_splice_read().
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Steve French <smfrench@gmail.com>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: David Hildenbrand <david@redhat.com>
cc: John Hubbard <jhubbard@nvidia.com>
cc: linux-mm@kvack.org
cc: linux-block@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
Notes:
ver #21)
- Switch to filemap_splice_read() rather than generic_file_splice_read().
ver #20)
- Don't remove the export of filemap_splice_read().
ver #18)
- Split out from change to generic_file_splice_read().
fs/cifs/cifsfs.c | 8 ++++----
fs/cifs/cifsfs.h | 3 ---
fs/cifs/file.c | 16 ----------------
3 files changed, 4 insertions(+), 23 deletions(-)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index fa2477bbcc86..4f4492eb975f 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -1376,7 +1376,7 @@ const struct file_operations cifs_file_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
- .splice_read = cifs_splice_read,
+ .splice_read = filemap_splice_read,
.splice_write = iter_file_splice_write,
.llseek = cifs_llseek,
.unlocked_ioctl = cifs_ioctl,
@@ -1396,7 +1396,7 @@ const struct file_operations cifs_file_strict_ops = {
.fsync = cifs_strict_fsync,
.flush = cifs_flush,
.mmap = cifs_file_strict_mmap,
- .splice_read = cifs_splice_read,
+ .splice_read = filemap_splice_read,
.splice_write = iter_file_splice_write,
.llseek = cifs_llseek,
.unlocked_ioctl = cifs_ioctl,
@@ -1434,7 +1434,7 @@ const struct file_operations cifs_file_nobrl_ops = {
.fsync = cifs_fsync,
.flush = cifs_flush,
.mmap = cifs_file_mmap,
- .splice_read = cifs_splice_read,
+ .splice_read = filemap_splice_read,
.splice_write = iter_file_splice_write,
.llseek = cifs_llseek,
.unlocked_ioctl = cifs_ioctl,
@@ -1452,7 +1452,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = {
.fsync = cifs_strict_fsync,
.flush = cifs_flush,
.mmap = cifs_file_strict_mmap,
- .splice_read = cifs_splice_read,
+ .splice_read = filemap_splice_read,
.splice_write = iter_file_splice_write,
.llseek = cifs_llseek,
.unlocked_ioctl = cifs_ioctl,
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 74cd6fafb33e..d7274eefc666 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -100,9 +100,6 @@ extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
extern ssize_t cifs_user_writev(struct kiocb *iocb, struct iov_iter *from);
extern ssize_t cifs_direct_writev(struct kiocb *iocb, struct iov_iter *from);
extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
-extern ssize_t cifs_splice_read(struct file *in, loff_t *ppos,
- struct pipe_inode_info *pipe, size_t len,
- unsigned int flags);
extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock);
extern int cifs_lock(struct file *, int, struct file_lock *);
extern int cifs_fsync(struct file *, loff_t, loff_t, int);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 023496207c18..375a8037a3f3 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -5078,19 +5078,3 @@ const struct address_space_operations cifs_addr_ops_smallbuf = {
.launder_folio = cifs_launder_folio,
.migrate_folio = filemap_migrate_folio,
};
-
-/*
- * Splice data from a file into a pipe.
- */
-ssize_t cifs_splice_read(struct file *in, loff_t *ppos,
- struct pipe_inode_info *pipe, size_t len,
- unsigned int flags)
-{
- if (unlikely(*ppos >= file_inode(in)->i_sb->s_maxbytes))
- return 0;
- if (unlikely(!len))
- return 0;
- if (in->f_flags & O_DIRECT)
- return copy_splice_read(in, ppos, pipe, len, flags);
- return filemap_splice_read(in, ppos, pipe, len, flags);
-}
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v21 29/30] splice: Remove generic_file_splice_read()
[not found] <20230520000049.2226926-1-dhowells@redhat.com>
2023-05-20 0:00 ` [PATCH v21 03/30] splice: Rename direct_splice_read() to copy_splice_read() David Howells
2023-05-20 0:00 ` [PATCH v21 27/30] cifs: Use filemap_splice_read() David Howells
@ 2023-05-20 0:00 ` David Howells
2023-05-20 4:14 ` Christoph Hellwig
2023-05-20 9:57 ` Christian Brauner
2 siblings, 2 replies; 10+ messages in thread
From: David Howells @ 2023-05-20 0:00 UTC (permalink / raw)
To: Jens Axboe, Al Viro, Christoph Hellwig
Cc: David Howells, Matthew Wilcox, Jan Kara, Jeff Layton,
David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe, Hillf Danton,
Christian Brauner, Linus Torvalds, linux-fsdevel, linux-block,
linux-kernel, linux-mm, Christoph Hellwig, Steve French,
John Hubbard, linux-cifs
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 <dhowells@redhat.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Jens Axboe <axboe@kernel.dk>
cc: Steve French <smfrench@gmail.com>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: David Hildenbrand <david@redhat.com>
cc: John Hubbard <jhubbard@nvidia.com>
cc: linux-mm@kvack.org
cc: linux-block@vger.kernel.org
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
Notes:
ver #21)
- Move zero-len check to vfs_splice_read().
- Move s_maxbytes check to filemap_splice_read().
- DIO (and DAX) are handled by vfs_splice_read().
ver #20)
- Use s_maxbytes from the backing store (in->f_mapping), not the front
inode (especially for a blockdev).
ver #18)
- Split out the change to cifs to make it use generic_file_splice_read().
- Split out the unexport of filemap_splice_read() (still needed by cifs).
fs/splice.c | 43 -------------------------------------------
include/linux/fs.h | 2 --
2 files changed, 45 deletions(-)
diff --git a/fs/splice.c b/fs/splice.c
index 8268248df3a9..9be4cb3b9879 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -386,49 +386,6 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos,
}
EXPORT_SYMBOL(copy_splice_read);
-/**
- * generic_file_splice_read - splice data from file to a pipe
- * @in: file to splice from
- * @ppos: position in @in
- * @pipe: pipe to splice to
- * @len: number of bytes to splice
- * @flags: splice modifier flags
- *
- * Description:
- * Will read pages from given file and fill them into a pipe. Can be
- * used as long as it has more or less sane ->read_iter().
- *
- */
-ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
- struct pipe_inode_info *pipe, size_t len,
- unsigned int flags)
-{
- struct iov_iter to;
- struct kiocb kiocb;
- int ret;
-
- iov_iter_pipe(&to, ITER_DEST, pipe, len);
- init_sync_kiocb(&kiocb, in);
- kiocb.ki_pos = *ppos;
- ret = call_read_iter(in, &kiocb, &to);
- if (ret > 0) {
- *ppos = kiocb.ki_pos;
- file_accessed(in);
- } else if (ret < 0) {
- /* free what was emitted */
- pipe_discard_from(pipe, to.start_head);
- /*
- * callers of ->splice_read() expect -EAGAIN on
- * "can't put anything in there", rather than -EFAULT.
- */
- if (ret == -EFAULT)
- ret = -EAGAIN;
- }
-
- return ret;
-}
-EXPORT_SYMBOL(generic_file_splice_read);
-
const struct pipe_buf_operations default_pipe_buf_ops = {
.release = generic_pipe_buf_release,
.try_steal = generic_pipe_buf_try_steal,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e3c22efa413e..08ba2ae1d3ce 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2755,8 +2755,6 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
ssize_t copy_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
size_t len, unsigned int flags);
-extern ssize_t generic_file_splice_read(struct file *, loff_t *,
- struct pipe_inode_info *, size_t, unsigned int);
extern ssize_t iter_file_splice_write(struct pipe_inode_info *,
struct file *, loff_t *, size_t, unsigned int);
extern ssize_t generic_splice_sendpage(struct pipe_inode_info *pipe,
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v21 29/30] splice: Remove generic_file_splice_read()
2023-05-20 0:00 ` [PATCH v21 29/30] splice: Remove generic_file_splice_read() David Howells
@ 2023-05-20 4:14 ` Christoph Hellwig
2023-05-20 9:57 ` Christian Brauner
1 sibling, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2023-05-20 4:14 UTC (permalink / raw)
To: David Howells
Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
Hillf Danton, Christian Brauner, Linus Torvalds, linux-fsdevel,
linux-block, linux-kernel, linux-mm, Christoph Hellwig,
Steve French, John Hubbard, linux-cifs
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v21 29/30] splice: Remove generic_file_splice_read()
2023-05-20 0:00 ` [PATCH v21 29/30] splice: Remove generic_file_splice_read() David Howells
2023-05-20 4:14 ` Christoph Hellwig
@ 2023-05-20 9:57 ` Christian Brauner
1 sibling, 0 replies; 10+ messages in thread
From: Christian Brauner @ 2023-05-20 9:57 UTC (permalink / raw)
To: David Howells
Cc: Jens Axboe, Al Viro, Christoph Hellwig, Matthew Wilcox, Jan Kara,
Jeff Layton, David Hildenbrand, Jason Gunthorpe, Logan Gunthorpe,
Hillf Danton, Linus Torvalds, linux-fsdevel, linux-block,
linux-kernel, linux-mm, Christoph Hellwig, Steve French,
John Hubbard, linux-cifs
On Sat, May 20, 2023 at 01:00:48AM +0100, David Howells wrote:
> 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 <dhowells@redhat.com>
> cc: Christoph Hellwig <hch@lst.de>
> cc: Jens Axboe <axboe@kernel.dk>
> cc: Steve French <smfrench@gmail.com>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: David Hildenbrand <david@redhat.com>
> cc: John Hubbard <jhubbard@nvidia.com>
> cc: linux-mm@kvack.org
> cc: linux-block@vger.kernel.org
> cc: linux-cifs@vger.kernel.org
> cc: linux-fsdevel@vger.kernel.org
> ---
Reviewed-by: Christian Brauner <brauner@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread