From a5eb7f2a0117ab43119ef5724cf5f4f2f181804a Mon Sep 17 00:00:00 2001 From: Dharmendra singh Date: Fri, 8 Apr 2022 10:18:27 +0000 Subject: Enable parallel direct writes on the same file. Right now fuse kernel serializes direct writes on the same file. This serialization is good for such FUSE implementations which rely on the inode lock to avoid any data inconsistency issues but it hurts badly such FUSE implementations which have their own mechanism of dealing with cache/data integrity and can handle parallel direct writes on the same file. This patch allows parallel direct writes on the same file to be enabled with the help of a flag FOPEN_PARALLEL_DIRECT_WRITES. FUSE implementations which want to use this feature can set this flag during fuse init. Default behaviour remains same i.e no parallel direct writes on the same file. Corresponding fuse kernel patch(Merged). https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.2&id=153524053bbb0d27bb2e0be36d1b46862e9ce74c --- lib/fuse.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/fuse.c') diff --git a/lib/fuse.c b/lib/fuse.c index a247d3c..6b42a69 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -3145,7 +3145,9 @@ static void fuse_lib_create(fuse_req_t req, fuse_ino_t parent, fi->direct_io = 1; if (f->conf.kernel_cache) fi->keep_cache = 1; - + if (fi->direct_io && + f->conf.parallel_direct_writes) + fi->parallel_direct_writes = 1; } } fuse_finish_interrupt(f, req, &d); @@ -3229,6 +3231,10 @@ static void fuse_lib_open(fuse_req_t req, fuse_ino_t ino, if (f->conf.no_rofd_flush && (fi->flags & O_ACCMODE) == O_RDONLY) fi->noflush = 1; + + if (fi->direct_io && f->conf.parallel_direct_writes) + fi->parallel_direct_writes = 1; + } fuse_finish_interrupt(f, req, &d); } @@ -4653,6 +4659,7 @@ static const struct fuse_opt fuse_lib_opts[] = { FUSE_LIB_OPT("noforget", remember, -1), FUSE_LIB_OPT("remember=%u", remember, 0), FUSE_LIB_OPT("modules=%s", modules, 0), + FUSE_LIB_OPT("parallel_direct_write=%d", parallel_direct_writes, 0), FUSE_OPT_END }; -- cgit v1.2.3