diff mbox

[v2,20/22] IB/srpt: Log out all initiators if a port is disabled

Message ID 56ABF33C.9030509@sandisk.com (mailing list archive)
State Superseded
Headers show

Commit Message

Bart Van Assche Jan. 29, 2016, 11:18 p.m. UTC
If an initiator observes LUN deletion during shutdown of the
target stack then that will trigger an I/O error even when using
multipathd. Users need a way to avoid that shutting down the
target stack causes I/O errors, e.g. by providing a way to force
initiator logout. Hence close all sessions if a target port is
disabled.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagig@mellanox.com>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

Comments

Christoph Hellwig Feb. 2, 2016, 11:13 a.m. UTC | #1
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Estrin, Alex Feb. 2, 2016, 3:35 p.m. UTC | #2
TG9va3MgZ29vZC4NClJldmlld2VkLWJ5OiBBbGV4IEVzdHJpbiA8YWxleC5lc3RyaW5AaW50ZWwu
Y29tPg0KDQo+IElmIGFuIGluaXRpYXRvciBvYnNlcnZlcyBMVU4gZGVsZXRpb24gZHVyaW5nIHNo
dXRkb3duIG9mIHRoZQ0KPiB0YXJnZXQgc3RhY2sgdGhlbiB0aGF0IHdpbGwgdHJpZ2dlciBhbiBJ
L08gZXJyb3IgZXZlbiB3aGVuIHVzaW5nDQo+IG11bHRpcGF0aGQuIFVzZXJzIG5lZWQgYSB3YXkg
dG8gYXZvaWQgdGhhdCBzaHV0dGluZyBkb3duIHRoZQ0KPiB0YXJnZXQgc3RhY2sgY2F1c2VzIEkv
TyBlcnJvcnMsIGUuZy4gYnkgcHJvdmlkaW5nIGEgd2F5IHRvIGZvcmNlDQo+IGluaXRpYXRvciBs
b2dvdXQuIE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Cj4gKwkJCXNycHRfY2xvc2VfY2goY2gpOw0K
PiArCQl9DQo+ICsJfQ0KPiArCW11dGV4X3VubG9jaygmc2Rldi0+bXV0ZXgpOw0KPiArDQo+ICtv
dXQ6DQo+ICAJcmV0dXJuIGNvdW50Ow0KPiAgfQ0KPiANCj4gLS0NCj4gMi43LjANCg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index a7c966f..d5b932c 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -3157,6 +3157,8 @@  static ssize_t srpt_tpg_enable_store(struct config_item *item,
 {
 	struct se_portal_group *se_tpg = to_tpg(item);
 	struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
+	struct srpt_device *sdev = sport->sdev;
+	struct srpt_rdma_ch *ch;
 	unsigned long tmp;
         int ret;
 
@@ -3170,11 +3172,24 @@  static ssize_t srpt_tpg_enable_store(struct config_item *item,
 		pr_err("Illegal value for srpt_tpg_store_enable: %lu\n", tmp);
 		return -EINVAL;
 	}
-	if (tmp == 1)
-		sport->enabled = true;
-	else
-		sport->enabled = false;
+	if (sport->enabled == tmp)
+		goto out;
+	sport->enabled = tmp;
+	if (sport->enabled)
+		goto out;
 
+	mutex_lock(&sdev->mutex);
+	list_for_each_entry(ch, &sdev->rch_list, list) {
+		if (ch->sport == sport) {
+			pr_debug("%s: ch %p %s-%d\n", __func__, ch,
+				 ch->sess_name, ch->qp->qp_num);
+			srpt_disconnect_ch(ch);
+			srpt_close_ch(ch);
+		}
+	}
+	mutex_unlock(&sdev->mutex);
+
+out:
 	return count;
 }