aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/sd.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c8b95e8d2859..43f34c73df12 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -609,17 +609,15 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
609 * In the latter case @inode and @filp carry an abridged amount 609 * In the latter case @inode and @filp carry an abridged amount
610 * of information as noted above. 610 * of information as noted above.
611 **/ 611 **/
612static int sd_open(struct inode *inode, struct file *filp) 612static int sd_open(struct block_device *bdev, fmode_t mode)
613{ 613{
614 struct gendisk *disk = inode->i_bdev->bd_disk; 614 struct scsi_disk *sdkp = scsi_disk_get(bdev->bd_disk);
615 struct scsi_disk *sdkp;
616 struct scsi_device *sdev; 615 struct scsi_device *sdev;
617 int retval; 616 int retval;
618 617
619 if (!(sdkp = scsi_disk_get(disk))) 618 if (!sdkp)
620 return -ENXIO; 619 return -ENXIO;
621 620
622
623 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n")); 621 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n"));
624 622
625 sdev = sdkp->device; 623 sdev = sdkp->device;
@@ -633,14 +631,13 @@ static int sd_open(struct inode *inode, struct file *filp)
633 goto error_out; 631 goto error_out;
634 632
635 if (sdev->removable || sdkp->write_prot) 633 if (sdev->removable || sdkp->write_prot)
636 check_disk_change(inode->i_bdev); 634 check_disk_change(bdev);
637 635
638 /* 636 /*
639 * If the drive is empty, just let the open fail. 637 * If the drive is empty, just let the open fail.
640 */ 638 */
641 retval = -ENOMEDIUM; 639 retval = -ENOMEDIUM;
642 if (sdev->removable && !sdkp->media_present && 640 if (sdev->removable && !sdkp->media_present && !(mode & FMODE_NDELAY))
643 !(filp->f_mode & FMODE_NDELAY))
644 goto error_out; 641 goto error_out;
645 642
646 /* 643 /*
@@ -648,7 +645,7 @@ static int sd_open(struct inode *inode, struct file *filp)
648 * if the user expects to be able to write to the thing. 645 * if the user expects to be able to write to the thing.
649 */ 646 */
650 retval = -EROFS; 647 retval = -EROFS;
651 if (sdkp->write_prot && (filp->f_mode & FMODE_WRITE)) 648 if (sdkp->write_prot && (mode & FMODE_WRITE))
652 goto error_out; 649 goto error_out;
653 650
654 /* 651 /*
@@ -684,9 +681,8 @@ error_out:
684 * Note: may block (uninterruptible) if error recovery is underway 681 * Note: may block (uninterruptible) if error recovery is underway
685 * on this disk. 682 * on this disk.
686 **/ 683 **/
687static int sd_release(struct inode *inode, struct file *filp) 684static int sd_release(struct gendisk *disk, fmode_t mode)
688{ 685{
689 struct gendisk *disk = inode->i_bdev->bd_disk;
690 struct scsi_disk *sdkp = scsi_disk(disk); 686 struct scsi_disk *sdkp = scsi_disk(disk);
691 struct scsi_device *sdev = sdkp->device; 687 struct scsi_device *sdev = sdkp->device;
692 688
@@ -743,10 +739,9 @@ static int sd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
743 * Note: most ioctls are forward onto the block subsystem or further 739 * Note: most ioctls are forward onto the block subsystem or further
744 * down in the scsi subsystem. 740 * down in the scsi subsystem.
745 **/ 741 **/
746static int sd_ioctl(struct inode * inode, struct file * filp, 742static int sd_ioctl(struct block_device *bdev, fmode_t mode,
747 unsigned int cmd, unsigned long arg) 743 unsigned int cmd, unsigned long arg)
748{ 744{
749 struct block_device *bdev = inode->i_bdev;
750 struct gendisk *disk = bdev->bd_disk; 745 struct gendisk *disk = bdev->bd_disk;
751 struct scsi_device *sdp = scsi_disk(disk)->device; 746 struct scsi_device *sdp = scsi_disk(disk)->device;
752 void __user *p = (void __user *)arg; 747 void __user *p = (void __user *)arg;
@@ -762,7 +757,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
762 * access to the device is prohibited. 757 * access to the device is prohibited.
763 */ 758 */
764 error = scsi_nonblockable_ioctl(sdp, cmd, p, 759 error = scsi_nonblockable_ioctl(sdp, cmd, p,
765 filp ? filp->f_flags & O_NDELAY : 0); 760 (mode & FMODE_NDELAY_NOW) != 0);
766 if (!scsi_block_when_processing_errors(sdp) || !error) 761 if (!scsi_block_when_processing_errors(sdp) || !error)
767 return error; 762 return error;
768 763
@@ -776,8 +771,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp,
776 case SCSI_IOCTL_GET_BUS_NUMBER: 771 case SCSI_IOCTL_GET_BUS_NUMBER:
777 return scsi_ioctl(sdp, cmd, p); 772 return scsi_ioctl(sdp, cmd, p);
778 default: 773 default:
779 error = scsi_cmd_ioctl(disk->queue, disk, 774 error = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, p);
780 filp ? filp->f_mode : 0, cmd, p);
781 if (error != -ENOTTY) 775 if (error != -ENOTTY)
782 return error; 776 return error;
783 } 777 }
@@ -930,11 +924,10 @@ static void sd_rescan(struct device *dev)
930 * This gets directly called from VFS. When the ioctl 924 * This gets directly called from VFS. When the ioctl
931 * is not recognized we go back to the other translation paths. 925 * is not recognized we go back to the other translation paths.
932 */ 926 */
933static long sd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 927static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode,
928 unsigned int cmd, unsigned long arg)
934{ 929{
935 struct block_device *bdev = file->f_path.dentry->d_inode->i_bdev; 930 struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device;
936 struct gendisk *disk = bdev->bd_disk;
937 struct scsi_device *sdev = scsi_disk(disk)->device;
938 931
939 /* 932 /*
940 * If we are in the middle of error recovery, don't let anyone 933 * If we are in the middle of error recovery, don't let anyone
@@ -962,12 +955,12 @@ static long sd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
962 955
963static struct block_device_operations sd_fops = { 956static struct block_device_operations sd_fops = {
964 .owner = THIS_MODULE, 957 .owner = THIS_MODULE,
965 .__open = sd_open, 958 .open = sd_open,
966 .__release = sd_release, 959 .release = sd_release,
967 .__ioctl = sd_ioctl, 960 .locked_ioctl = sd_ioctl,
968 .getgeo = sd_getgeo, 961 .getgeo = sd_getgeo,
969#ifdef CONFIG_COMPAT 962#ifdef CONFIG_COMPAT
970 .__compat_ioctl = sd_compat_ioctl, 963 .compat_ioctl = sd_compat_ioctl,
971#endif 964#endif
972 .media_changed = sd_media_changed, 965 .media_changed = sd_media_changed,
973 .revalidate_disk = sd_revalidate_disk, 966 .revalidate_disk = sd_revalidate_disk,