Skip to content

Commit a390ccb

Browse files
amir73ilMiklos Szeredi
authored andcommitted
fuse: add FOPEN_NOFLUSH
Add flag returned by FUSE_OPEN and FUSE_CREATE requests to avoid flushing data cache on close. Different filesystems implement ->flush() is different ways: - Most disk filesystems do not implement ->flush() at all - Some network filesystem (e.g. nfs) flush local write cache of FMODE_WRITE file and send a "flush" command to server - Some network filesystem (e.g. cifs) flush local write cache of FMODE_WRITE file without sending an additional command to server FUSE flushes local write cache of ANY file, even non FMODE_WRITE and sends a "flush" command to server (if server implements it). The FUSE implementation of ->flush() seems over agressive and arbitrary and does not make a lot of sense when writeback caching is disabled. Instead of deciding on another arbitrary implementation that makes sense, leave the choice of per-file flush behavior in the hands of the server. Link: https://lore.kernel.org/linux-fsdevel/CAJfpegspE8e6aKd47uZtSYX8Y-1e1FWS0VL0DH2Skb9gQP5RJQ@mail.gmail.com/ Suggested-by: Miklos Szeredi <[email protected]> Signed-off-by: Amir Goldstein <[email protected]> Signed-off-by: Miklos Szeredi <[email protected]>
1 parent c6c745b commit a390ccb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

fs/fuse/file.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ static int fuse_flush(struct file *file, fl_owner_t id)
476476
if (fuse_is_bad(inode))
477477
return -EIO;
478478

479+
if (ff->open_flags & FOPEN_NOFLUSH && !fm->fc->writeback_cache)
480+
return 0;
481+
479482
err = write_inode_now(inode, 1);
480483
if (err)
481484
return err;

include/uapi/linux/fuse.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@
184184
*
185185
* 7.34
186186
* - add FUSE_SYNCFS
187+
*
188+
* 7.35
189+
* - add FOPEN_NOFLUSH
187190
*/
188191

189192
#ifndef _LINUX_FUSE_H
@@ -219,7 +222,7 @@
219222
#define FUSE_KERNEL_VERSION 7
220223

221224
/** Minor version number of this interface */
222-
#define FUSE_KERNEL_MINOR_VERSION 34
225+
#define FUSE_KERNEL_MINOR_VERSION 35
223226

224227
/** The node ID of the root inode */
225228
#define FUSE_ROOT_ID 1
@@ -290,12 +293,14 @@ struct fuse_file_lock {
290293
* FOPEN_NONSEEKABLE: the file is not seekable
291294
* FOPEN_CACHE_DIR: allow caching this directory
292295
* FOPEN_STREAM: the file is stream-like (no file position at all)
296+
* FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE)
293297
*/
294298
#define FOPEN_DIRECT_IO (1 << 0)
295299
#define FOPEN_KEEP_CACHE (1 << 1)
296300
#define FOPEN_NONSEEKABLE (1 << 2)
297301
#define FOPEN_CACHE_DIR (1 << 3)
298302
#define FOPEN_STREAM (1 << 4)
303+
#define FOPEN_NOFLUSH (1 << 5)
299304

300305
/**
301306
* INIT request/reply flags

0 commit comments

Comments
 (0)