int timeout_set;
int readdirplus_set;
int readdirplus_clear;
+ int allow_direct_io;
struct lo_inode root;
GHashTable *inodes; /* protected by lo->mutex */
struct lo_map ino_map; /* protected by lo->mutex */
{ "cache=always", offsetof(struct lo_data, cache), CACHE_ALWAYS },
{ "readdirplus", offsetof(struct lo_data, readdirplus_set), 1 },
{ "no_readdirplus", offsetof(struct lo_data, readdirplus_clear), 1 },
+ { "allow_direct_io", offsetof(struct lo_data, allow_direct_io), 1 },
+ { "no_allow_direct_io", offsetof(struct lo_data, allow_direct_io), 0 },
FUSE_OPT_END
};
static bool use_syslog = false;
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 allow_direct_io,
+ struct fuse_file_info *fi)
{
/*
* With writeback cache, kernel may send read requests even
/*
* 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. Therefore, we discard it by default
+ * ('-o no_allow_direct_io'). If somebody needs that behavior,
+ * the '-o allow_direct_io' option should be set.
*/
- fi->flags &= ~O_DIRECT;
+ if (!allow_direct_io) {
+ fi->flags &= ~O_DIRECT;
+ }
}
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->allow_direct_io, fi);
fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
mode);
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->allow_direct_io, fi);
sprintf(buf, "%i", lo_fd(req, ino));
fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
.debug = 0,
.writeback = 0,
.posix_lock = 0,
+ .allow_direct_io = 0,
.proc_self_fd = -1,
};
struct lo_map_elem *root_elem;