Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753386AbbGIQFe (ORCPT ); Thu, 9 Jul 2015 12:05:34 -0400 Received: from 78-80-28-91.tmcz.cz ([78.80.28.91]:60679 "EHLO leontynka.twibright.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751164AbbGIQFZ (ORCPT ); Thu, 9 Jul 2015 12:05:25 -0400 Date: Thu, 9 Jul 2015 18:05:15 +0200 (CEST) From: Mikulas Patocka X-X-Sender: mikulas@leontynka To: Linus Torvalds cc: Al Viro , "Ted Ts'o" , Linux Kernel Mailing List , linux-fsdevel Subject: [PATCH] ioctl_compat: handle FITRIM In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6391 Lines: 182 On Sun, 28 Jun 2015, Linus Torvalds wrote: > On Sun, Jun 28, 2015 at 6:16 AM, Mikulas Patocka wrote: > > This patch adds support for fstrim to the HPFS filesystem. > ... > > +#ifdef CONFIG_COMPAT > > + .compat_ioctl = hpfs_compat_ioctl, > > +#endif > ... > > +#ifdef CONFIG_COMPAT > > + .compat_ioctl = hpfs_compat_ioctl, > > +#endif > ... > > +#ifdef CONFIG_COMPAT > > +long hpfs_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) > > +{ > > + return hpfs_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); > > +} > > +#endif > > Hmm. You've clearly copied this pattern from other filesystems, and so > I can't really blame you, but this thing annoys me a lot. > > Why isn't FITRIM just marked as a COMPATIBLE_IOCTL(), at which point > the generic ioctl layer will do exactly the above translation for us? > > Am I missing something? > > Linus Here I'm sending a patch that handles FITRIM in a generic way? BTW. what happened with the other HPFS patches? They haven't been included in Linux 4.2-rc1. From: Mikulas Patocka The FITRIM ioctl has the same arguments on 32-bit and 64-bit architectures, so we can add it to the list of compatible ioctls and drop it from compat_ioctl method of various filesystems. Signed-off-by: Mikulas Patocka --- fs/compat_ioctl.c | 1 + fs/ecryptfs/file.c | 1 - fs/ext4/ioctl.c | 1 - fs/hpfs/dir.c | 3 --- fs/hpfs/file.c | 3 --- fs/hpfs/super.c | 7 ------- fs/jfs/ioctl.c | 4 ---- fs/nilfs2/ioctl.c | 1 - fs/ocfs2/ioctl.c | 1 - 9 files changed, 1 insertion(+), 21 deletions(-) Index: linux-4.2-rc1/fs/compat_ioctl.c =================================================================== --- linux-4.2-rc1.orig/fs/compat_ioctl.c 2015-07-09 16:17:16.000000000 +0200 +++ linux-4.2-rc1/fs/compat_ioctl.c 2015-07-09 16:18:50.000000000 +0200 @@ -896,6 +896,7 @@ COMPATIBLE_IOCTL(FIGETBSZ) /* 'X' - originally XFS but some now in the VFS */ COMPATIBLE_IOCTL(FIFREEZE) COMPATIBLE_IOCTL(FITHAW) +COMPATIBLE_IOCTL(FITRIM) COMPATIBLE_IOCTL(KDGETKEYCODE) COMPATIBLE_IOCTL(KDSETKEYCODE) COMPATIBLE_IOCTL(KDGKBTYPE) Index: linux-4.2-rc1/fs/ecryptfs/file.c =================================================================== --- linux-4.2-rc1.orig/fs/ecryptfs/file.c 2015-07-09 16:13:54.000000000 +0200 +++ linux-4.2-rc1/fs/ecryptfs/file.c 2015-07-09 16:14:05.000000000 +0200 @@ -325,7 +325,6 @@ ecryptfs_compat_ioctl(struct file *file, return rc; switch (cmd) { - case FITRIM: case FS_IOC32_GETFLAGS: case FS_IOC32_SETFLAGS: case FS_IOC32_GETVERSION: Index: linux-4.2-rc1/fs/ext4/ioctl.c =================================================================== --- linux-4.2-rc1.orig/fs/ext4/ioctl.c 2015-07-09 16:16:38.000000000 +0200 +++ linux-4.2-rc1/fs/ext4/ioctl.c 2015-07-09 16:16:45.000000000 +0200 @@ -755,7 +755,6 @@ long ext4_compat_ioctl(struct file *file return err; } case EXT4_IOC_MOVE_EXT: - case FITRIM: case EXT4_IOC_RESIZE_FS: case EXT4_IOC_PRECACHE_EXTENTS: case EXT4_IOC_SET_ENCRYPTION_POLICY: Index: linux-4.2-rc1/fs/hpfs/dir.c =================================================================== --- linux-4.2-rc1.orig/fs/hpfs/dir.c 2015-07-09 16:15:22.000000000 +0200 +++ linux-4.2-rc1/fs/hpfs/dir.c 2015-07-09 16:15:26.000000000 +0200 @@ -328,7 +328,4 @@ const struct file_operations hpfs_dir_op .release = hpfs_dir_release, .fsync = hpfs_file_fsync, .unlocked_ioctl = hpfs_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = hpfs_compat_ioctl, -#endif }; Index: linux-4.2-rc1/fs/hpfs/file.c =================================================================== --- linux-4.2-rc1.orig/fs/hpfs/file.c 2015-07-09 16:15:30.000000000 +0200 +++ linux-4.2-rc1/fs/hpfs/file.c 2015-07-09 16:15:33.000000000 +0200 @@ -204,9 +204,6 @@ const struct file_operations hpfs_file_o .fsync = hpfs_file_fsync, .splice_read = generic_file_splice_read, .unlocked_ioctl = hpfs_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = hpfs_compat_ioctl, -#endif }; const struct inode_operations hpfs_file_iops = Index: linux-4.2-rc1/fs/hpfs/super.c =================================================================== --- linux-4.2-rc1.orig/fs/hpfs/super.c 2015-07-09 16:14:53.000000000 +0200 +++ linux-4.2-rc1/fs/hpfs/super.c 2015-07-09 16:15:12.000000000 +0200 @@ -228,13 +228,6 @@ long hpfs_ioctl(struct file *file, unsig } } -#ifdef CONFIG_COMPAT -long hpfs_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) -{ - return hpfs_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); -} -#endif - static struct kmem_cache * hpfs_inode_cachep; Index: linux-4.2-rc1/fs/jfs/ioctl.c =================================================================== --- linux-4.2-rc1.orig/fs/jfs/ioctl.c 2015-07-09 16:16:52.000000000 +0200 +++ linux-4.2-rc1/fs/jfs/ioctl.c 2015-07-09 16:17:03.000000000 +0200 @@ -180,10 +180,6 @@ long jfs_compat_ioctl(struct file *filp, case JFS_IOC_SETFLAGS32: cmd = JFS_IOC_SETFLAGS; break; - case FITRIM: - cmd = FITRIM; - break; - } return jfs_ioctl(filp, cmd, arg); } #endif Index: linux-4.2-rc1/fs/nilfs2/ioctl.c =================================================================== --- linux-4.2-rc1.orig/fs/nilfs2/ioctl.c 2015-07-09 16:13:37.000000000 +0200 +++ linux-4.2-rc1/fs/nilfs2/ioctl.c 2015-07-09 16:13:47.000000000 +0200 @@ -1369,7 +1369,6 @@ long nilfs_compat_ioctl(struct file *fil case NILFS_IOCTL_SYNC: case NILFS_IOCTL_RESIZE: case NILFS_IOCTL_SET_ALLOC_RANGE: - case FITRIM: break; default: return -ENOIOCTLCMD; Index: linux-4.2-rc1/fs/ocfs2/ioctl.c =================================================================== --- linux-4.2-rc1.orig/fs/ocfs2/ioctl.c 2015-07-09 16:14:20.000000000 +0200 +++ linux-4.2-rc1/fs/ocfs2/ioctl.c 2015-07-09 16:14:25.000000000 +0200 @@ -980,7 +980,6 @@ long ocfs2_compat_ioctl(struct file *fil case OCFS2_IOC_GROUP_EXTEND: case OCFS2_IOC_GROUP_ADD: case OCFS2_IOC_GROUP_ADD64: - case FITRIM: break; case OCFS2_IOC_REFLINK: if (copy_from_user(&args, argp, sizeof(args))) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/