scsi: target: Make the virtual LUN 0 device
authorKonstantin Shelekhin <k.shelekhin@yadro.com>
Mon, 22 Mar 2021 20:09:38 +0000 (23:09 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 6 Apr 2021 03:26:39 +0000 (23:26 -0400)
Create the device for the virtual LUN 0 using the DUMMY flag. This change
makes it possible to remove some special-casing in the INQUIRY code.

Link: https://lore.kernel.org/r/20210322200938.53300-3-k.shelekhin@yadro.com
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_device.c
drivers/target/target_core_spc.c

index 74d3a48..a8df9f0 100644 (file)
@@ -1035,7 +1035,7 @@ int core_dev_setup_virtual_lun0(void)
 {
        struct se_hba *hba;
        struct se_device *dev;
-       char buf[] = "rd_pages=8,rd_nullio=1";
+       char buf[] = "rd_pages=8,rd_nullio=1,rd_dummy=1";
        int ret;
 
        hba = core_alloc_hba("rd_mcp", 0, HBA_FLAGS_INTERNAL_USE);
index ca5579e..70a6618 100644 (file)
@@ -701,7 +701,6 @@ static sense_reason_t
 spc_emulate_inquiry(struct se_cmd *cmd)
 {
        struct se_device *dev = cmd->se_dev;
-       struct se_portal_group *tpg = cmd->se_lun->lun_tpg;
        unsigned char *rbuf;
        unsigned char *cdb = cmd->t_task_cdb;
        unsigned char *buf;
@@ -715,10 +714,7 @@ spc_emulate_inquiry(struct se_cmd *cmd)
                return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
        }
 
-       if (dev == rcu_access_pointer(tpg->tpg_virt_lun0->lun_se_dev))
-               buf[0] = 0x3f; /* Not connected */
-       else
-               buf[0] = dev->transport->get_device_type(dev);
+       buf[0] = dev->transport->get_device_type(dev);
 
        if (!(cdb[1] & 0x1)) {
                if (cdb[2]) {