From 500368f7fbdd888038d3dda579823e9515f63a3b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 23 May 2013 20:07:11 -0400 Subject: lift file_*_write out of do_splice_from() Signed-off-by: Al Viro --- fs/splice.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'fs/splice.c') diff --git a/fs/splice.c b/fs/splice.c index 9eca476227d5..fed5134f761c 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1115,10 +1115,7 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, else splice_write = default_file_splice_write; - file_start_write(out); - ret = splice_write(pipe, out, ppos, len, flags); - file_end_write(out); - return ret; + return splice_write(pipe, out, ppos, len, flags); } /* @@ -1306,9 +1303,11 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, }; long ret; + file_start_write(out); ret = splice_direct_to_actor(in, &sd, direct_splice_actor); if (ret > 0) *ppos = sd.pos; + file_end_write(out); return ret; } @@ -1361,7 +1360,9 @@ static long do_splice(struct file *in, loff_t __user *off_in, offset = out->f_pos; } + file_start_write(out); ret = do_splice_from(ipipe, out, &offset, len, flags); + file_end_write(out); if (!off_out) out->f_pos = offset; -- cgit v1.2.1 From 50cd2c577668a170750b15f9a88f022f681ce3c7 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 23 May 2013 20:10:34 -0400 Subject: lift file_*_write out of do_splice_direct() Signed-off-by: Al Viro --- fs/splice.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'fs/splice.c') diff --git a/fs/splice.c b/fs/splice.c index fed5134f761c..78b3d12046e7 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1303,11 +1303,9 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, }; long ret; - file_start_write(out); ret = splice_direct_to_actor(in, &sd, direct_splice_actor); if (ret > 0) *ppos = sd.pos; - file_end_write(out); return ret; } -- cgit v1.2.1 From 18c67cb9f0d2ac1e5660899c852f657ba84ddd2e Mon Sep 17 00:00:00 2001 From: Al Viro Date: Wed, 19 Jun 2013 15:41:54 +0400 Subject: splice: lift checks from do_splice_from() into callers Signed-off-by: Al Viro --- fs/splice.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'fs/splice.c') diff --git a/fs/splice.c b/fs/splice.c index 78b3d12046e7..cc53bd04be8f 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1098,17 +1098,6 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, { ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); - int ret; - - if (unlikely(!(out->f_mode & FMODE_WRITE))) - return -EBADF; - - if (unlikely(out->f_flags & O_APPEND)) - return -EINVAL; - - ret = rw_verify_area(WRITE, out, ppos, len); - if (unlikely(ret < 0)) - return ret; if (out->f_op && out->f_op->splice_write) splice_write = out->f_op->splice_write; @@ -1303,6 +1292,16 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, }; long ret; + if (unlikely(!(out->f_mode & FMODE_WRITE))) + return -EBADF; + + if (unlikely(out->f_flags & O_APPEND)) + return -EINVAL; + + ret = rw_verify_area(WRITE, out, opos, len); + if (unlikely(ret < 0)) + return ret; + ret = splice_direct_to_actor(in, &sd, direct_splice_actor); if (ret > 0) *ppos = sd.pos; @@ -1358,6 +1357,16 @@ static long do_splice(struct file *in, loff_t __user *off_in, offset = out->f_pos; } + if (unlikely(!(out->f_mode & FMODE_WRITE))) + return -EBADF; + + if (unlikely(out->f_flags & O_APPEND)) + return -EINVAL; + + ret = rw_verify_area(WRITE, out, &offset, len); + if (unlikely(ret < 0)) + return ret; + file_start_write(out); ret = do_splice_from(ipipe, out, &offset, len, flags); file_end_write(out); -- cgit v1.2.1