Skip to contentSkip to conversation

ibmvscsis: Initial IBM vSCSI Target merge for v3.2-rc1

PATCH Superseded Nicholas A. Bellinger 2 participants 3 messages Oct 14, 2011 – Oct 22, 2011

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ibmvscsis: Initial IBM vSCSI Target merge for v3.2-rc1

From: FUJITA Tomonori <[email protected]>

Hello Brian, Tomo-san & Co,

This patch contains the forth version for an initial merge of the tcm ibmvscsis driver for v3.2-rc1. More information on this driver can be found here:

http://www.linux-iscsi.org/wiki/IBM_vSCSI
http://www.linux-iscsi.org/wiki/IBM_vSCSI/configFS

The changes are:
v4:
- Remove TCM v4.0 legacy ibmvscsis_pack_lun() usage
- Remove TCM v4.0 legacy SCF_SCSI_CONTROL_NONSG_IO_CDB +

    se_cmd->t_task usage

- Updated to use TCM v4.1 infrastructure code
v3:
- fix task attribute (convert MSG_* to TASK_ATTR_*)
v2:
- send VIOSRP_MAD_NOT_SUPPORTED for unknown mad type requests.
- fix inquiry typo
- sends task management response (for now, 'NOT SUPPORTED').
- remove dead code.

This replaces ibmvstgt driver that uses the old target framework.

Note that this patch currently depends upon the target-core series for v3.2-rc1 currently in the queue, and will need to be merged ahead of this patch.

[PATCH 00/37] target: Updates for v3.2-rc1 (round one)
http://marc.info/?l=linux-scsi&m=131855299419466&w=2

This driver has been compile tested and loaded on pSeries hardware running lio-core-2.6.git @ 3.1.0-rc8. Please have a look and consider signing-off for a v3.2-rc1 mainline merge.

Thank you,

--nab

Cc FUJITA Tomonori <[email protected]>
Cc Brian King <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc James Bottomley <[email protected]>
---
 drivers/scsi/ibmvscsi/Makefile    |    4 +-
 drivers/scsi/ibmvscsi/ibmvscsis.c | 1731 +++++++++++++++++++++++++++++++++++++
 2 files changed, 1734 insertions(+), 1 deletions(-)
 create mode 100644 drivers/scsi/ibmvscsi/ibmvscsis.c
drivers/scsi/ibmvscsi/Makefile +3 -1
index a423d96..a615ea5 100644
@@ -1,8 +1,10 @@
+EXTRA_CFLAGS += -I$(srctree)/drivers/target/
+
 obj-$(CONFIG_SCSI_IBMVSCSI)	+= ibmvscsic.o
 
 ibmvscsic-y			+= ibmvscsi.o
 ibmvscsic-$(CONFIG_PPC_ISERIES)	+= iseries_vscsi.o 
 ibmvscsic-$(CONFIG_PPC_PSERIES)	+= rpa_vscsi.o 
 
-obj-$(CONFIG_SCSI_IBMVSCSIS)	+= ibmvstgt.o
+obj-$(CONFIG_SCSI_IBMVSCSIS)	+= ibmvscsis.o
 obj-$(CONFIG_SCSI_IBMVFC)	+= ibmvfc.o
drivers/scsi/ibmvscsi/ibmvscsis.c new file +1731 -0

1,731 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#1 lore raw

This needs a patch like the one below folded in. In addition to not unessecarily offload new command mapping to the fabric thread this also fixes the currenly incorrect (outdated) handling of the return values from transport_generic_allocate_tasks. I don't even have a ppc compiler at hand right now, so handle it with care.

---
From: Christoph Hellwig <[email protected]>
Subject: ibmvscsis: do not offload new command processing to the fabric thread

tcm_queuecommand is always called from process context, so prepare the command in-process instead of offloading it.

drivers/scsi/ibmvscsi/ibmvscsis.c +23 -35
Index: lio-core/drivers/scsi/ibmvscsi/ibmvscsis.c
===================================================================
@@ -424,7 +424,6 @@ static struct configfs_attribute *ibmvsc
 static int ibmvscsis_write_pending(struct se_cmd *se_cmd);
 static int ibmvscsis_queue_data_in(struct se_cmd *se_cmd);
 static int ibmvscsis_queue_status(struct se_cmd *se_cmd);
-static int ibmvscsis_new_cmd_map(struct se_cmd *se_cmd);
 static void ibmvscsis_check_stop_free(struct se_cmd *se_cmd);
 
 static struct target_core_fabric_ops ibmvscsis_ops = {
@@ -444,7 +443,6 @@ static struct target_core_fabric_ops ibm
 	.tpg_alloc_fabric_acl		= ibmvscsis_alloc_fabric_acl,
 	.tpg_release_fabric_acl		= ibmvscsis_release_fabric_acl,
 	.tpg_get_inst_index		= ibmvscsis_tpg_get_inst_index,
-	.new_cmd_map			= ibmvscsis_new_cmd_map,
 	.check_stop_free		= ibmvscsis_check_stop_free,
 	.release_cmd			= ibmvscsis_release_cmd,
 	.shutdown_session		= ibmvscsis_shutdown_session,
@@ -839,8 +837,11 @@ static inline struct viosrp_crq *next_cr
 
 static int tcm_queuecommand(struct ibmvscsis_adapter *adapter,
 			    struct ibmvscsis_cmnd *vsc,
-			    struct srp_cmd *cmd)
+			    struct srp_cmd *scmd)
 {
+	struct scsi_cmnd *sc = &vsc->sc;
+	struct iu_entry *iue = (struct iu_entry *)sc->SCp.ptr;
+
 	struct se_cmd *se_cmd;
 	int attr;
 	int data_len;
@@ -858,63 +859,50 @@ static int tcm_queuecommand(struct ibmvs
 		break;
 	default:
 		printk(KERN_WARNING "Task attribute %d not supported\n",
-		       cmd->task_attr);
+		       scmd->task_attr);
 		attr = MSG_SIMPLE_TAG;
 	}
 
-	data_len = srp_data_length(cmd, srp_cmd_direction(cmd));
+	data_len = srp_data_length(scmd, srp_cmd_direction(scmd));
 
 	se_cmd = &vsc->se_cmd;
 
 	transport_init_se_cmd(se_cmd,
 			      adapter->se_tpg.se_tpg_tfo,
 			      adapter->se_sess, data_len,
-			      srp_cmd_direction(cmd),
+			      srp_cmd_direction(scmd),
 			      attr, vsc->sense_buf);
 
-	ret = transport_lookup_cmd_lun(se_cmd, cmd->lun);
+	ret = transport_lookup_cmd_lun(se_cmd, scmd->lun);
 	if (ret) {
-		printk(KERN_ERR "invalid lun %u\n", GETLUN(cmd->lun));
+		printk(KERN_ERR "invalid lun %u\n", GETLUN(scmd->lun));
 		transport_send_check_condition_and_sense(se_cmd,
 							 se_cmd->scsi_sense_reason,
 							 0);
 		return ret;
 	}
 
-	transport_generic_handle_cdb_map(se_cmd);
-
-	return 0;
-}
-
-static int ibmvscsis_new_cmd_map(struct se_cmd *se_cmd)
-{
-	struct ibmvscsis_cmnd *cmd =
-		container_of(se_cmd, struct ibmvscsis_cmnd, se_cmd);
-	struct scsi_cmnd *sc = &cmd->sc;
-	struct iu_entry *iue = (struct iu_entry *)sc->SCp.ptr;
-	struct srp_cmd *scmd = iue->sbuf->buf;
-	int ret;
-
 	/*
 	 * Allocate the necessary tasks to complete the received CDB+data
 	 */
 	ret = transport_generic_allocate_tasks(se_cmd, scmd->cdb);
-	if (ret == -1) {
-		/* Out of Resources */
-		return PYX_TRANSPORT_LU_COMM_FAILURE;
-	} else if (ret == -2) {
-		/*
-		 * Handle case for SAM_STAT_RESERVATION_CONFLICT
-		 */
+	if (ret == -ENOMEM) {
+		transport_send_check_condition_and_sense(se_cmd,
+				TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
+		transport_generic_free_cmd(se_cmd, 0);
+		return;
+	}
+	if (ret == -EINVAL) {
 		if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT)
-			return PYX_TRANSPORT_RESERVATION_CONFLICT;
-		/*
-		 * Otherwise, return SAM_STAT_CHECK_CONDITION and return
-		 * sense data
-		 */
-		return PYX_TRANSPORT_USE_SENSE_REASON;
+			ibmvscsis_queue_status(se_cmd);
+		else
+			transport_send_check_condition_and_sense(se_cmd,
+					se_cmd->scsi_sense_reason, 0);
+		transport_generic_free_cmd(se_cmd, 0);
+		return;
 	}
 
+	transport_handle_cdb_direct(se_cmd);
 	return 0;
 }
 
#2 lore raw
Quoted 6 lines · Christoph Hellwig

This needs a patch like the one below folded in. In addition to not unessecarily offload new command mapping to the fabric thread this also fixes the currenly incorrect (outdated) handling of the return values from transport_generic_allocate_tasks. I don't even have a ppc compiler at hand right now, so handle it with care.

Quoted 8 lines

---
From: Christoph Hellwig <[email protected]>
Subject: ibmvscsis: do not offload new command processing to the fabric thread

tcm_queuecommand is always called from process context, so prepare the command in-process instead of offloading it.

Hi Christoph,

Fixed some minor compile breakage with this patch. Aside from that, I think it looks like a reasonably safe conversion to perform the necessary setup in tcm_queuecommand() process context instead of the extra context switch into transport_generic_handle_cdb_map().

I've not heard Tomo-san or BR-King feedback on this for a v3.2 merge yet, but will respin with this change included for them to review again for next week.

Thanks,

--nab