[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 015/108] virtiofsd: Make fsync work even if only inode is passed i
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 015/108] virtiofsd: Make fsync work even if only inode is passed in |
Date: |
Thu, 23 Jan 2020 16:44:57 +0000 |
From: Vivek Goyal <address@hidden>
If caller has not sent file handle in request, then using inode, retrieve
the fd opened using O_PATH and use that to open file again and issue
fsync. This will be needed when dax_flush() calls fsync. At that time
we only have inode information (and not file).
Signed-off-by: Vivek Goyal <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
tools/virtiofsd/fuse_lowlevel.c | 6 +++++-
tools/virtiofsd/passthrough_ll.c | 28 ++++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
index 514d79cb24..8552cfb8af 100644
--- a/tools/virtiofsd/fuse_lowlevel.c
+++ b/tools/virtiofsd/fuse_lowlevel.c
@@ -1075,7 +1075,11 @@ static void do_fsync(fuse_req_t req, fuse_ino_t nodeid,
const void *inarg)
fi.fh = arg->fh;
if (req->se->op.fsync) {
- req->se->op.fsync(req, nodeid, datasync, &fi);
+ if (fi.fh == (uint64_t)-1) {
+ req->se->op.fsync(req, nodeid, datasync, NULL);
+ } else {
+ req->se->op.fsync(req, nodeid, datasync, &fi);
+ }
} else {
fuse_reply_err(req, ENOSYS);
}
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 6c4da18075..26ac87013b 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -903,10 +903,34 @@ static void lo_fsync(fuse_req_t req, fuse_ino_t ino, int
datasync,
{
int res;
(void)ino;
+ int fd;
+ char *buf;
+
+ fuse_log(FUSE_LOG_DEBUG, "lo_fsync(ino=%" PRIu64 ", fi=0x%p)\n", ino,
+ (void *)fi);
+
+ if (!fi) {
+ res = asprintf(&buf, "/proc/self/fd/%i", lo_fd(req, ino));
+ if (res == -1) {
+ return (void)fuse_reply_err(req, errno);
+ }
+
+ fd = open(buf, O_RDWR);
+ free(buf);
+ if (fd == -1) {
+ return (void)fuse_reply_err(req, errno);
+ }
+ } else {
+ fd = fi->fh;
+ }
+
if (datasync) {
- res = fdatasync(fi->fh);
+ res = fdatasync(fd);
} else {
- res = fsync(fi->fh);
+ res = fsync(fd);
+ }
+ if (!fi) {
+ close(fd);
}
fuse_reply_err(req, res == -1 ? errno : 0);
}
--
2.24.1
- [PULL 005/108] virtiofsd: Add passthrough_ll, (continued)
- [PULL 005/108] virtiofsd: Add passthrough_ll, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 006/108] virtiofsd: Trim down imported files, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 004/108] virtiofsd: Add fuse_lowlevel.c, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 010/108] virtiofsd: Remove unused enum fuse_buf_copy_flags, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 009/108] virtiofsd: remove unused notify reply support, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 011/108] virtiofsd: Fix fuse_daemonize ignored return values, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 012/108] virtiofsd: Fix common header and define for QEMU builds, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 014/108] vitriofsd/passthrough_ll: fix fallocate() ifdefs, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 013/108] virtiofsd: Trim out compatibility code, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 017/108] virtiofsd: add -o source=PATH to help output, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 015/108] virtiofsd: Make fsync work even if only inode is passed in,
Dr. David Alan Gilbert (git) <=
- [PULL 016/108] virtiofsd: Add options for virtio, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 019/108] virtiofsd: Start wiring up vhost-user, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 001/108] virtiofsd: Pull in upstream headers, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 020/108] virtiofsd: Add main virtio loop, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 007/108] virtiofsd: Format imported files to qemu style, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 018/108] virtiofsd: Open vhost connection instead of mounting, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 021/108] virtiofsd: get/set features callbacks, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 022/108] virtiofsd: Start queue threads, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 025/108] virtiofsd: Send replies to messages, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 026/108] virtiofsd: Keep track of replies, Dr. David Alan Gilbert (git), 2020/01/23