Skip to contentSkip to conversation

SRP implement device_loss_timeout per target

PATCH New Vu Pham 1 participant 1 message Nov 9, 2009

Subsystems (2)
lore
Share & tools
lore

Vu Pham

author
#0 lore raw

PATCH 3/6 SRP implement device_loss_timeout per target

Introducing device_loss_timeout per target granuality.
SRP driver will propagate I/O errors and clean up connection resources after device_loss_timeout expired when local port or target port disconnected from the fabric.

 drivers/infiniband/ulp/srp/ib_srp.c |   12 +++++++++++-
 drivers/infiniband/ulp/srp/ib_srp.h |    1 +
 2 files changed, 12 insertions(+), 1 deletions(-)
drivers/infiniband/ulp/srp/ib_srp.c +11 -1
index e44939a..047d488 100644
@@ -1298,7 +1298,6 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
 	case IB_CM_TIMEWAIT_EXIT:
 		shost_printk(KERN_ERR, target->scsi_host,
 			     PFX "connection closed\n");
-
 		target->status = 0;
 		break;
 
@@ -1657,6 +1656,7 @@ enum {
 	SRP_OPT_MAX_CMD_PER_LUN	= 1 << 6,
 	SRP_OPT_IO_CLASS	= 1 << 7,
 	SRP_OPT_INITIATOR_EXT	= 1 << 8,
+	SRP_OPT_DEVICE_LOSS_TMO	= 1 << 9,
 	SRP_OPT_ALL		= (SRP_OPT_ID_EXT	|
 				   SRP_OPT_IOC_GUID	|
 				   SRP_OPT_DGID		|
@@ -1674,6 +1674,7 @@ static const match_table_t srp_opt_tokens = {
 	{ SRP_OPT_MAX_CMD_PER_LUN,	"max_cmd_per_lun=%d" 	},
 	{ SRP_OPT_IO_CLASS,		"io_class=%x"		},
 	{ SRP_OPT_INITIATOR_EXT,	"initiator_ext=%s"	},
+	{ SRP_OPT_DEVICE_LOSS_TMO,	"device_loss_timeout=%d"},
 	{ SRP_OPT_ERR,			NULL 			}
 };
 
@@ -1801,6 +1802,15 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
 			kfree(p);
 			break;
 
+		case SRP_OPT_DEVICE_LOSS_TMO:
+			if (match_int(args, &token)) {
+				printk(KERN_WARNING PFX "bad device loss timeout '%s'\n", p);
+				goto out;
+			}
+			if (token > 0)
+				target->device_loss_timeout = token;
+			break;
+
 		default:
 			printk(KERN_WARNING PFX "unknown parameter or missing value "
 			       "'%s' in target creation request\n", p);
drivers/infiniband/ulp/srp/ib_srp.h +1 -0
index e185b90..92db025 100644
@@ -159,6 +159,7 @@ struct srp_target_port {
 	int			status;
 	enum srp_target_state	state;
 	int			qp_in_error;
+	int			device_loss_timeout;
 };
 
 struct srp_iu {