[Devel] [PATCH RHEL8 COMMIT] fuse: don't declare FUSE FIEMAP support for any FUSE fs

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 23 11:54:57 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.19
------>
commit 09c1b47b3c37843962b669994b01f8220920e3af
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Fri Apr 23 11:54:57 2021 +0300

    fuse: don't declare FUSE FIEMAP support for any FUSE fs
    
    Stock kernels don't have FIEMAP support in fuse filesystems,
    we've added the support for FIEMAP for pStorage performance.
    
    Now if you call FIEMAP ioctl on a FUSE fs (for example mergerfs, sshfs,
    mhddfs), libfuse crashes (the function fuse_lib_ioctl aborts due to
    inbufsz > != outbufsz), so FIEMAP support autodetection does not work.
    
    Let's pretend we don't provide FIEMAP for any FUSE fs except for pStorage.
    
    https://bugs.openvz.org/browse/OVZ-7145
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 fs/fuse/inode.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 07c28ee12d8d..1a5724a7d8e6 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1546,23 +1546,33 @@ static struct dentry *fuse_mount(struct file_system_type *fs_type,
 		       void *raw_data)
 {
 	struct dentry *dentry;
+	struct fuse_conn *fc;
 
 	dentry = mount_nodev(fs_type, flags, raw_data, fuse_fill_super);
+	if (IS_ERR(dentry))
+		return dentry;
+
+	fc = dentry->d_sb->s_fs_info;
 
-	/* Hack to distinguish pcs fuse service and to force synchronous close for it.
-	 * Seems, this is the only place where we have some variable (dev_name), which
-	 * is not confined by fuse API and already defined.
+	/* Hack to distinguish pcs fuse service and to force synchronous
+	 * close for it. Seems, this is the only place where we have some
+	 * variable (dev_name), which is not confined by fuse API and
+	 * already defined.
+	 *
+	 * libfuse is not ready for fiemap autodetection, so disable fiemap
+	 * support check in advance for all FUSE fs except for pStorage.
 	 */
-	if (!IS_ERR(dentry) && dev_name &&
-			(strncmp(dev_name, "pstorage://", 11) == 0 ||
-				strncmp(dev_name, "vstorage://", 11) == 0) ) {
-		struct fuse_conn *fc = dentry->d_sb->s_fs_info;
+	if (dev_name &&
+	    (strncmp(dev_name, "pstorage://", 11) == 0 ||
+	     strncmp(dev_name, "vstorage://", 11) == 0)) {
 
 		if (!fc->disable_close_wait)
 			fc->close_wait = 1;
 
 		fc->compat_inval_files = 1;
-	}
+	} else
+		fc->no_fiemap = 1;
+
 	return dentry;
 }
 


More information about the Devel mailing list