]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: only flush O_SYNC files on close
authorDarrick J. Wong <djwong@kernel.org>
Thu, 28 Aug 2025 17:30:39 +0000 (10:30 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 9 Mar 2026 02:14:03 +0000 (19:14 -0700)
Don't call ext2fs_flush2() from op_release unless the file was opened
with either synchronous write flag.

XXX: Maybe this should be replaced with actual incore state tracking for
inodes?

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
misc/fuse2fs.c

index 12bbd1f9cecddeef77ee69c4a26915a45c72394a..a8cb3bc8ab51c346e02fc136fe21b4b7f12a9174 100644 (file)
@@ -3066,11 +3066,15 @@ static int op_release(const char *path EXT2FS_ATTR((unused)),
        FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
        dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
        pthread_mutex_lock(&ff->bfl);
-       if (fs_writeable(fs) && fh->open_flags & EXT2_FILE_WRITE) {
+
+       if ((fp->flags & O_SYNC) &&
+           fs_writeable(fs) &&
+           (fh->open_flags & EXT2_FILE_WRITE)) {
                err = ext2fs_flush2(fs, EXT2_FLAG_FLUSH_NO_SYNC);
                if (err)
                        ret = translate_error(fs, fh->ino, err);
        }
+
        fp->fh = 0;
        pthread_mutex_unlock(&ff->bfl);