Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Amir Goldstein and committed by
Miklos Szeredi
f03b296e 9852d85e

+15 -10
+4 -4
fs/backing-file.c
··· 80 80 refcount_t ref; 81 81 struct kiocb *orig_iocb; 82 82 /* used for aio completion */ 83 - void (*end_write)(struct file *); 83 + void (*end_write)(struct file *, loff_t, ssize_t); 84 84 struct work_struct work; 85 85 long res; 86 86 }; ··· 109 109 struct kiocb *orig_iocb = aio->orig_iocb; 110 110 111 111 if (aio->end_write) 112 - aio->end_write(orig_iocb->ki_filp); 112 + aio->end_write(orig_iocb->ki_filp, iocb->ki_pos, res); 113 113 114 114 orig_iocb->ki_pos = iocb->ki_pos; 115 115 backing_aio_put(aio); ··· 239 239 240 240 ret = vfs_iter_write(file, iter, &iocb->ki_pos, rwf); 241 241 if (ctx->end_write) 242 - ctx->end_write(ctx->user_file); 242 + ctx->end_write(ctx->user_file, iocb->ki_pos, ret); 243 243 } else { 244 244 struct backing_aio *aio; 245 245 ··· 317 317 revert_creds(old_cred); 318 318 319 319 if (ctx->end_write) 320 - ctx->end_write(ctx->user_file); 320 + ctx->end_write(ctx->user_file, ppos ? *ppos : 0, ret); 321 321 322 322 return ret; 323 323 }
+3 -3
fs/fuse/passthrough.c
··· 18 18 fuse_invalidate_atime(inode); 19 19 } 20 20 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) 22 22 { 23 23 struct inode *inode = file_inode(file); 24 24 ··· 63 63 struct backing_file_ctx ctx = { 64 64 .cred = ff->cred, 65 65 .user_file = file, 66 - .end_write = fuse_file_modified, 66 + .end_write = fuse_passthrough_end_write, 67 67 }; 68 68 69 69 pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu\n", __func__, ··· 110 110 struct backing_file_ctx ctx = { 111 111 .cred = ff->cred, 112 112 .user_file = out, 113 - .end_write = fuse_file_modified, 113 + .end_write = fuse_passthrough_end_write, 114 114 }; 115 115 116 116 pr_debug("%s: backing_file=0x%p, pos=%lld, len=%zu, flags=0x%x\n", __func__,
+7 -2
fs/overlayfs/file.c
··· 231 231 ovl_copyattr(file_inode(file)); 232 232 } 233 233 234 + static void ovl_file_end_write(struct file *file, loff_t pos, ssize_t ret) 235 + { 236 + ovl_file_modified(file); 237 + } 238 + 234 239 static void ovl_file_accessed(struct file *file) 235 240 { 236 241 struct inode *inode, *upperinode; ··· 299 294 struct backing_file_ctx ctx = { 300 295 .cred = ovl_creds(inode->i_sb), 301 296 .user_file = file, 302 - .end_write = ovl_file_modified, 297 + .end_write = ovl_file_end_write, 303 298 }; 304 299 305 300 if (!iov_iter_count(iter)) ··· 369 364 struct backing_file_ctx ctx = { 370 365 .cred = ovl_creds(inode->i_sb), 371 366 .user_file = out, 372 - .end_write = ovl_file_modified, 367 + .end_write = ovl_file_end_write, 373 368 }; 374 369 375 370 inode_lock(inode);
+1 -1
include/linux/backing-file.h
··· 16 16 const struct cred *cred; 17 17 struct file *user_file; 18 18 void (*accessed)(struct file *); 19 - void (*end_write)(struct file *); 19 + void (*end_write)(struct file *, loff_t, ssize_t); 20 20 }; 21 21 22 22 struct file *backing_file_open(const struct path *user_path, int flags,