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 524b77b5d7bbd0..1357f4319bcc21 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -881,6 +881,14 @@ struct fuse_operations { off_t pos_in, uint64_t length_in, uint32_t opflags_in, ssize_t written_in, const struct fuse_file_iomap *iomap); + + /** + * 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); }; /** Extra context that may be needed by some filesystems diff --git a/lib/fuse.c b/lib/fuse.c index 632e935b8dff3e..725ab615d456e3 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -2848,6 +2848,26 @@ int fuse_fs_iomap_device_remove(int device_id) return fuse_lowlevel_iomap_device_remove(se, device_id); } +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 -ENOSYS; + + 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) { @@ -4578,6 +4598,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) { /* @@ -4681,6 +4725,7 @@ static struct fuse_lowlevel_ops fuse_path_ops = { #endif .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)