mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 12:52:30 +00:00
splice: return type ssize_t from all helpers
Not sure why some splice helpers return long, maybe historic reasons. Change them all to return ssize_t to conform to the splice methods and to the rest of the helpers. Suggested-by: Christian Brauner <brauner@kernel.org> Link: https://lore.kernel.org/r/20231208-horchen-helium-d3ec1535ede5@brauner/ Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://lore.kernel.org/r/20231212094440.250945-2-amir73il@gmail.com Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
7306512686
commit
0f292086c2
@ -243,7 +243,7 @@ int do_statx(int dfd, struct filename *filename, unsigned int flags,
|
|||||||
/*
|
/*
|
||||||
* fs/splice.c:
|
* fs/splice.c:
|
||||||
*/
|
*/
|
||||||
long splice_file_to_pipe(struct file *in,
|
ssize_t splice_file_to_pipe(struct file *in,
|
||||||
struct pipe_inode_info *opipe,
|
struct pipe_inode_info *opipe,
|
||||||
loff_t *offset,
|
loff_t *offset,
|
||||||
size_t len, unsigned int flags);
|
size_t len, unsigned int flags);
|
||||||
|
@ -285,7 +285,7 @@ static int ovl_copy_up_file(struct ovl_fs *ofs, struct dentry *dentry,
|
|||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
size_t this_len = OVL_COPY_UP_CHUNK_SIZE;
|
size_t this_len = OVL_COPY_UP_CHUNK_SIZE;
|
||||||
long bytes;
|
ssize_t bytes;
|
||||||
|
|
||||||
if (len < this_len)
|
if (len < this_len)
|
||||||
this_len = len;
|
this_len = len;
|
||||||
|
60
fs/splice.c
60
fs/splice.c
@ -201,7 +201,8 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
|
|||||||
unsigned int tail = pipe->tail;
|
unsigned int tail = pipe->tail;
|
||||||
unsigned int head = pipe->head;
|
unsigned int head = pipe->head;
|
||||||
unsigned int mask = pipe->ring_size - 1;
|
unsigned int mask = pipe->ring_size - 1;
|
||||||
int ret = 0, page_nr = 0;
|
ssize_t ret = 0;
|
||||||
|
int page_nr = 0;
|
||||||
|
|
||||||
if (!spd_pages)
|
if (!spd_pages)
|
||||||
return 0;
|
return 0;
|
||||||
@ -932,7 +933,7 @@ static int warn_unsupported(struct file *file, const char *op)
|
|||||||
/*
|
/*
|
||||||
* Attempt to initiate a splice from pipe to file.
|
* Attempt to initiate a splice from pipe to file.
|
||||||
*/
|
*/
|
||||||
static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
|
static ssize_t do_splice_from(struct pipe_inode_info *pipe, struct file *out,
|
||||||
loff_t *ppos, size_t len, unsigned int flags)
|
loff_t *ppos, size_t len, unsigned int flags)
|
||||||
{
|
{
|
||||||
if (unlikely(!out->f_op->splice_write))
|
if (unlikely(!out->f_op->splice_write))
|
||||||
@ -955,7 +956,7 @@ static void do_splice_eof(struct splice_desc *sd)
|
|||||||
* Callers already called rw_verify_area() on the entire range.
|
* Callers already called rw_verify_area() on the entire range.
|
||||||
* No need to call it for sub ranges.
|
* No need to call it for sub ranges.
|
||||||
*/
|
*/
|
||||||
static long do_splice_read(struct file *in, loff_t *ppos,
|
static ssize_t do_splice_read(struct file *in, loff_t *ppos,
|
||||||
struct pipe_inode_info *pipe, size_t len,
|
struct pipe_inode_info *pipe, size_t len,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
@ -999,11 +1000,11 @@ static long do_splice_read(struct file *in, loff_t *ppos,
|
|||||||
* If successful, it returns the amount of data spliced, 0 if it hit the EOF or
|
* If successful, it returns the amount of data spliced, 0 if it hit the EOF or
|
||||||
* a hole and a negative error code otherwise.
|
* a hole and a negative error code otherwise.
|
||||||
*/
|
*/
|
||||||
long vfs_splice_read(struct file *in, loff_t *ppos,
|
ssize_t vfs_splice_read(struct file *in, loff_t *ppos,
|
||||||
struct pipe_inode_info *pipe, size_t len,
|
struct pipe_inode_info *pipe, size_t len,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int ret;
|
ssize_t ret;
|
||||||
|
|
||||||
ret = rw_verify_area(READ, in, ppos, len);
|
ret = rw_verify_area(READ, in, ppos, len);
|
||||||
if (unlikely(ret < 0))
|
if (unlikely(ret < 0))
|
||||||
@ -1030,7 +1031,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
|
|||||||
splice_direct_actor *actor)
|
splice_direct_actor *actor)
|
||||||
{
|
{
|
||||||
struct pipe_inode_info *pipe;
|
struct pipe_inode_info *pipe;
|
||||||
long ret, bytes;
|
ssize_t ret, bytes;
|
||||||
size_t len;
|
size_t len;
|
||||||
int i, flags, more;
|
int i, flags, more;
|
||||||
|
|
||||||
@ -1181,7 +1182,7 @@ static void direct_file_splice_eof(struct splice_desc *sd)
|
|||||||
file->f_op->splice_eof(file);
|
file->f_op->splice_eof(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static long do_splice_direct_actor(struct file *in, loff_t *ppos,
|
static ssize_t do_splice_direct_actor(struct file *in, loff_t *ppos,
|
||||||
struct file *out, loff_t *opos,
|
struct file *out, loff_t *opos,
|
||||||
size_t len, unsigned int flags,
|
size_t len, unsigned int flags,
|
||||||
splice_direct_actor *actor)
|
splice_direct_actor *actor)
|
||||||
@ -1195,7 +1196,7 @@ static long do_splice_direct_actor(struct file *in, loff_t *ppos,
|
|||||||
.splice_eof = direct_file_splice_eof,
|
.splice_eof = direct_file_splice_eof,
|
||||||
.opos = opos,
|
.opos = opos,
|
||||||
};
|
};
|
||||||
long ret;
|
ssize_t ret;
|
||||||
|
|
||||||
if (unlikely(!(out->f_mode & FMODE_WRITE)))
|
if (unlikely(!(out->f_mode & FMODE_WRITE)))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
@ -1226,7 +1227,7 @@ static long do_splice_direct_actor(struct file *in, loff_t *ppos,
|
|||||||
*
|
*
|
||||||
* Callers already called rw_verify_area() on the entire range.
|
* Callers already called rw_verify_area() on the entire range.
|
||||||
*/
|
*/
|
||||||
long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
|
ssize_t do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
|
||||||
loff_t *opos, size_t len, unsigned int flags)
|
loff_t *opos, size_t len, unsigned int flags)
|
||||||
{
|
{
|
||||||
return do_splice_direct_actor(in, ppos, out, opos, len, flags,
|
return do_splice_direct_actor(in, ppos, out, opos, len, flags,
|
||||||
@ -1249,7 +1250,7 @@ EXPORT_SYMBOL(do_splice_direct);
|
|||||||
*
|
*
|
||||||
* Callers already called rw_verify_area() on the entire range.
|
* Callers already called rw_verify_area() on the entire range.
|
||||||
*/
|
*/
|
||||||
long splice_file_range(struct file *in, loff_t *ppos, struct file *out,
|
ssize_t splice_file_range(struct file *in, loff_t *ppos, struct file *out,
|
||||||
loff_t *opos, size_t len)
|
loff_t *opos, size_t len)
|
||||||
{
|
{
|
||||||
lockdep_assert(file_write_started(out));
|
lockdep_assert(file_write_started(out));
|
||||||
@ -1280,12 +1281,12 @@ static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,
|
|||||||
struct pipe_inode_info *opipe,
|
struct pipe_inode_info *opipe,
|
||||||
size_t len, unsigned int flags);
|
size_t len, unsigned int flags);
|
||||||
|
|
||||||
long splice_file_to_pipe(struct file *in,
|
ssize_t splice_file_to_pipe(struct file *in,
|
||||||
struct pipe_inode_info *opipe,
|
struct pipe_inode_info *opipe,
|
||||||
loff_t *offset,
|
loff_t *offset,
|
||||||
size_t len, unsigned int flags)
|
size_t len, unsigned int flags)
|
||||||
{
|
{
|
||||||
long ret;
|
ssize_t ret;
|
||||||
|
|
||||||
pipe_lock(opipe);
|
pipe_lock(opipe);
|
||||||
ret = wait_for_space(opipe, flags);
|
ret = wait_for_space(opipe, flags);
|
||||||
@ -1300,13 +1301,13 @@ long splice_file_to_pipe(struct file *in,
|
|||||||
/*
|
/*
|
||||||
* Determine where to splice to/from.
|
* Determine where to splice to/from.
|
||||||
*/
|
*/
|
||||||
long do_splice(struct file *in, loff_t *off_in, struct file *out,
|
ssize_t do_splice(struct file *in, loff_t *off_in, struct file *out,
|
||||||
loff_t *off_out, size_t len, unsigned int flags)
|
loff_t *off_out, size_t len, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct pipe_inode_info *ipipe;
|
struct pipe_inode_info *ipipe;
|
||||||
struct pipe_inode_info *opipe;
|
struct pipe_inode_info *opipe;
|
||||||
loff_t offset;
|
loff_t offset;
|
||||||
long ret;
|
ssize_t ret;
|
||||||
|
|
||||||
if (unlikely(!(in->f_mode & FMODE_READ) ||
|
if (unlikely(!(in->f_mode & FMODE_READ) ||
|
||||||
!(out->f_mode & FMODE_WRITE)))
|
!(out->f_mode & FMODE_WRITE)))
|
||||||
@ -1397,14 +1398,14 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long __do_splice(struct file *in, loff_t __user *off_in,
|
static ssize_t __do_splice(struct file *in, loff_t __user *off_in,
|
||||||
struct file *out, loff_t __user *off_out,
|
struct file *out, loff_t __user *off_out,
|
||||||
size_t len, unsigned int flags)
|
size_t len, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct pipe_inode_info *ipipe;
|
struct pipe_inode_info *ipipe;
|
||||||
struct pipe_inode_info *opipe;
|
struct pipe_inode_info *opipe;
|
||||||
loff_t offset, *__off_in = NULL, *__off_out = NULL;
|
loff_t offset, *__off_in = NULL, *__off_out = NULL;
|
||||||
long ret;
|
ssize_t ret;
|
||||||
|
|
||||||
ipipe = get_pipe_info(in, true);
|
ipipe = get_pipe_info(in, true);
|
||||||
opipe = get_pipe_info(out, true);
|
opipe = get_pipe_info(out, true);
|
||||||
@ -1443,16 +1444,16 @@ static long __do_splice(struct file *in, loff_t __user *off_in,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int iter_to_pipe(struct iov_iter *from,
|
static ssize_t iter_to_pipe(struct iov_iter *from,
|
||||||
struct pipe_inode_info *pipe,
|
struct pipe_inode_info *pipe,
|
||||||
unsigned flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct pipe_buffer buf = {
|
struct pipe_buffer buf = {
|
||||||
.ops = &user_page_pipe_buf_ops,
|
.ops = &user_page_pipe_buf_ops,
|
||||||
.flags = flags
|
.flags = flags
|
||||||
};
|
};
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
int ret = 0;
|
ssize_t ret = 0;
|
||||||
|
|
||||||
while (iov_iter_count(from)) {
|
while (iov_iter_count(from)) {
|
||||||
struct page *pages[16];
|
struct page *pages[16];
|
||||||
@ -1501,7 +1502,7 @@ static int pipe_to_user(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
|
|||||||
* For lack of a better implementation, implement vmsplice() to userspace
|
* For lack of a better implementation, implement vmsplice() to userspace
|
||||||
* as a simple copy of the pipes pages to the user iov.
|
* as a simple copy of the pipes pages to the user iov.
|
||||||
*/
|
*/
|
||||||
static long vmsplice_to_user(struct file *file, struct iov_iter *iter,
|
static ssize_t vmsplice_to_user(struct file *file, struct iov_iter *iter,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct pipe_inode_info *pipe = get_pipe_info(file, true);
|
struct pipe_inode_info *pipe = get_pipe_info(file, true);
|
||||||
@ -1510,7 +1511,7 @@ static long vmsplice_to_user(struct file *file, struct iov_iter *iter,
|
|||||||
.flags = flags,
|
.flags = flags,
|
||||||
.u.data = iter
|
.u.data = iter
|
||||||
};
|
};
|
||||||
long ret = 0;
|
ssize_t ret = 0;
|
||||||
|
|
||||||
if (!pipe)
|
if (!pipe)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
@ -1534,11 +1535,11 @@ static long vmsplice_to_user(struct file *file, struct iov_iter *iter,
|
|||||||
* as splice-from-memory, where the regular splice is splice-from-file (or
|
* as splice-from-memory, where the regular splice is splice-from-file (or
|
||||||
* to file). In both cases the output is a pipe, naturally.
|
* to file). In both cases the output is a pipe, naturally.
|
||||||
*/
|
*/
|
||||||
static long vmsplice_to_pipe(struct file *file, struct iov_iter *iter,
|
static ssize_t vmsplice_to_pipe(struct file *file, struct iov_iter *iter,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct pipe_inode_info *pipe;
|
struct pipe_inode_info *pipe;
|
||||||
long ret = 0;
|
ssize_t ret = 0;
|
||||||
unsigned buf_flag = 0;
|
unsigned buf_flag = 0;
|
||||||
|
|
||||||
if (flags & SPLICE_F_GIFT)
|
if (flags & SPLICE_F_GIFT)
|
||||||
@ -1634,7 +1635,7 @@ SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in,
|
|||||||
size_t, len, unsigned int, flags)
|
size_t, len, unsigned int, flags)
|
||||||
{
|
{
|
||||||
struct fd in, out;
|
struct fd in, out;
|
||||||
long error;
|
ssize_t error;
|
||||||
|
|
||||||
if (unlikely(!len))
|
if (unlikely(!len))
|
||||||
return 0;
|
return 0;
|
||||||
@ -1871,7 +1872,7 @@ retry:
|
|||||||
/*
|
/*
|
||||||
* Link contents of ipipe to opipe.
|
* Link contents of ipipe to opipe.
|
||||||
*/
|
*/
|
||||||
static int link_pipe(struct pipe_inode_info *ipipe,
|
static ssize_t link_pipe(struct pipe_inode_info *ipipe,
|
||||||
struct pipe_inode_info *opipe,
|
struct pipe_inode_info *opipe,
|
||||||
size_t len, unsigned int flags)
|
size_t len, unsigned int flags)
|
||||||
{
|
{
|
||||||
@ -1879,7 +1880,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
|
|||||||
unsigned int i_head, o_head;
|
unsigned int i_head, o_head;
|
||||||
unsigned int i_tail, o_tail;
|
unsigned int i_tail, o_tail;
|
||||||
unsigned int i_mask, o_mask;
|
unsigned int i_mask, o_mask;
|
||||||
int ret = 0;
|
ssize_t ret = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Potential ABBA deadlock, work around it by ordering lock
|
* Potential ABBA deadlock, work around it by ordering lock
|
||||||
@ -1962,11 +1963,12 @@ static int link_pipe(struct pipe_inode_info *ipipe,
|
|||||||
* The 'flags' used are the SPLICE_F_* variants, currently the only
|
* The 'flags' used are the SPLICE_F_* variants, currently the only
|
||||||
* applicable one is SPLICE_F_NONBLOCK.
|
* applicable one is SPLICE_F_NONBLOCK.
|
||||||
*/
|
*/
|
||||||
long do_tee(struct file *in, struct file *out, size_t len, unsigned int flags)
|
ssize_t do_tee(struct file *in, struct file *out, size_t len,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct pipe_inode_info *ipipe = get_pipe_info(in, true);
|
struct pipe_inode_info *ipipe = get_pipe_info(in, true);
|
||||||
struct pipe_inode_info *opipe = get_pipe_info(out, true);
|
struct pipe_inode_info *opipe = get_pipe_info(out, true);
|
||||||
int ret = -EINVAL;
|
ssize_t ret = -EINVAL;
|
||||||
|
|
||||||
if (unlikely(!(in->f_mode & FMODE_READ) ||
|
if (unlikely(!(in->f_mode & FMODE_READ) ||
|
||||||
!(out->f_mode & FMODE_WRITE)))
|
!(out->f_mode & FMODE_WRITE)))
|
||||||
@ -2003,7 +2005,7 @@ long do_tee(struct file *in, struct file *out, size_t len, unsigned int flags)
|
|||||||
SYSCALL_DEFINE4(tee, int, fdin, int, fdout, size_t, len, unsigned int, flags)
|
SYSCALL_DEFINE4(tee, int, fdin, int, fdout, size_t, len, unsigned int, flags)
|
||||||
{
|
{
|
||||||
struct fd in, out;
|
struct fd in, out;
|
||||||
int error;
|
ssize_t error;
|
||||||
|
|
||||||
if (unlikely(flags & ~SPLICE_F_ALL))
|
if (unlikely(flags & ~SPLICE_F_ALL))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -68,30 +68,29 @@ typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *,
|
|||||||
typedef int (splice_direct_actor)(struct pipe_inode_info *,
|
typedef int (splice_direct_actor)(struct pipe_inode_info *,
|
||||||
struct splice_desc *);
|
struct splice_desc *);
|
||||||
|
|
||||||
extern ssize_t splice_from_pipe(struct pipe_inode_info *, struct file *,
|
ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,
|
||||||
loff_t *, size_t, unsigned int,
|
loff_t *ppos, size_t len, unsigned int flags,
|
||||||
splice_actor *);
|
splice_actor *actor);
|
||||||
extern ssize_t __splice_from_pipe(struct pipe_inode_info *,
|
ssize_t __splice_from_pipe(struct pipe_inode_info *pipe,
|
||||||
struct splice_desc *, splice_actor *);
|
struct splice_desc *sd, splice_actor *actor);
|
||||||
extern ssize_t splice_to_pipe(struct pipe_inode_info *,
|
ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
|
||||||
struct splice_pipe_desc *);
|
struct splice_pipe_desc *spd);
|
||||||
extern ssize_t add_to_pipe(struct pipe_inode_info *,
|
ssize_t add_to_pipe(struct pipe_inode_info *pipe, struct pipe_buffer *buf);
|
||||||
struct pipe_buffer *);
|
ssize_t vfs_splice_read(struct file *in, loff_t *ppos,
|
||||||
long vfs_splice_read(struct file *in, loff_t *ppos,
|
|
||||||
struct pipe_inode_info *pipe, size_t len,
|
struct pipe_inode_info *pipe, size_t len,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
ssize_t splice_direct_to_actor(struct file *file, struct splice_desc *sd,
|
ssize_t splice_direct_to_actor(struct file *file, struct splice_desc *sd,
|
||||||
splice_direct_actor *actor);
|
splice_direct_actor *actor);
|
||||||
long do_splice(struct file *in, loff_t *off_in, struct file *out,
|
ssize_t do_splice(struct file *in, loff_t *off_in, struct file *out,
|
||||||
loff_t *off_out, size_t len, unsigned int flags);
|
loff_t *off_out, size_t len, unsigned int flags);
|
||||||
long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
|
ssize_t do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
|
||||||
loff_t *opos, size_t len, unsigned int flags);
|
loff_t *opos, size_t len, unsigned int flags);
|
||||||
long splice_file_range(struct file *in, loff_t *ppos, struct file *out,
|
ssize_t splice_file_range(struct file *in, loff_t *ppos, struct file *out,
|
||||||
loff_t *opos, size_t len);
|
loff_t *opos, size_t len);
|
||||||
|
|
||||||
extern long do_tee(struct file *in, struct file *out, size_t len,
|
ssize_t do_tee(struct file *in, struct file *out, size_t len,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
extern ssize_t splice_to_socket(struct pipe_inode_info *pipe, struct file *out,
|
ssize_t splice_to_socket(struct pipe_inode_info *pipe, struct file *out,
|
||||||
loff_t *ppos, size_t len, unsigned int flags);
|
loff_t *ppos, size_t len, unsigned int flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -51,7 +51,7 @@ int io_tee(struct io_kiocb *req, unsigned int issue_flags)
|
|||||||
struct file *out = sp->file_out;
|
struct file *out = sp->file_out;
|
||||||
unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
|
unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
|
||||||
struct file *in;
|
struct file *in;
|
||||||
long ret = 0;
|
ssize_t ret = 0;
|
||||||
|
|
||||||
WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK);
|
WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK);
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ int io_splice(struct io_kiocb *req, unsigned int issue_flags)
|
|||||||
unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
|
unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
|
||||||
loff_t *poff_in, *poff_out;
|
loff_t *poff_in, *poff_out;
|
||||||
struct file *in;
|
struct file *in;
|
||||||
long ret = 0;
|
ssize_t ret = 0;
|
||||||
|
|
||||||
WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK);
|
WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user