sr: remove cd->lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cd->lock is taken in sr_block_open, sr_block_release and sr_block_ioctl.
->open and ->release are synchronized by the block layer open_mutex,
and ->ioctl can only be called on live files and thus block devices.

So there is nothing that is actually protected by this lock, but on the
other hand it causes deadlocks when hot removing sr devices due to
the door locking called from cdrom_release.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 drivers/scsi/sr.c | 14 +-------------
 drivers/scsi/sr.h |  1 -
 2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 198bec87bb8e7c..cb89f7afc284e9 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -500,9 +500,7 @@ static int sr_block_open(struct gendisk *disk, blk_mode_t mode)
 			goto out;
 	}
 
-	mutex_lock(&cd->lock);
 	ret = cdrom_open(&cd->cdi, mode);
-	mutex_unlock(&cd->lock);
 out:
 	scsi_autopm_put_device(sdev);
 	if (ret)
@@ -514,10 +512,7 @@ static void sr_block_release(struct gendisk *disk)
 {
 	struct scsi_cd *cd = scsi_cd(disk);
 
-	mutex_lock(&cd->lock);
 	cdrom_release(&cd->cdi);
-	mutex_unlock(&cd->lock);
-
 	scsi_device_put(cd->device);
 }
 
@@ -532,12 +527,10 @@ static int sr_block_ioctl(struct block_device *bdev, blk_mode_t mode,
 	if (bdev_is_partition(bdev) && !capable(CAP_SYS_RAWIO))
 		return -ENOIOCTLCMD;
 
-	mutex_lock(&cd->lock);
-
 	ret = scsi_ioctl_block_when_processing_errors(sdev, cmd,
 			(mode & BLK_OPEN_NDELAY));
 	if (ret)
-		goto out;
+		return ret;
 
 	scsi_autopm_get_device(sdev);
 
@@ -550,8 +543,6 @@ static int sr_block_ioctl(struct block_device *bdev, blk_mode_t mode,
 
 put:
 	scsi_autopm_put_device(sdev);
-out:
-	mutex_unlock(&cd->lock);
 	return ret;
 }
 
@@ -574,7 +565,6 @@ static void sr_free_disk(struct gendisk *disk)
 	spin_unlock(&sr_index_lock);
 
 	unregister_cdrom(&cd->cdi);
-	mutex_destroy(&cd->lock);
 	kfree(cd);
 }
 
@@ -629,7 +619,6 @@ static int sr_probe(struct device *dev)
 					   &sr_bio_compl_lkclass);
 	if (!disk)
 		goto fail_free;
-	mutex_init(&cd->lock);
 
 	spin_lock(&sr_index_lock);
 	minor = find_first_zero_bit(sr_index_bits, SR_DISKS);
@@ -710,7 +699,6 @@ static int sr_probe(struct device *dev)
 	spin_unlock(&sr_index_lock);
 fail_put:
 	put_disk(disk);
-	mutex_destroy(&cd->lock);
 fail_free:
 	kfree(cd);
 fail:
diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h
index dc899277b3a441..98e881775aa591 100644
--- a/drivers/scsi/sr.h
+++ b/drivers/scsi/sr.h
@@ -49,7 +49,6 @@ typedef struct scsi_cd {
 	bool ignore_get_event:1;	/* GET_EVENT is unreliable, use TUR */
 
 	struct cdrom_device_info cdi;
-	struct mutex lock;
 	struct gendisk *disk;
 } Scsi_CD;
 
-- 
2.45.2





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux