[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none
From: |
Catherine Ho |
Subject: |
[PATCH] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none |
Date: |
Sat, 11 Apr 2020 02:19:57 -0400 |
cache=none means to bypass host cache. So we can't remove O_DIRECT flag in
unconditionally in update_open_flags();
Signed-off-by: Catherine Ho <address@hidden>
---
tools/virtiofsd/passthrough_ll.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 4c35c95..889e144 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -1677,7 +1677,8 @@ static void lo_releasedir(fuse_req_t req, fuse_ino_t ino,
fuse_reply_err(req, 0);
}
-static void update_open_flags(int writeback, struct fuse_file_info *fi)
+static void update_open_flags(int writeback, int cache_mode,
+ struct fuse_file_info *fi)
{
/*
* With writeback cache, kernel may send read requests even
@@ -1702,10 +1703,13 @@ static void update_open_flags(int writeback, struct
fuse_file_info *fi)
/*
* O_DIRECT in guest should not necessarily mean bypassing page
- * cache on host as well. If somebody needs that behavior, it
- * probably should be a configuration knob in daemon.
+ * cache on host as well. If cache=none, set the flag to O_DIRECT
*/
- fi->flags &= ~O_DIRECT;
+ if (cache_mode == CACHE_NONE) {
+ fi->flags |= O_DIRECT;
+ } else {
+ fi->flags &= ~O_DIRECT;
+ }
}
static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
@@ -1737,7 +1741,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent,
const char *name,
goto out;
}
- update_open_flags(lo->writeback, fi);
+ update_open_flags(lo->writeback, lo->cache, fi);
fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
mode);
@@ -1947,7 +1951,7 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino,
struct fuse_file_info *fi)
fuse_log(FUSE_LOG_DEBUG, "lo_open(ino=%" PRIu64 ", flags=%d)\n", ino,
fi->flags);
- update_open_flags(lo->writeback, fi);
+ update_open_flags(lo->writeback, lo->cache, fi);
sprintf(buf, "%i", lo_fd(req, ino));
fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
--
1.7.1
- [PATCH] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none,
Catherine Ho <=