From: Darrick J. Wong <djwong@xxxxxxxxxx> Teach the upper level fuse library about iomap ioend events, which happen when a write that isn't a pure overwrite completes. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- include/fuse.h | 8 ++++++++ lib/fuse.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/include/fuse.h b/include/fuse.h index 6b25586e768285..e2e7c950bf144d 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -868,6 +868,14 @@ struct fuse_operations { off_t pos_in, uint64_t length_in, uint32_t opflags_in, ssize_t written_in, const struct fuse_iomap *iomap_in); + + /** + * Respond to the outcome of a file IO operation. + */ + int (*iomap_ioend) (const char *path, uint64_t nodeid, + uint64_t attr_ino, off_t pos_in, size_t written_in, + uint32_t ioendflags_in, int error_in, + uint64_t new_addr_in); #endif /* FUSE_USE_VERSION >= 318 */ }; diff --git a/lib/fuse.c b/lib/fuse.c index aa4287e0896761..8dbf88877dd37c 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -2776,6 +2776,26 @@ static int fuse_fs_iomap_end(struct fuse_fs *fs, const char *path, written, iomap); } +static int fuse_fs_iomap_ioend(struct fuse_fs *fs, const char *path, + uint64_t nodeid, uint64_t attr_ino, off_t pos, + size_t written, uint32_t ioendflags, int error, + uint64_t new_addr) +{ + fuse_get_context()->private_data = fs->user_data; + if (!fs->op.iomap_ioend) + return 0; + + if (fs->debug) { + fuse_log(FUSE_LOG_DEBUG, + "iomap_ioend[%s] nodeid %llu attr_ino %llu pos %llu written %zu ioendflags 0x%x error %d\n", + path, nodeid, attr_ino, pos, written, ioendflags, + error); + } + + return fs->op.iomap_ioend(path, nodeid, attr_ino, pos, written, + ioendflags, error, new_addr); +} + static void fuse_lib_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr, int valid, struct fuse_file_info *fi) { @@ -4466,6 +4486,30 @@ static void fuse_lib_iomap_end(fuse_req_t req, fuse_ino_t nodeid, reply_err(req, err); } +static void fuse_lib_iomap_ioend(fuse_req_t req, fuse_ino_t nodeid, + uint64_t attr_ino, off_t pos, size_t written, + uint32_t ioendflags, int error, + uint64_t new_addr) +{ + struct fuse *f = req_fuse_prepare(req); + struct fuse_intr_data d; + char *path; + int err; + + err = get_path_nullok(f, nodeid, &path); + if (err) { + reply_err(req, err); + return; + } + + fuse_prepare_interrupt(f, req, &d); + err = fuse_fs_iomap_ioend(f->fs, path, nodeid, attr_ino, pos, written, + ioendflags, error, new_addr); + fuse_finish_interrupt(f, req, &d); + free_path(f, nodeid, path); + reply_err(req, err); +} + static int clean_delay(struct fuse *f) { /* @@ -4566,6 +4610,7 @@ static struct fuse_lowlevel_ops fuse_path_ops = { .lseek = fuse_lib_lseek, .iomap_begin = fuse_lib_iomap_begin, .iomap_end = fuse_lib_iomap_end, + .iomap_ioend = fuse_lib_iomap_ioend, }; int fuse_notify_poll(struct fuse_pollhandle *ph)