public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: target-devel <target-devel@vger.kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	Brian King <brking@linux.vnet.ibm.com>,
	Christoph Hellwig <hch@lst.de>,
	James Bottomley <JBottomley@Parallels.com>
Subject: Re: [PATCH] ibmvscsis: Initial IBM vSCSI Target merge for v3.2-rc1
Date: Tue, 18 Oct 2011 11:08:49 +0200	[thread overview]
Message-ID: <20111018090849.GA22131@lst.de> (raw)
In-Reply-To: <1318585132-3618-1-git-send-email-nab@linux-iscsi.org>

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 <hch@lst.de>
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.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: lio-core/drivers/scsi/ibmvscsi/ibmvscsis.c
===================================================================
--- lio-core.orig/drivers/scsi/ibmvscsi/ibmvscsis.c	2011-10-14 14:06:51.440394983 +0200
+++ lio-core/drivers/scsi/ibmvscsi/ibmvscsis.c	2011-10-14 14:07:06.072895825 +0200
@@ -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;
 }
 

  reply	other threads:[~2011-10-18  9:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-14  9:38 [PATCH] ibmvscsis: Initial IBM vSCSI Target merge for v3.2-rc1 Nicholas A. Bellinger
2011-10-18  9:08 ` Christoph Hellwig [this message]
2011-10-22  7:25   ` Nicholas A. Bellinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111018090849.GA22131@lst.de \
    --to=hch@lst.de \
    --cc=JBottomley@Parallels.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox