fs: pass offset and result to backing_file end_write() callback
This is needed for extending fuse inode size after fuse passthrough write. Suggested-by: Miklos Szeredi <miklos@szeredi.hu> Link: https://lore.kernel.org/linux-fsdevel/CAJfpegs=cvZ_NYy6Q_D42XhYS=Sjj5poM1b5TzXzOVvX=R36aA@mail.gmail.com/ Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
9852d85ec9
commit
f03b296e8b
@ -80,7 +80,7 @@ struct backing_aio {
|
|||||||
refcount_t ref;
|
refcount_t ref;
|
||||||
struct kiocb *orig_iocb;
|
struct kiocb *orig_iocb;
|
||||||
/* used for aio completion */
|
/* used for aio completion */
|
||||||
void (*end_write)(struct file *);
|
void (*end_write)(struct file *, loff_t, ssize_t);
|
||||||
struct work_struct work;
|
struct work_struct work;
|
||||||
long res;
|
long res;
|
||||||
};
|
};
|
||||||
@ -109,7 +109,7 @@ static void backing_aio_cleanup(struct backing_aio *aio, long res)
|
|||||||
struct kiocb *orig_iocb = aio->orig_iocb;
|
struct kiocb *orig_iocb = aio->orig_iocb;
|
||||||
|
|
||||||
if (aio->end_write)
|
if (aio->end_write)
|
||||||
aio->end_write(orig_iocb->ki_filp);
|
aio->end_write(orig_iocb->ki_filp, iocb->ki_pos, res);
|
||||||
|
|
||||||
orig_iocb->ki_pos = iocb->ki_pos;
|
orig_iocb->ki_pos = iocb->ki_pos;
|
||||||
backing_aio_put(aio);
|
backing_aio_put(aio);
|
||||||
@ -239,7 +239,7 @@ ssize_t backing_file_write_iter(struct file *file, struct iov_iter *iter,
|
|||||||
|
|
||||||
ret = vfs_iter_write(file, iter, &iocb->ki_pos, rwf);
|
ret = vfs_iter_write(file, iter, &iocb->ki_pos, rwf);
|
||||||
if (ctx->end_write)
|
if (ctx->end_write)
|
||||||
ctx->end_write(ctx->user_file);
|
ctx->end_write(ctx->user_file, iocb->ki_pos, ret);
|
||||||
} else {
|
} else {
|
||||||
struct backing_aio *aio;
|
struct backing_aio *aio;
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe,
|
|||||||
revert_creds(old_cred);
|
revert_creds(old_cred);
|
||||||
|
|
||||||
if (ctx->end_write)
|
if (ctx->end_write)
|
||||||
ctx->end_write(ctx->user_file);
|
ctx->end_write(ctx->user_file, ppos ? *ppos : 0, ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ static void fuse_file_accessed(struct file *file)
|
|||||||
fuse_invalidate_atime(inode);
|
fuse_invalidate_atime(inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fuse_file_modified(struct file *file)
|
static void fuse_passthrough_end_write(struct file *file, loff_t pos, ssize_t ret)
|
||||||
{
|
{
|
||||||
struct inode *inode = file_inode(file);
|
struct inode *inode = file_inode(file);
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ ssize_t fuse_passthrough_write_iter(struct kiocb *iocb,
|
|||||||
struct backing_file_ctx ctx = {
|
struct backing_file_ctx ctx = {
|
||||||
.cred = ff->cred,
|
.cred = ff->cred,
|
||||||
.user_file = file,
|
.user_file = file,
|
||||||
.end_write = fuse_file_modified,
|
.end_write = fuse_passthrough_end_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu\n", __func__,
|
pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu\n", __func__,
|
||||||
@ -110,7 +110,7 @@ ssize_t fuse_passthrough_splice_write(struct pipe_inode_info *pipe,
|
|||||||
struct backing_file_ctx ctx = {
|
struct backing_file_ctx ctx = {
|
||||||
.cred = ff->cred,
|
.cred = ff->cred,
|
||||||
.user_file = out,
|
.user_file = out,
|
||||||
.end_write = fuse_file_modified,
|
.end_write = fuse_passthrough_end_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu, flags=0x%x\n", __func__,
|
pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu, flags=0x%x\n", __func__,
|
||||||
|
@ -231,6 +231,11 @@ static void ovl_file_modified(struct file *file)
|
|||||||
ovl_copyattr(file_inode(file));
|
ovl_copyattr(file_inode(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ovl_file_end_write(struct file *file, loff_t pos, ssize_t ret)
|
||||||
|
{
|
||||||
|
ovl_file_modified(file);
|
||||||
|
}
|
||||||
|
|
||||||
static void ovl_file_accessed(struct file *file)
|
static void ovl_file_accessed(struct file *file)
|
||||||
{
|
{
|
||||||
struct inode *inode, *upperinode;
|
struct inode *inode, *upperinode;
|
||||||
@ -294,7 +299,7 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
|
|||||||
struct backing_file_ctx ctx = {
|
struct backing_file_ctx ctx = {
|
||||||
.cred = ovl_creds(inode->i_sb),
|
.cred = ovl_creds(inode->i_sb),
|
||||||
.user_file = file,
|
.user_file = file,
|
||||||
.end_write = ovl_file_modified,
|
.end_write = ovl_file_end_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!iov_iter_count(iter))
|
if (!iov_iter_count(iter))
|
||||||
@ -364,7 +369,7 @@ static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out,
|
|||||||
struct backing_file_ctx ctx = {
|
struct backing_file_ctx ctx = {
|
||||||
.cred = ovl_creds(inode->i_sb),
|
.cred = ovl_creds(inode->i_sb),
|
||||||
.user_file = out,
|
.user_file = out,
|
||||||
.end_write = ovl_file_modified,
|
.end_write = ovl_file_end_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
inode_lock(inode);
|
inode_lock(inode);
|
||||||
|
@ -16,7 +16,7 @@ struct backing_file_ctx {
|
|||||||
const struct cred *cred;
|
const struct cred *cred;
|
||||||
struct file *user_file;
|
struct file *user_file;
|
||||||
void (*accessed)(struct file *);
|
void (*accessed)(struct file *);
|
||||||
void (*end_write)(struct file *);
|
void (*end_write)(struct file *, loff_t, ssize_t);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct file *backing_file_open(const struct path *user_path, int flags,
|
struct file *backing_file_open(const struct path *user_path, int flags,
|
||||||
|
Loading…
Reference in New Issue
Block a user