diff options
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 7c4d2e68df1c..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 | **/ |
612 | static int sd_open(struct inode *inode, struct file *filp) | 612 | static 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_flags & O_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 | **/ |
687 | static int sd_release(struct inode *inode, struct file *filp) | 684 | static 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 | **/ |
746 | static int sd_ioctl(struct inode * inode, struct file * filp, | 742 | static 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; |
@@ -761,7 +756,8 @@ static int sd_ioctl(struct inode * inode, struct file * filp, | |||
761 | * may try and take the device offline, in which case all further | 756 | * may try and take the device offline, in which case all further |
762 | * access to the device is prohibited. | 757 | * access to the device is prohibited. |
763 | */ | 758 | */ |
764 | error = scsi_nonblockable_ioctl(sdp, cmd, p, filp); | 759 | error = scsi_nonblockable_ioctl(sdp, cmd, p, |
760 | (mode & FMODE_NDELAY_NOW) != 0); | ||
765 | if (!scsi_block_when_processing_errors(sdp) || !error) | 761 | if (!scsi_block_when_processing_errors(sdp) || !error) |
766 | return error; | 762 | return error; |
767 | 763 | ||
@@ -775,7 +771,7 @@ static int sd_ioctl(struct inode * inode, struct file * filp, | |||
775 | case SCSI_IOCTL_GET_BUS_NUMBER: | 771 | case SCSI_IOCTL_GET_BUS_NUMBER: |
776 | return scsi_ioctl(sdp, cmd, p); | 772 | return scsi_ioctl(sdp, cmd, p); |
777 | default: | 773 | default: |
778 | error = scsi_cmd_ioctl(filp, disk->queue, disk, cmd, p); | 774 | error = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, p); |
779 | if (error != -ENOTTY) | 775 | if (error != -ENOTTY) |
780 | return error; | 776 | return error; |
781 | } | 777 | } |
@@ -928,11 +924,10 @@ static void sd_rescan(struct device *dev) | |||
928 | * This gets directly called from VFS. When the ioctl | 924 | * This gets directly called from VFS. When the ioctl |
929 | * is not recognized we go back to the other translation paths. | 925 | * is not recognized we go back to the other translation paths. |
930 | */ | 926 | */ |
931 | static long sd_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 927 | static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode, |
928 | unsigned int cmd, unsigned long arg) | ||
932 | { | 929 | { |
933 | struct block_device *bdev = file->f_path.dentry->d_inode->i_bdev; | 930 | struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device; |
934 | struct gendisk *disk = bdev->bd_disk; | ||
935 | struct scsi_device *sdev = scsi_disk(disk)->device; | ||
936 | 931 | ||
937 | /* | 932 | /* |
938 | * 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,7 +957,7 @@ static struct block_device_operations sd_fops = { | |||
962 | .owner = THIS_MODULE, | 957 | .owner = THIS_MODULE, |
963 | .open = sd_open, | 958 | .open = sd_open, |
964 | .release = sd_release, | 959 | .release = sd_release, |
965 | .ioctl = sd_ioctl, | 960 | .locked_ioctl = sd_ioctl, |
966 | .getgeo = sd_getgeo, | 961 | .getgeo = sd_getgeo, |
967 | #ifdef CONFIG_COMPAT | 962 | #ifdef CONFIG_COMPAT |
968 | .compat_ioctl = sd_compat_ioctl, | 963 | .compat_ioctl = sd_compat_ioctl, |