[Devel] [PATCH rh7] fuse: don't declare FUSE FIEMAP support for generic FUSE fs

Konstantin Khorenko khorenko at virtuozzo.com
Thu Dec 12 18:55:45 MSK 2019


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).

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/ioctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 0eeebd1723aaa..99a5df85306cf 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -180,7 +180,12 @@ static int ioctl_fiemap(struct file *filp, unsigned long arg)
 	u64 len;
 	int error;
 
-	if (!inode->i_op->fiemap)
+	/*
+	 * Among FUSE filesystems only pStorage has FIEMAP support,
+	 * generic libfuse is not ready for it.
+	 */
+	if ((!inode->i_op->fiemap) ||
+	    ((sb->s_magic == FUSE_SUPER_MAGIC) && !IS_PSTORAGE(sb)))
 		return -EOPNOTSUPP;
 
 	if (copy_from_user(&fiemap, ufiemap, sizeof(fiemap)))
-- 
2.15.1



More information about the Devel mailing list