block: remove QUEUE_FLAG_SCSI_PASSTHROUGH remove-blk_queue_scsi_passthrough
authorChristoph Hellwig <hch@lst.de>
Mon, 2 Aug 2021 15:55:49 +0000 (17:55 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 20 Oct 2021 17:26:41 +0000 (19:26 +0200)
Export scsi_device_from_queue for use with pktcdvd and use that instead
of the otherwise unused QUEUE_FLAG_SCSI_PASSTHROUGH queue flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
block/blk-mq-debugfs.c
drivers/block/pktcdvd.c
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_scan.c
include/linux/blkdev.h

index 68ca5d21cda778fe638e552f2cf0016d550cba3b..a317f05de466a4e699e8014b3474cc9c9f143305 100644 (file)
@@ -124,7 +124,6 @@ static const char *const blk_queue_flag_name[] = {
        QUEUE_FLAG_NAME(STATS),
        QUEUE_FLAG_NAME(POLL_STATS),
        QUEUE_FLAG_NAME(REGISTERED),
-       QUEUE_FLAG_NAME(SCSI_PASSTHROUGH),
        QUEUE_FLAG_NAME(QUIESCED),
        QUEUE_FLAG_NAME(PCI_P2PDMA),
        QUEUE_FLAG_NAME(ZONE_RESETALL),
index d7d37131ab9dd74f26584668c19600e98a1e600b..d7bcd12394b3c7a113d40f4632fe2d5cff5b3317 100644 (file)
@@ -2536,6 +2536,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
        int i;
        char b[BDEVNAME_SIZE];
        struct block_device *bdev;
+       struct scsi_device *sdev;
 
        if (pd->pkt_dev == dev) {
                pkt_err(pd, "recursive setup not allowed\n");
@@ -2559,10 +2560,12 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
        bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_NDELAY, NULL);
        if (IS_ERR(bdev))
                return PTR_ERR(bdev);
-       if (!blk_queue_scsi_passthrough(bdev_get_queue(bdev))) {
+       sdev = scsi_device_from_queue(bdev->bd_disk->queue);
+       if (!sdev) {
                blkdev_put(bdev, FMODE_READ | FMODE_NDELAY);
                return -EINVAL;
        }
+       put_device(&sdev->sdev_gendev);
 
        /* This is safe, since we have a reference from open(). */
        __module_get(THIS_MODULE);
index a0f801fc8943b4620b562201a5db3a346d9d647a..9823b65d1536886c4ee68a6df286731d361964a7 100644 (file)
@@ -1967,6 +1967,14 @@ struct scsi_device *scsi_device_from_queue(struct request_queue *q)
 
        return sdev;
 }
+/*
+ * pktcdvd should have been integrated into the SCSI layers, but for historical
+ * reasons like the old IDE driver it isn't.  This export allows it to safely
+ * probe if a given device is a SCSI one and only attach to that.
+ */
+#ifdef CONFIG_CDROM_PKTCDVD_MODULE
+EXPORT_SYMBOL_GPL(scsi_device_from_queue);
+#endif
 
 /**
  * scsi_block_requests - Utility function used by low-level drivers to prevent
index fe22191522a3b9e4742c4f59113f84b5d7c00279..2808c0cb5711462cf1201cae3198bae67ee85078 100644 (file)
@@ -280,7 +280,6 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
        sdev->request_queue = q;
        q->queuedata = sdev;
        __scsi_init_queue(sdev->host, q);
-       blk_queue_flag_set(QUEUE_FLAG_SCSI_PASSTHROUGH, q);
        WARN_ON_ONCE(!blk_get_queue(q));
 
        depth = sdev->host->cmd_per_lun ?: 1;
index af61fb3e1502c58c50687df588fe155105cb2f76..558aa7ab4c4c83c9316d503c879e7fcf1d838d2a 100644 (file)
@@ -356,7 +356,6 @@ struct request_queue {
 #define QUEUE_FLAG_STATS       20      /* track IO start and completion times */
 #define QUEUE_FLAG_POLL_STATS  21      /* collecting stats for hybrid polling */
 #define QUEUE_FLAG_REGISTERED  22      /* queue has been registered to a disk */
-#define QUEUE_FLAG_SCSI_PASSTHROUGH 23 /* queue supports SCSI commands */
 #define QUEUE_FLAG_QUIESCED    24      /* queue has been quiesced */
 #define QUEUE_FLAG_PCI_P2PDMA  25      /* device supports PCI p2p requests */
 #define QUEUE_FLAG_ZONE_RESETALL 26    /* supports Zone Reset All */
@@ -390,8 +389,6 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q);
 #define blk_queue_secure_erase(q) \
        (test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags))
 #define blk_queue_dax(q)       test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags)
-#define blk_queue_scsi_passthrough(q)  \
-       test_bit(QUEUE_FLAG_SCSI_PASSTHROUGH, &(q)->queue_flags)
 #define blk_queue_pci_p2pdma(q)        \
        test_bit(QUEUE_FLAG_PCI_P2PDMA, &(q)->queue_flags)
 #ifdef CONFIG_BLK_RQ_ALLOC_TIME