fuse: fix wrong ff->iomode state changes from parallel dio write
authorAmir Goldstein <amir73il@gmail.com>
Sun, 7 Apr 2024 15:57:56 +0000 (18:57 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Mon, 15 Apr 2024 08:12:03 +0000 (10:12 +0200)
commit4864a6dd8320ad856698f93009c89f66ccb1653f
treea831c7c145ece77057573844807b1829dc9f1fa2
parentfec50db7033ea478773b159e0e2efb135270e3b7
fuse: fix wrong ff->iomode state changes from parallel dio write

There is a confusion with fuse_file_uncached_io_{start,end} interface.
These helpers do two things when called from passthrough open()/release():
1. Take/drop negative refcount of fi->iocachectr (inode uncached io mode)
2. State change ff->iomode IOM_NONE <-> IOM_UNCACHED (file uncached open)

The calls from parallel dio write path need to take a reference on
fi->iocachectr, but they should not be changing ff->iomode state, because
in this case, the fi->iocachectr reference does not stick around until file
release().

Factor out helpers fuse_inode_uncached_io_{start,end}, to be used from
parallel dio write path and rename fuse_file_*cached_io_{start,end} helpers
to fuse_file_*cached_io_{open,release} to clarify the difference.

Fixes: 205c1d802683 ("fuse: allow parallel dio writes with FUSE_DIRECT_IO_ALLOW_MMAP")
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/file.c
fs/fuse/fuse_i.h
fs/fuse/inode.c
fs/fuse/iomode.c