Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / drivers / target / target_core_pscsi.c
index 099c59d31b1f54c1b5afe7201ffbf63ac31811bb..6e32ff6f2fa0ce4ead43073d87bedc77d3ffee2c 100644 (file)
@@ -55,6 +55,7 @@
 
 static struct se_subsystem_api pscsi_template;
 
+static int pscsi_execute_cmd(struct se_cmd *cmd);
 static void pscsi_req_done(struct request *, int);
 
 /*     pscsi_attach_hba():
@@ -1022,6 +1023,30 @@ fail:
        return -ENOMEM;
 }
 
+/*
+ * Clear a lun set in the cdb if the initiator talking to use spoke
+ * and old standards version, as we can't assume the underlying device
+ * won't choke up on it.
+ */
+static inline void pscsi_clear_cdb_lun(unsigned char *cdb)
+{
+       switch (cdb[0]) {
+       case READ_10: /* SBC - RDProtect */
+       case READ_12: /* SBC - RDProtect */
+       case READ_16: /* SBC - RDProtect */
+       case SEND_DIAGNOSTIC: /* SPC - SELF-TEST Code */
+       case VERIFY: /* SBC - VRProtect */
+       case VERIFY_16: /* SBC - VRProtect */
+       case WRITE_VERIFY: /* SBC - VRProtect */
+       case WRITE_VERIFY_12: /* SBC - VRProtect */
+       case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */
+               break;
+       default:
+               cdb[1] &= 0x1f; /* clear logical unit number */
+               break;
+       }
+}
+
 static int pscsi_parse_cdb(struct se_cmd *cmd)
 {
        unsigned char *cdb = cmd->t_task_cdb;
@@ -1034,19 +1059,15 @@ static int pscsi_parse_cdb(struct se_cmd *cmd)
                return -EINVAL;
        }
 
+       pscsi_clear_cdb_lun(cdb);
+
        /*
-        * For REPORT LUNS we always need to emulate the respone, and for everything
-        * related to persistent reservations and ALUA we might optionally use our
-        * handlers before passing on the command to the physical hardware.
+        * For REPORT LUNS we always need to emulate the response, for everything
+        * else the default for pSCSI is to pass the command to the underlying
+        * LLD / physical hardware.
         */
        switch (cdb[0]) {
        case REPORT_LUNS:
-       case PERSISTENT_RESERVE_IN:
-       case PERSISTENT_RESERVE_OUT:
-       case RELEASE:
-       case RELEASE_10:
-       case RESERVE:
-       case RESERVE_10:
                ret = spc_parse_cdb(cmd, &dummy_size);
                if (ret)
                        return ret;
@@ -1061,17 +1082,20 @@ static int pscsi_parse_cdb(struct se_cmd *cmd)
        case WRITE_16:
        case WRITE_VERIFY:
                cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
-               break;
+               /* FALLTHROUGH*/
        default:
+               cmd->execute_cmd = pscsi_execute_cmd;
                break;
        }
 
        return 0;
 }
 
-static int pscsi_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl,
-               u32 sgl_nents, enum dma_data_direction data_direction)
+static int pscsi_execute_cmd(struct se_cmd *cmd)
 {
+       struct scatterlist *sgl = cmd->t_data_sg;
+       u32 sgl_nents = cmd->t_data_nents;
+       enum dma_data_direction data_direction = cmd->data_direction;
        struct pscsi_dev_virt *pdv = cmd->se_dev->dev_ptr;
        struct pscsi_plugin_task *pt;
        struct request *req;
@@ -1239,7 +1263,6 @@ static struct se_subsystem_api pscsi_template = {
        .free_device            = pscsi_free_device,
        .transport_complete     = pscsi_transport_complete,
        .parse_cdb              = pscsi_parse_cdb,
-       .execute_cmd            = pscsi_execute_cmd,
        .check_configfs_dev_params = pscsi_check_configfs_dev_params,
        .set_configfs_dev_params = pscsi_set_configfs_dev_params,
        .show_configfs_dev_params = pscsi_show_configfs_dev_params,
This page took 0.026045 seconds and 5 git commands to generate.