aboutsummaryrefslogtreecommitdiffstats
path: root/example/passthrough.c
diff options
context:
space:
mode:
Diffstat (limited to 'example/passthrough.c')
-rw-r--r--example/passthrough.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/example/passthrough.c b/example/passthrough.c
index dd385c5..30a8ad5 100644
--- a/example/passthrough.c
+++ b/example/passthrough.c
@@ -59,6 +59,13 @@ static void *xmp_init(struct fuse_conn_info *conn,
(void) conn;
cfg->use_ino = 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
@@ -285,7 +292,6 @@ static int xmp_create(const char *path, mode_t mode,
return -errno;
fi->fh = res;
- fi->parallel_direct_writes = 1;
return 0;
}
@@ -297,8 +303,15 @@ static int xmp_open(const char *path, struct fuse_file_info *fi)
if (res == -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 = res;
- fi->parallel_direct_writes = 1;
return 0;
}