[PATCH 6/9] fc class: add fc queueing helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mike Christie <michaelc@xxxxxxxxxxx>

Add a queueing helper which will return SCSI_MLQUEUE_TARGET_BUSY
if we are transitioning because there is no need to call into
the driver anymore at that point.

Signed-off-by: Mike Christie <michaelc@xxxxxxxxxxx>
---
 include/scsi/scsi_transport_fc.h |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index 4769efd..62a6a74 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -29,6 +29,7 @@
 
 #include <linux/sched.h>
 #include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_netlink.h>
 
 struct scsi_transport_template;
@@ -640,6 +641,38 @@ struct fc_function_template {
 	unsigned long	disable_target_scan:1;
 };
 
+/**
+ * fc_remote_port_queue_ready - called to validate the remote port state
+ * @rport: remote port to be checked
+ *
+ * Returns 0 if IO can be queued or if there the cmd should be
+ * completed by a call to cmd->scsi_done. Caller must check cmd->result.
+ * Returns SCSI_MLQUEUE value if IO cannot be queued temporarily.
+ **/
+static inline int
+fc_remote_port_queue_ready(struct fc_rport *rport, struct scsi_cmnd *cmd)
+{
+	int result = 0;
+
+	cmd->result = 0;
+	switch (rport->port_state) {
+	case FC_PORTSTATE_ONLINE:
+		if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
+			result = 0;
+		else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
+			result = SCSI_MLQUEUE_TARGET_BUSY;
+		else
+			cmd->result = DID_NO_CONNECT << 16;
+		break;
+	case FC_PORTSTATE_BLOCKED:
+		result = SCSI_MLQUEUE_TARGET_BUSY;
+		break;
+	default:
+		cmd->result = DID_NO_CONNECT << 16;
+		break;
+	}
+	return result;
+}
 
 /**
  * fc_remote_port_chkready - called to validate the remote port state
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux