diff options
author | Amir Goldstein <amir73il@gmail.com> | 2021-12-05 18:29:05 +0200 |
---|---|---|
committer | Amir Goldstein <amir73il@gmail.com> | 2022-01-03 14:55:34 +0200 |
commit | dad15aee26835240d72188179ba177a0bbafe659 (patch) | |
tree | bc03a4652249f38d0236a337c377b952aef38e4b | |
parent | 1b498ac9b341e086562f54cc49bf035e19a94e1d (diff) | |
download | fuse-dad15aee26835240d72188179ba177a0bbafe659.tar.gz |
Add no_rofd_flush mount option
To disable flush for read-only fd.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
-rw-r--r-- | include/fuse.h | 8 | ||||
-rw-r--r-- | lib/fuse.c | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/include/fuse.h b/include/fuse.h index a273b15..9148688 100644 --- a/include/fuse.h +++ b/include/fuse.h @@ -248,6 +248,14 @@ struct fuse_config { int auto_cache; /** + * By default, fuse waits for all pending writes to complete + * and calls the FLUSH operation on close(2) of every fuse fd. + * With this option, wait and FLUSH are not done for read-only + * fuse fd, similar to the behavior of NFS/SMB clients. + */ + int no_rofd_flush; + + /** * The timeout in seconds for which file attributes are cached * for the purpose of checking if auto_cache should flush the * file data on open. @@ -3272,6 +3272,10 @@ static void fuse_lib_open(fuse_req_t req, fuse_ino_t ino, if (f->conf.auto_cache) open_auto_cache(f, ino, path, fi); + + if (f->conf.no_rofd_flush && + (fi->flags & O_ACCMODE) == O_RDONLY) + fi->noflush = 1; } fuse_finish_interrupt(f, req, &d); } @@ -4653,6 +4657,7 @@ static const struct fuse_opt fuse_lib_opts[] = { FUSE_LIB_OPT("kernel_cache", kernel_cache, 1), FUSE_LIB_OPT("auto_cache", auto_cache, 1), FUSE_LIB_OPT("noauto_cache", auto_cache, 0), + FUSE_LIB_OPT("no_rofd_flush", no_rofd_flush, 1), FUSE_LIB_OPT("umask=", set_mode, 1), FUSE_LIB_OPT("umask=%o", umask, 0), FUSE_LIB_OPT("uid=", set_uid, 1), @@ -4705,6 +4710,7 @@ void fuse_lib_help(struct fuse_args *args) printf( " -o kernel_cache cache files in kernel\n" " -o [no]auto_cache enable caching based on modification times (off)\n" +" -o no_rofd_flush disable flushing of read-only fd on close (off)\n" " -o umask=M set file permissions (octal)\n" " -o uid=N set file owner\n" " -o gid=N set file group\n" |