aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/ub.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/ub.c')
-rw-r--r--drivers/block/ub.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 0536b5b29adc..c48e14878582 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -28,6 +28,7 @@
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/scatterlist.h> 29#include <linux/scatterlist.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/smp_lock.h>
31#include <scsi/scsi.h> 32#include <scsi/scsi.h>
32 33
33#define DRV_NAME "ub" 34#define DRV_NAME "ub"
@@ -648,7 +649,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
648 return 0; 649 return 0;
649 } 650 }
650 651
651 if (lun->changed && !blk_pc_request(rq)) { 652 if (lun->changed && rq->cmd_type != REQ_TYPE_BLOCK_PC) {
652 blk_start_request(rq); 653 blk_start_request(rq);
653 ub_end_rq(rq, SAM_STAT_CHECK_CONDITION); 654 ub_end_rq(rq, SAM_STAT_CHECK_CONDITION);
654 return 0; 655 return 0;
@@ -684,7 +685,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
684 } 685 }
685 urq->nsg = n_elem; 686 urq->nsg = n_elem;
686 687
687 if (blk_pc_request(rq)) { 688 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
688 ub_cmd_build_packet(sc, lun, cmd, urq); 689 ub_cmd_build_packet(sc, lun, cmd, urq);
689 } else { 690 } else {
690 ub_cmd_build_block(sc, lun, cmd, urq); 691 ub_cmd_build_block(sc, lun, cmd, urq);
@@ -781,7 +782,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
781 rq = urq->rq; 782 rq = urq->rq;
782 783
783 if (cmd->error == 0) { 784 if (cmd->error == 0) {
784 if (blk_pc_request(rq)) { 785 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
785 if (cmd->act_len >= rq->resid_len) 786 if (cmd->act_len >= rq->resid_len)
786 rq->resid_len = 0; 787 rq->resid_len = 0;
787 else 788 else
@@ -795,7 +796,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
795 } 796 }
796 } 797 }
797 } else { 798 } else {
798 if (blk_pc_request(rq)) { 799 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
799 /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ 800 /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */
800 memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE); 801 memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE);
801 rq->sense_len = UB_SENSE_SIZE; 802 rq->sense_len = UB_SENSE_SIZE;
@@ -1710,6 +1711,18 @@ err_open:
1710 return rc; 1711 return rc;
1711} 1712}
1712 1713
1714static int ub_bd_unlocked_open(struct block_device *bdev, fmode_t mode)
1715{
1716 int ret;
1717
1718 lock_kernel();
1719 ret = ub_bd_open(bdev, mode);
1720 unlock_kernel();
1721
1722 return ret;
1723}
1724
1725
1713/* 1726/*
1714 */ 1727 */
1715static int ub_bd_release(struct gendisk *disk, fmode_t mode) 1728static int ub_bd_release(struct gendisk *disk, fmode_t mode)
@@ -1717,7 +1730,10 @@ static int ub_bd_release(struct gendisk *disk, fmode_t mode)
1717 struct ub_lun *lun = disk->private_data; 1730 struct ub_lun *lun = disk->private_data;
1718 struct ub_dev *sc = lun->udev; 1731 struct ub_dev *sc = lun->udev;
1719 1732
1733 lock_kernel();
1720 ub_put(sc); 1734 ub_put(sc);
1735 unlock_kernel();
1736
1721 return 0; 1737 return 0;
1722} 1738}
1723 1739
@@ -1729,8 +1745,13 @@ static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode,
1729{ 1745{
1730 struct gendisk *disk = bdev->bd_disk; 1746 struct gendisk *disk = bdev->bd_disk;
1731 void __user *usermem = (void __user *) arg; 1747 void __user *usermem = (void __user *) arg;
1748 int ret;
1749
1750 lock_kernel();
1751 ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem);
1752 unlock_kernel();
1732 1753
1733 return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); 1754 return ret;
1734} 1755}
1735 1756
1736/* 1757/*
@@ -1792,9 +1813,9 @@ static int ub_bd_media_changed(struct gendisk *disk)
1792 1813
1793static const struct block_device_operations ub_bd_fops = { 1814static const struct block_device_operations ub_bd_fops = {
1794 .owner = THIS_MODULE, 1815 .owner = THIS_MODULE,
1795 .open = ub_bd_open, 1816 .open = ub_bd_unlocked_open,
1796 .release = ub_bd_release, 1817 .release = ub_bd_release,
1797 .locked_ioctl = ub_bd_ioctl, 1818 .ioctl = ub_bd_ioctl,
1798 .media_changed = ub_bd_media_changed, 1819 .media_changed = ub_bd_media_changed,
1799 .revalidate_disk = ub_bd_revalidate, 1820 .revalidate_disk = ub_bd_revalidate,
1800}; 1821};