All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikulas Patocka <mikulas@twibright.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>, "Ted Ts'o" <tytso@google.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: [PATCH] ioctl_compat: handle FITRIM
Date: Thu, 9 Jul 2015 18:05:15 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.00.1507091803170.13646@leontynka> (raw)
In-Reply-To: <CA+55aFzY9Y8tgrv=HW6Sia_CmgLvn6_pC4MnLQYbmC8Urfbh+Q@mail.gmail.com>



On Sun, 28 Jun 2015, Linus Torvalds wrote:

> On Sun, Jun 28, 2015 at 6:16 AM, Mikulas Patocka <mikulas@twibright.com> 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 <mikulas@twibright.com>

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 <mpatocka@redhat.com>

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

      parent reply	other threads:[~2015-07-09 16:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-28 13:16 [PATCH] hpfs: add fstrim support Mikulas Patocka
2015-06-28 19:52 ` Linus Torvalds
2015-06-28 20:59   ` Al Viro
2015-06-28 21:46     ` Linus Torvalds
2015-07-09 16:05   ` Mikulas Patocka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.1507091803170.13646@leontynka \
    --to=mikulas@twibright.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@google.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.