[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/30] virtiofsd: Make fsync work even if only inode is passed in
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH 12/30] virtiofsd: Make fsync work even if only inode is passed in |
Date: |
Mon, 21 Oct 2019 11:58:14 +0100 |
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>
---
contrib/virtiofsd/fuse_lowlevel.c | 9 ++++++---
contrib/virtiofsd/passthrough_ll.c | 24 ++++++++++++++++++++++--
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/contrib/virtiofsd/fuse_lowlevel.c
b/contrib/virtiofsd/fuse_lowlevel.c
index ff68ec0c9d..6fe7506ead 100644
--- a/contrib/virtiofsd/fuse_lowlevel.c
+++ b/contrib/virtiofsd/fuse_lowlevel.c
@@ -1083,9 +1083,12 @@ static void do_fsync(fuse_req_t req, fuse_ino_t nodeid,
const void *inarg)
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
- if (req->se->op.fsync)
- req->se->op.fsync(req, nodeid, datasync, &fi);
- else
+ if (req->se->op.fsync) {
+ 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/contrib/virtiofsd/passthrough_ll.c
b/contrib/virtiofsd/passthrough_ll.c
index 72fae9d10b..63a32c87c3 100644
--- a/contrib/virtiofsd/passthrough_ll.c
+++ b/contrib/virtiofsd/passthrough_ll.c
@@ -863,10 +863,30 @@ 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.23.0
- [PATCH 01/30] virtiofsd: Pull in upstream headers, (continued)
- [PATCH 01/30] virtiofsd: Pull in upstream headers, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 05/30] virtiofsd: Add passthrough_ll, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 07/30] virtiofsd: remove mountpoint dummy argument, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 06/30] virtiofsd: Trim down imported files, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 09/30] virtiofsd: Fix fuse_daemonize ignored return values, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 08/30] virtiofsd: remove unused notify reply support, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 10/30] virtiofsd: Fix common header and define for QEMU builds, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 11/30] virtiofsd: fuse: Make iov_length usable outside fuse_lowlevel.c, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 12/30] virtiofsd: Make fsync work even if only inode is passed in,
Dr. David Alan Gilbert (git) <=
- [PATCH 14/30] virtiofsd: add -o source=PATH to help output, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 13/30] virtiofsd: Add options for virtio, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 15/30] virtiofsd: Open vhost connection instead of mounting, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 16/30] virtiofsd: Start wiring up vhost-user, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 17/30] virtiofsd: Add main virtio loop, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 19/30] virtiofsd: Start queue threads, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 20/30] virtiofsd: Poll kick_fd for queue, Dr. David Alan Gilbert (git), 2019/10/21
- [PATCH 18/30] virtiofsd: get/set features callbacks, Dr. David Alan Gilbert (git), 2019/10/21