Skip to content

Commit f03b296

Browse files
amir73ilMiklos Szeredi
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/linux-fsdevel/CAJfpegs=cvZ_NYy6Q_D42XhYS=Sjj5poM1b5TzXzOVvX=R36aA@mail.gmail.com/ Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 9852d85 commit f03b296

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

fs/backing-file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct backing_aio {
8080
refcount_t ref;
8181
struct kiocb *orig_iocb;
8282
/* used for aio completion */
83-
void (*end_write)(struct file *);
83+
void (*end_write)(struct file *, loff_t, ssize_t);
8484
struct work_struct work;
8585
long res;
8686
};
@@ -109,7 +109,7 @@ static void backing_aio_cleanup(struct backing_aio *aio, long res)
109109
struct kiocb *orig_iocb = aio->orig_iocb;
110110

111111
if (aio->end_write)
112-
aio->end_write(orig_iocb->ki_filp);
112+
aio->end_write(orig_iocb->ki_filp, iocb->ki_pos, res);
113113

114114
orig_iocb->ki_pos = iocb->ki_pos;
115115
backing_aio_put(aio);
@@ -239,7 +239,7 @@ ssize_t backing_file_write_iter(struct file *file, struct iov_iter *iter,
239239

240240
ret = vfs_iter_write(file, iter, &iocb->ki_pos, rwf);
241241
if (ctx->end_write)
242-
ctx->end_write(ctx->user_file);
242+
ctx->end_write(ctx->user_file, iocb->ki_pos, ret);
243243
} else {
244244
struct backing_aio *aio;
245245

@@ -317,7 +317,7 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe,
317317
revert_creds(old_cred);
318318

319319
if (ctx->end_write)
320-
ctx->end_write(ctx->user_file);
320+
ctx->end_write(ctx->user_file, ppos ? *ppos : 0, ret);
321321

322322
return ret;
323323
}

fs/fuse/passthrough.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void fuse_file_accessed(struct file *file)
1818
fuse_invalidate_atime(inode);
1919
}
2020

21-
static void fuse_file_modified(struct file *file)
21+
static void fuse_passthrough_end_write(struct file *file, loff_t pos, ssize_t ret)
2222
{
2323
struct inode *inode = file_inode(file);
2424

@@ -63,7 +63,7 @@ ssize_t fuse_passthrough_write_iter(struct kiocb *iocb,
6363
struct backing_file_ctx ctx = {
6464
.cred = ff->cred,
6565
.user_file = file,
66-
.end_write = fuse_file_modified,
66+
.end_write = fuse_passthrough_end_write,
6767
};
6868

6969
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,
110110
struct backing_file_ctx ctx = {
111111
.cred = ff->cred,
112112
.user_file = out,
113-
.end_write = fuse_file_modified,
113+
.end_write = fuse_passthrough_end_write,
114114
};
115115

116116
pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu, flags=0x%x\n", __func__,

fs/overlayfs/file.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ static void ovl_file_modified(struct file *file)
231231
ovl_copyattr(file_inode(file));
232232
}
233233

234+
static void ovl_file_end_write(struct file *file, loff_t pos, ssize_t ret)
235+
{
236+
ovl_file_modified(file);
237+
}
238+
234239
static void ovl_file_accessed(struct file *file)
235240
{
236241
struct inode *inode, *upperinode;
@@ -294,7 +299,7 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter)
294299
struct backing_file_ctx ctx = {
295300
.cred = ovl_creds(inode->i_sb),
296301
.user_file = file,
297-
.end_write = ovl_file_modified,
302+
.end_write = ovl_file_end_write,
298303
};
299304

300305
if (!iov_iter_count(iter))
@@ -364,7 +369,7 @@ static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out,
364369
struct backing_file_ctx ctx = {
365370
.cred = ovl_creds(inode->i_sb),
366371
.user_file = out,
367-
.end_write = ovl_file_modified,
372+
.end_write = ovl_file_end_write,
368373
};
369374

370375
inode_lock(inode);

include/linux/backing-file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct backing_file_ctx {
1616
const struct cred *cred;
1717
struct file *user_file;
1818
void (*accessed)(struct file *);
19-
void (*end_write)(struct file *);
19+
void (*end_write)(struct file *, loff_t, ssize_t);
2020
};
2121

2222
struct file *backing_file_open(const struct path *user_path, int flags,

0 commit comments

Comments
 (0)