diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2022-04-03 12:12:59 +0300 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2022-04-03 12:12:59 +0300 |
commit | d7d0dc47f03762f5fcd92bbe8c2221ea6b3fa642 (patch) | |
tree | 5116d073d44fccfcda7a091d8c66aa031bf8d80f /src | |
parent | ead937af9cf85c5249230da8677e56a1ab7cb8bd (diff) | |
download | bindfs-d7d0dc47f03762f5fcd92bbe8c2221ea6b3fa642.tar.gz |
Added --direct-io
Issue #110, thanks @DUOLabs333 for the initial patch.
Diffstat (limited to 'src')
-rw-r--r-- | src/bindfs.1 | 5 | ||||
-rw-r--r-- | src/bindfs.c | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/bindfs.1 b/src/bindfs.1 index b681e44..db2e4fe 100644 --- a/src/bindfs.1 +++ b/src/bindfs.1 @@ -389,6 +389,11 @@ otherwise thread-safe, there is currently a race condition that may pose a security risk for some use cases. See \fB\%BUGS\fP below. .TP +.B \-\-direct\-io, \-o direct\-io +Forces each read/write operation to be forwarded 1:1 to the underlying FS, +disabling batching and caching by the kernel. + +.TP .B \-\-forward\-odirect=\fIalignment\fP, \-o forward\-odirect=\fIalignment\fP Enable experimental \fBO_DIRECT\fP forwarding, with all read/write requests rounded to the given alignment (in bytes). By default, the \fBO_DIRECT\fP flag is diff --git a/src/bindfs.c b/src/bindfs.c index bc24154..fd09704 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -203,6 +203,8 @@ static struct Settings { #ifdef __linux__ int forward_odirect; size_t odirect_alignment; + + bool direct_io; #endif uid_t uid_offset; @@ -689,6 +691,7 @@ static void *bindfs_init() cfg->entry_timeout = 0; cfg->attr_timeout = 0; cfg->negative_timeout = 0; + cfg->direct_io = settings.direct_io; #endif assert(settings.permchain != NULL); @@ -1283,6 +1286,9 @@ static int bindfs_open(const char *path, struct fuse_file_info *fi) flags &= ~O_DIRECT; } #endif +#ifndef HAVE_FUSE_3 // With FUSE 3, we set this in bindfs_init + fi->direct_io = settings.direct_io; +#endif fd = open(real_path, flags); free(real_path); @@ -1790,7 +1796,8 @@ enum OptionKey { OPTKEY_ENABLE_IOCTL, OPTKEY_HIDE_HARD_LINKS, OPTKEY_RESOLVE_SYMLINKS, - OPTKEY_BLOCK_DEVICES_AS_FILES + OPTKEY_BLOCK_DEVICES_AS_FILES, + OPTKEY_DIRECT_IO }; static int process_option(void *data, const char *arg, int key, @@ -1898,7 +1905,9 @@ static int process_option(void *data, const char *arg, int key, case OPTKEY_BLOCK_DEVICES_AS_FILES: settings.block_devices_as_files = 1; return 0; - + case OPTKEY_DIRECT_IO: + settings.direct_io = true; + return 0; case OPTKEY_NONOPTION: if (!settings.mntsrc) { if (strncmp(arg, "/proc/", strlen("/proc/")) == 0) { @@ -2388,6 +2397,7 @@ int main(int argc, char *argv[]) OPT2("--delete-deny", "delete-deny", OPTKEY_DELETE_DENY), OPT2("--rename-deny", "rename-deny", OPTKEY_RENAME_DENY), + OPT2("--direct-io", "direct-io", OPTKEY_DIRECT_IO), OPT2("--hide-hard-links", "hide-hard-links", OPTKEY_HIDE_HARD_LINKS), OPT2("--resolve-symlinks", "resolve-symlinks", OPTKEY_RESOLVE_SYMLINKS), @@ -2455,6 +2465,7 @@ int main(int argc, char *argv[]) #ifdef __linux__ settings.forward_odirect = 0; settings.odirect_alignment = 0; + settings.direct_io = false; #endif atexit(&atexit_func); |