aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2013-10-26 08:33:30 -0400
committerRoland Dreier <roland@purestorage.com>2013-11-08 17:43:15 -0500
commit29c17324803c8a3bb5b2b69309e43571164cc4de (patch)
tree93279b89d0b16228eccd2dc5f1d2b29c17c4e3af /include/scsi
parent9dd69a600a680fab1c9235a644c886d8d6a2da2a (diff)
scsi_transport_srp: Add transport layer error handling
Add the necessary functions in the SRP transport module to allow an SRP initiator driver to implement transport layer error handling similar to the functionality already provided by the FC transport layer. This includes: - Support for implementing fast_io_fail_tmo, the time that should elapse after having detected a transport layer problem and before failing I/O. - Support for implementing dev_loss_tmo, the time that should elapse after having detected a transport layer problem and before removing a remote port. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Acked-by: David Dillow <dillowda@ornl.gov> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/scsi_transport_srp.h74
1 files changed, 72 insertions, 2 deletions
diff --git a/include/scsi/scsi_transport_srp.h b/include/scsi/scsi_transport_srp.h
index 5a2d2d1081c1..ee7001677f64 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -13,6 +13,26 @@ struct srp_rport_identifiers {
13 u8 roles; 13 u8 roles;
14}; 14};
15 15
16/**
17 * enum srp_rport_state - SRP transport layer state
18 * @SRP_RPORT_RUNNING: Transport layer operational.
19 * @SRP_RPORT_BLOCKED: Transport layer not operational; fast I/O fail timer
20 * is running and I/O has been blocked.
21 * @SRP_RPORT_FAIL_FAST: Fast I/O fail timer has expired; fail I/O fast.
22 * @SRP_RPORT_LOST: Device loss timer has expired; port is being removed.
23 */
24enum srp_rport_state {
25 SRP_RPORT_RUNNING,
26 SRP_RPORT_BLOCKED,
27 SRP_RPORT_FAIL_FAST,
28 SRP_RPORT_LOST,
29};
30
31/**
32 * struct srp_rport
33 * @lld_data: LLD private data.
34 * @mutex: Protects against concurrent rport fast_io_fail / dev_loss_tmo.
35 */
16struct srp_rport { 36struct srp_rport {
17 /* for initiator and target drivers */ 37 /* for initiator and target drivers */
18 38
@@ -23,11 +43,38 @@ struct srp_rport {
23 43
24 /* for initiator drivers */ 44 /* for initiator drivers */
25 45
26 void *lld_data; /* LLD private data */ 46 void *lld_data;
47
48 struct mutex mutex;
49 enum srp_rport_state state;
50 bool deleted;
51 int fast_io_fail_tmo;
52 int dev_loss_tmo;
53 struct delayed_work fast_io_fail_work;
54 struct delayed_work dev_loss_work;
27}; 55};
28 56
57/**
58 * struct srp_function_template
59 * @has_rport_state: Whether or not to create the state, fast_io_fail_tmo and
60 * dev_loss_tmo sysfs attribute for an rport.
61 * @reset_timer_if_blocked: Whether or srp_timed_out() should reset the command
62 * timer if the device on which it has been queued is blocked.
63 * @fast_io_fail_tmo: If not NULL, points to the default fast_io_fail_tmo value.
64 * @dev_loss_tmo: If not NULL, points to the default dev_loss_tmo value.
65 * @reconnect: Callback function for reconnecting to the target. See also
66 * srp_reconnect_rport().
67 * @terminate_rport_io: Callback function for terminating all outstanding I/O
68 * requests for an rport.
69 */
29struct srp_function_template { 70struct srp_function_template {
30 /* for initiator drivers */ 71 /* for initiator drivers */
72 bool has_rport_state;
73 bool reset_timer_if_blocked;
74 int *fast_io_fail_tmo;
75 int *dev_loss_tmo;
76 int (*reconnect)(struct srp_rport *rport);
77 void (*terminate_rport_io)(struct srp_rport *rport);
31 void (*rport_delete)(struct srp_rport *rport); 78 void (*rport_delete)(struct srp_rport *rport);
32 /* for target drivers */ 79 /* for target drivers */
33 int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int); 80 int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int);
@@ -43,7 +90,30 @@ extern void srp_rport_put(struct srp_rport *rport);
43extern struct srp_rport *srp_rport_add(struct Scsi_Host *, 90extern struct srp_rport *srp_rport_add(struct Scsi_Host *,
44 struct srp_rport_identifiers *); 91 struct srp_rport_identifiers *);
45extern void srp_rport_del(struct srp_rport *); 92extern void srp_rport_del(struct srp_rport *);
46 93extern int srp_tmo_valid(int fast_io_fail_tmo, int dev_loss_tmo);
94extern int srp_reconnect_rport(struct srp_rport *rport);
95extern void srp_start_tl_fail_timers(struct srp_rport *rport);
47extern void srp_remove_host(struct Scsi_Host *); 96extern void srp_remove_host(struct Scsi_Host *);
48 97
98/**
99 * srp_chkready() - evaluate the transport layer state before I/O
100 *
101 * Returns a SCSI result code that can be returned by the LLD queuecommand()
102 * implementation. The role of this function is similar to that of
103 * fc_remote_port_chkready().
104 */
105static inline int srp_chkready(struct srp_rport *rport)
106{
107 switch (rport->state) {
108 case SRP_RPORT_RUNNING:
109 case SRP_RPORT_BLOCKED:
110 default:
111 return 0;
112 case SRP_RPORT_FAIL_FAST:
113 return DID_TRANSPORT_FAILFAST << 16;
114 case SRP_RPORT_LOST:
115 return DID_NO_CONNECT << 16;
116 }
117}
118
49#endif 119#endif