sd: fix up ->compat_ioctl
authorChristoph Hellwig <hch@lst.de>
Fri, 24 Oct 2014 16:39:37 +0000 (18:39 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 12 Nov 2014 10:16:11 +0000 (11:16 +0100)
No need to verify the passthrough ioctls, the real handler will
take care of that.  Also make sure not to block for resets on
O_NONBLOCK fds.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
drivers/scsi/sd.c

index ddf763ad3b83d9d753f5553f1c78f5bf31d9561a..b041eca8955d08c1cd3c064423ab5dd105e8972e 100644 (file)
@@ -1541,31 +1541,19 @@ static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode,
                           unsigned int cmd, unsigned long arg)
 {
        struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device;
-       int ret;
-
-       ret = scsi_verify_blk_ioctl(bdev, cmd);
-       if (ret < 0)
-               return ret;
+       int error;
 
-       /*
-        * If we are in the middle of error recovery, don't let anyone
-        * else try and use this device.  Also, if error recovery fails, it
-        * may try and take the device offline, in which case all further
-        * access to the device is prohibited.
-        */
-       if (!scsi_block_when_processing_errors(sdev))
-               return -ENODEV;
+       error = scsi_ioctl_block_when_processing_errors(sdev, cmd,
+                       (mode & FMODE_NDELAY) != 0);
+       if (error)
+               return error;
               
-       if (sdev->host->hostt->compat_ioctl) {
-               ret = sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg);
-
-               return ret;
-       }
-
        /* 
         * Let the static ioctl translation table take care of it.
         */
-       return -ENOIOCTLCMD; 
+       if (!sdev->host->hostt->compat_ioctl)
+               return -ENOIOCTLCMD; 
+       return sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg);
 }
 #endif