summaryrefslogtreecommitdiff
path: root/fs/overlayfs/file.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2024-10-21 12:33:38 +0200
committerAmir Goldstein <amir73il@gmail.com>2024-11-11 10:45:03 +0100
commit48b50624aec454ce0fa8f78ef96e2f43bc0be495 (patch)
tree607d8001af0e76d0a734c0f1ddbe830665ea9cff /fs/overlayfs/file.c
parent3b6b99ef15ea37635604992ede9ebcccef38a239 (diff)
backing-file: clean up the API
- Pass iocb to ctx->end_write() instead of file + pos - Get rid of ctx->user_file, which is redundant most of the time - Instead pass iocb to backing_file_splice_read and backing_file_splice_write Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Diffstat (limited to 'fs/overlayfs/file.c')
-rw-r--r--fs/overlayfs/file.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 4444c78e2e0c..12c4d502ff91 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -231,9 +231,9 @@ static void ovl_file_modified(struct file *file)
ovl_copyattr(file_inode(file));
}
-static void ovl_file_end_write(struct file *file, loff_t pos, ssize_t ret)
+static void ovl_file_end_write(struct kiocb *iocb, ssize_t ret)
{
- ovl_file_modified(file);
+ ovl_file_modified(iocb->ki_filp);
}
static void ovl_file_accessed(struct file *file)
@@ -271,7 +271,6 @@ static ssize_t ovl_read_iter(struct kiocb *iocb, struct iov_iter *iter)
ssize_t ret;
struct backing_file_ctx ctx = {
.cred = ovl_creds(file_inode(file)->i_sb),
- .user_file = file,
.accessed = ovl_file_accessed,
};
@@ -298,7 +297,6 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
int ifl = iocb->ki_flags;
struct backing_file_ctx ctx = {
.cred = ovl_creds(inode->i_sb),
- .user_file = file,
.end_write = ovl_file_end_write,
};
@@ -338,15 +336,18 @@ static ssize_t ovl_splice_read(struct file *in, loff_t *ppos,
ssize_t ret;
struct backing_file_ctx ctx = {
.cred = ovl_creds(file_inode(in)->i_sb),
- .user_file = in,
.accessed = ovl_file_accessed,
};
+ struct kiocb iocb;
ret = ovl_real_fdget(in, &real);
if (ret)
return ret;
- ret = backing_file_splice_read(fd_file(real), ppos, pipe, len, flags, &ctx);
+ init_sync_kiocb(&iocb, in);
+ iocb.ki_pos = *ppos;
+ ret = backing_file_splice_read(fd_file(real), &iocb, pipe, len, flags, &ctx);
+ *ppos = iocb.ki_pos;
fdput(real);
return ret;
@@ -368,9 +369,9 @@ static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out,
ssize_t ret;
struct backing_file_ctx ctx = {
.cred = ovl_creds(inode->i_sb),
- .user_file = out,
.end_write = ovl_file_end_write,
};
+ struct kiocb iocb;
inode_lock(inode);
/* Update mode */
@@ -380,9 +381,13 @@ static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out,
if (ret)
goto out_unlock;
- ret = backing_file_splice_write(pipe, fd_file(real), ppos, len, flags, &ctx);
+ init_sync_kiocb(&iocb, out);
+ iocb.ki_pos = *ppos;
+ ret = backing_file_splice_write(pipe, fd_file(real), &iocb, len, flags, &ctx);
+ *ppos = iocb.ki_pos;
fdput(real);
+
out_unlock:
inode_unlock(inode);
@@ -420,7 +425,6 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma)
struct file *realfile = file->private_data;
struct backing_file_ctx ctx = {
.cred = ovl_creds(file_inode(file)->i_sb),
- .user_file = file,
.accessed = ovl_file_accessed,
};