Skip to content

Commit 82a763e

Browse files
author
Miklos Szeredi
committed
ovl: simplify file splice
generic_file_splice_read() and iter_file_splice_write() will call back into f_op->iter_read() and f_op->iter_write() respectively. These already do the real file lookup and cred override. So the code in ovl_splice_read() and ovl_splice_write() is redundant. In addition the ovl_file_accessed() call in ovl_splice_write() is incorrect, though probably harmless. Fix by calling generic_file_splice_read() and iter_file_splice_write() directly. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 89bdfaf commit 82a763e

1 file changed

Lines changed: 2 additions & 44 deletions

File tree

‎fs/overlayfs/file.c‎

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -397,48 +397,6 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
397397
return ret;
398398
}
399399

400-
static ssize_t ovl_splice_read(struct file *in, loff_t *ppos,
401-
struct pipe_inode_info *pipe, size_t len,
402-
unsigned int flags)
403-
{
404-
ssize_t ret;
405-
struct fd real;
406-
const struct cred *old_cred;
407-
408-
ret = ovl_real_fdget(in, &real);
409-
if (ret)
410-
return ret;
411-
412-
old_cred = ovl_override_creds(file_inode(in)->i_sb);
413-
ret = generic_file_splice_read(real.file, ppos, pipe, len, flags);
414-
revert_creds(old_cred);
415-
416-
ovl_file_accessed(in);
417-
fdput(real);
418-
return ret;
419-
}
420-
421-
static ssize_t
422-
ovl_splice_write(struct pipe_inode_info *pipe, struct file *out,
423-
loff_t *ppos, size_t len, unsigned int flags)
424-
{
425-
struct fd real;
426-
const struct cred *old_cred;
427-
ssize_t ret;
428-
429-
ret = ovl_real_fdget(out, &real);
430-
if (ret)
431-
return ret;
432-
433-
old_cred = ovl_override_creds(file_inode(out)->i_sb);
434-
ret = iter_file_splice_write(pipe, real.file, ppos, len, flags);
435-
revert_creds(old_cred);
436-
437-
ovl_file_accessed(out);
438-
fdput(real);
439-
return ret;
440-
}
441-
442400
static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync)
443401
{
444402
struct fd real;
@@ -746,8 +704,8 @@ const struct file_operations ovl_file_operations = {
746704
#ifdef CONFIG_COMPAT
747705
.compat_ioctl = ovl_compat_ioctl,
748706
#endif
749-
.splice_read = ovl_splice_read,
750-
.splice_write = ovl_splice_write,
707+
.splice_read = generic_file_splice_read,
708+
.splice_write = iter_file_splice_write,
751709

752710
.copy_file_range = ovl_copy_file_range,
753711
.remap_file_range = ovl_remap_file_range,

0 commit comments

Comments
 (0)