mirror of
https://github.com/libfuse/libfuse.git
synced 2024-11-26 21:54:30 +08:00
Enable direct IO for passthrough examples when open has flag O_DIRECT
Shared locks (parallel_direct_writes) cannot be enabled for O_DIRECT, as O_DIRECT may be set past file open time with fcntl(fd, F_SETFD, ...). Kernel side fuse has precautions for shared lock direct-IO (direct_io in libfuse), as it needs an exclusive inode lock when direct and page cache IO happend at the same time. In order to enjoy the parallel_direct_writes feature (i.e., get a shared lock, not exclusive lock) for writes to the same file), direct_io is needed. The feature direct_io is corresponding to FOPEN_DIRECT_IO in fuse kernel. FOPEN_DIRECT_IO and O_DIRECT are not entirely the same as described above. So enable direct_io (i.e., FOPEN_DIRECT_IO in fuse kernel) to enjoy parallel direct_writes. Some patches related to FOPEN_DIRECT_IO and O_DIRECT are below: https://lore.kernel.org/all/753d6823-e984-4730-a126-d66b65ea772c@ddn.com
This commit is contained in:
parent
fce970c313
commit
c458633188
@ -303,6 +303,14 @@ 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;
|
||||
return 0;
|
||||
}
|
||||
|
@ -384,6 +384,14 @@ 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;
|
||||
return 0;
|
||||
}
|
||||
|
@ -905,6 +905,12 @@ static void sfs_open(fuse_req_t req, fuse_ino_t ino, fuse_file_info *fi) {
|
||||
if (fs.direct_io)
|
||||
fi->direct_io = 1;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* parallel_direct_writes feature depends on direct_io features.
|
||||
To make parallel_direct_writes valid, need set fi->direct_io
|
||||
in current function. */
|
||||
|
@ -837,6 +837,12 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
|
||||
else if (lo->cache == CACHE_ALWAYS)
|
||||
fi->keep_cache = 1;
|
||||
|
||||
/* 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 in the kernel). */
|
||||
if (fi->flags & O_DIRECT)
|
||||
fi->direct_io = 1;
|
||||
|
||||
/* parallel_direct_writes feature depends on direct_io features.
|
||||
To make parallel_direct_writes valid, need set fi->direct_io
|
||||
in current function. */
|
||||
|
Loading…
Reference in New Issue
Block a user