diff options
author | Bernd Schubert <bernd.schubert@fastmail.fm> | 2024-02-26 09:48:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-26 09:48:04 +0100 |
commit | f557f3677586d4e22a6208e5dc2ceea4e1999462 (patch) | |
tree | 1d907e2ee1f016f4fa379707782bab3e399a0d8f /example/passthrough_fh.c | |
parent | 74b1df2e84e836a1710561f52075d51f20cd5c78 (diff) | |
parent | c45863318889fa6344534537c7ef91a37b3fba32 (diff) | |
download | libfuse-f557f3677586d4e22a6208e5dc2ceea4e1999462.tar.gz |
Merge pull request #888 from yangyun50/master
passthrough examples: enable direct io when open has flag: O_DIRECT
Diffstat (limited to 'example/passthrough_fh.c')
-rw-r--r-- | example/passthrough_fh.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/example/passthrough_fh.c b/example/passthrough_fh.c index 51df3be..701d59e 100644 --- a/example/passthrough_fh.c +++ b/example/passthrough_fh.c @@ -54,6 +54,13 @@ static void *xmp_init(struct fuse_conn_info *conn, cfg->use_ino = 1; cfg->nullpath_ok = 1; + /* parallel_direct_writes feature depends on direct_io features. + To make parallel_direct_writes valid, need either set cfg->direct_io + in current function (recommended in high level API) or set fi->direct_io + in xmp_create() or xmp_open(). */ + // cfg->direct_io = 1; + cfg->parallel_direct_writes = 1; + /* Pick up changes from lower filesystem right away. This is also necessary for better hardlink support. When the kernel calls the unlink() handler, it does not know the inode of @@ -366,7 +373,6 @@ static int xmp_create(const char *path, mode_t mode, struct fuse_file_info *fi) return -errno; fi->fh = fd; - fi->parallel_direct_writes = 1; return 0; } @@ -378,8 +384,15 @@ static int xmp_open(const char *path, struct fuse_file_info *fi) if (fd == -1) return -errno; + /* Enable direct_io when open has flags O_DIRECT to enjoy the feature + parallel_direct_writes (i.e., to get a shared lock, not exclusive lock, + for writes to the same file). */ + if (fi->flags & O_DIRECT) { + fi->direct_io = 1; + fi->parallel_direct_writes = 1; + } + fi->fh = fd; - fi->parallel_direct_writes = 1; return 0; } |