On Fri, Feb 9, 2024 at 12:56 PM Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > > On Fri, 9 Feb 2024 at 11:35, Amir Goldstein <amir73il@xxxxxxxxx> wrote: > > > No reason apart from "symmetry" with the other io mode FOPEN flags. > > I will use an internal flag. > > Okay. > > Other ff->open_flags are set at open time and never changed. > FOPEN_CACHE_IO doesn't fit into that pattern. > > > I added io_open to fix a bug in an earlier version where fuse_file_release() > > was called on the error path after fuse_file_io_open() failed. > > > > The simple change would be to replace FOPEN_CACHE_IO flag > > with ff->io_cache_opened bit. > > Right. > > > > > I assume you meant to change ff->io_opened to an enum: > > { FUSE_IO_NONE, FUSE_IO_CACHE, FUSE_IO_DIRECT, > > FUSE_IO_PASSTHROUGH } > > > > Is that what you mean? > > I just meant ff->io_cache_opened is only set when the cache counter > needs decrementing. The logic is simpler and is trivially right. > Ok. but I'll leave it named io_opened because with fuse passthrough io_opened means either positive or negative refcount: void fuse_file_io_release(struct fuse_file *ff, struct inode *inode) { if (!ff->io_opened) return; /* * Last caching file close allows passthrough open of inode and * Last passthrough file close allows caching open of inode. */ if (ff->open_flags & FOPEN_PASSTHROUGH) fuse_file_uncached_io_end(inode); else fuse_file_cached_io_end(inode); ff->io_opened = false; } Thanks, Amir.