* [PATCH 09/15] srp_transport: Fix atttribute registration
2012-03-25 14:45 [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
@ 2012-03-25 14:57 ` Bart Van Assche
2012-03-25 14:58 ` [PATCH 10/15] srp_transport: Simplify attribute initialization code Bart Van Assche
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2012-03-25 14:57 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
Cc: dillowda-1Heg1YXhbW8, roland-BHEL68pLQRGGvPXPguhicg,
fujita.tomonori-Zyj7fXuS5i5L9jVzuh4AOg,
brking-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
Register transport attributes after the attribute array has been
set up instead of before. The current code can trigger a race
condition because the code reading the attribute array can run
on another thread than the code that initialized that array.
Make sure that any code reading the attribute array will see all
values written into that array.
Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: FUJITA Tomonori <fujita.tomonori-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
Cc: Brian King <brking-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: David Dillow <dillowda-1Heg1YXhbW8@public.gmane.org>
Cc: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Cc: <stable-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
drivers/scsi/scsi_transport_srp.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 21a045e..07c4394 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -324,13 +324,14 @@ srp_attach_transport(struct srp_function_template *ft)
i->rport_attr_cont.ac.attrs = &i->rport_attrs[0];
i->rport_attr_cont.ac.class = &srp_rport_class.class;
i->rport_attr_cont.ac.match = srp_rport_match;
- transport_container_register(&i->rport_attr_cont);
count = 0;
SETUP_RPORT_ATTRIBUTE_RD(port_id);
SETUP_RPORT_ATTRIBUTE_RD(roles);
i->rport_attrs[count] = NULL;
+ transport_container_register(&i->rport_attr_cont);
+
i->f = ft;
return &i->t;
--
1.7.7
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 10/15] srp_transport: Simplify attribute initialization code
2012-03-25 14:45 [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
2012-03-25 14:57 ` [PATCH 09/15] srp_transport: Fix atttribute registration Bart Van Assche
@ 2012-03-25 14:58 ` Bart Van Assche
2012-03-25 14:59 ` [PATCH 11/15] srp_transport: Document sysfs attributes Bart Van Assche
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2012-03-25 14:58 UTC (permalink / raw)
To: linux-rdma, linux-scsi; +Cc: dillowda, roland, brking, fujita.tomonori
Eliminate the private_rport_attrs[] array and the SETUP_*() macros
used to set up that array since the information in that array
duplicates the information in the static device attributes. Also,
verify whether SRP_RPORT_ATTRS is large enough since it is easy
to forget to update that macro when adding new attributes.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Brian King <brking@linux.vnet.ibm.com>
Cc: David Dillow <dillowda@ornl.gov>
Cc: Roland Dreier <roland@purestorage.com>
---
drivers/scsi/scsi_transport_srp.c | 26 ++++----------------------
1 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 07c4394..0d85f79 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -47,7 +47,6 @@ struct srp_internal {
struct device_attribute *host_attrs[SRP_HOST_ATTRS + 1];
struct device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1];
- struct device_attribute private_rport_attrs[SRP_RPORT_ATTRS];
struct transport_container rport_attr_cont;
};
@@ -72,24 +71,6 @@ static DECLARE_TRANSPORT_CLASS(srp_host_class, "srp_host", srp_host_setup,
static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
NULL, NULL, NULL);
-#define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm) \
- i->private_##attrb[count] = dev_attr_##field; \
- i->private_##attrb[count].attr.mode = perm; \
- if (ro_test) { \
- i->private_##attrb[count].attr.mode = ro_perm; \
- i->private_##attrb[count].store = NULL; \
- } \
- i->attrb[count] = &i->private_##attrb[count]; \
- if (test) \
- count++
-
-#define SETUP_RPORT_ATTRIBUTE_RD(field) \
- SETUP_TEMPLATE(rport_attrs, field, S_IRUGO, 1, 0, 0)
-
-#define SETUP_RPORT_ATTRIBUTE_RW(field) \
- SETUP_TEMPLATE(rport_attrs, field, S_IRUGO | S_IWUSR, \
- 1, 1, S_IRUGO)
-
#define SRP_PID(p) \
(p)->port_id[0], (p)->port_id[1], (p)->port_id[2], (p)->port_id[3], \
(p)->port_id[4], (p)->port_id[5], (p)->port_id[6], (p)->port_id[7], \
@@ -326,9 +307,10 @@ srp_attach_transport(struct srp_function_template *ft)
i->rport_attr_cont.ac.match = srp_rport_match;
count = 0;
- SETUP_RPORT_ATTRIBUTE_RD(port_id);
- SETUP_RPORT_ATTRIBUTE_RD(roles);
- i->rport_attrs[count] = NULL;
+ i->rport_attrs[count++] = &dev_attr_port_id;
+ i->rport_attrs[count++] = &dev_attr_roles;
+ i->rport_attrs[count++] = NULL;
+ BUG_ON(count > ARRAY_SIZE(i->rport_attrs));
transport_container_register(&i->rport_attr_cont);
--
1.7.7
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 11/15] srp_transport: Document sysfs attributes
2012-03-25 14:45 [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
2012-03-25 14:57 ` [PATCH 09/15] srp_transport: Fix atttribute registration Bart Van Assche
2012-03-25 14:58 ` [PATCH 10/15] srp_transport: Simplify attribute initialization code Bart Van Assche
@ 2012-03-25 14:59 ` Bart Van Assche
2012-03-25 15:01 ` [PATCH 13/15] ib_srp: Allow SRP disconnect through sysfs Bart Van Assche
2012-03-25 15:18 ` [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
4 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2012-03-25 14:59 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
Cc: dillowda-1Heg1YXhbW8, roland-BHEL68pLQRGGvPXPguhicg,
fujita.tomonori-Zyj7fXuS5i5L9jVzuh4AOg,
brking-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: FUJITA Tomonori <fujita.tomonori-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
Cc: Brian King <brking-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: David Dillow <dillowda-1Heg1YXhbW8@public.gmane.org>
Cc: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
---
Documentation/ABI/stable/sysfs-transport-srp | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
create mode 100644 Documentation/ABI/stable/sysfs-transport-srp
diff --git a/Documentation/ABI/stable/sysfs-transport-srp b/Documentation/ABI/stable/sysfs-transport-srp
new file mode 100644
index 0000000..7b0d4a5
--- /dev/null
+++ b/Documentation/ABI/stable/sysfs-transport-srp
@@ -0,0 +1,12 @@
+What: /sys/class/srp_remote_ports/port-<h>:<n>/port_id
+Date: June 27, 2007
+KernelVersion: 2.6.24
+Contact: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
+Description: 16-byte local SRP port identifier in hexadecimal format. An
+ example: 4c:49:4e:55:58:20:56:49:4f:00:00:00:00:00:00:00.
+
+What: /sys/class/srp_remote_ports/port-<h>:<n>/roles
+Date: June 27, 2007
+KernelVersion: 2.6.24
+Contact: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
+Description: Role of the remote port. Either "SRP Initiator" or "SRP Target".
--
1.7.7
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 13/15] ib_srp: Allow SRP disconnect through sysfs
2012-03-25 14:45 [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
` (2 preceding siblings ...)
2012-03-25 14:59 ` [PATCH 11/15] srp_transport: Document sysfs attributes Bart Van Assche
@ 2012-03-25 15:01 ` Bart Van Assche
2012-07-16 22:20 ` Mike Christie
2012-03-25 15:18 ` [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
4 siblings, 1 reply; 9+ messages in thread
From: Bart Van Assche @ 2012-03-25 15:01 UTC (permalink / raw)
To: linux-rdma, linux-scsi; +Cc: dillowda, roland, fujita.tomonori, brking
Make it possible to disconnect the IB RC connection used by the
SRP protocol to communicate with a target.
Let the SRP transport layer create a sysfs "delete" attribute for
initiator drivers that support this functionality.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: David Dillow <dillowda@ornl.gov>
Cc: Roland Dreier <roland@purestorage.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Brian King <brking@linux.vnet.ibm.com>
---
Documentation/ABI/stable/sysfs-transport-srp | 7 +++++++
drivers/infiniband/ulp/srp/ib_srp.c | 24 +++++++++++++++++++++---
drivers/scsi/scsi_transport_srp.c | 22 +++++++++++++++++++++-
include/scsi/scsi_transport_srp.h | 8 ++++++++
4 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/Documentation/ABI/stable/sysfs-transport-srp b/Documentation/ABI/stable/sysfs-transport-srp
index 7b0d4a5..9fbc703 100644
--- a/Documentation/ABI/stable/sysfs-transport-srp
+++ b/Documentation/ABI/stable/sysfs-transport-srp
@@ -1,3 +1,10 @@
+What: /sys/class/srp_remote_ports/port-<h>:<n>/delete
+Date: January 1, 2012
+KernelVersion: 3.4
+Contact: linux-scsi@vger.kernel.org, linux-rdma@vger.kernel.org
+Description: Instructs an SRP initiator to disconnect from a target and to
+ remove all LUNs imported from that target.
+
What: /sys/class/srp_remote_ports/port-<h>:<n>/port_id
Date: June 27, 2007
KernelVersion: 2.6.24
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 564ff08..9f940a5 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -612,6 +612,21 @@ static void srp_remove_work(struct work_struct *work)
srp_remove_target(target);
}
+/*
+ * Note: it is up to the caller to ensure that invoking srp_rport_delete()
+ * does not trigger a race against target port removal in srp_remove_target().
+ * As an example, invoking srp_rport_delete() from the SCSI EH is not safe.
+ */
+static void srp_rport_delete(struct srp_rport *rport)
+{
+ struct srp_target_port *target = rport->lld_data;
+
+ BUG_ON(!target);
+
+ if (srp_change_state_to_removed(target))
+ queue_work(system_long_wq, &target->remove_work);
+}
+
static int srp_connect_target(struct srp_target_port *target)
{
int retries = 3;
@@ -1982,6 +1997,10 @@ static struct scsi_host_template srp_template = {
.shost_attrs = srp_host_attrs
};
+static struct srp_function_template ib_srp_transport_functions = {
+ .rport_delete = srp_rport_delete,
+};
+
static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
{
struct srp_rport_identifiers ids;
@@ -2002,6 +2021,8 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
return PTR_ERR(rport);
}
+ rport->lld_data = target;
+
spin_lock(&host->target_lock);
list_add_tail(&target->list, &host->target_list);
spin_unlock(&host->target_lock);
@@ -2576,9 +2597,6 @@ static void srp_remove_one(struct ib_device *device)
kfree(srp_dev);
}
-static struct srp_function_template ib_srp_transport_functions = {
-};
-
static int __init srp_init_module(void)
{
int ret;
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 0d85f79..f379c7f 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -38,7 +38,7 @@ struct srp_host_attrs {
#define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
#define SRP_HOST_ATTRS 0
-#define SRP_RPORT_ATTRS 2
+#define SRP_RPORT_ATTRS 3
struct srp_internal {
struct scsi_transport_template t;
@@ -116,6 +116,24 @@ show_srp_rport_roles(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL);
+static ssize_t store_srp_rport_delete(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct srp_rport *rport = transport_class_to_srp_rport(dev);
+ struct Scsi_Host *shost = dev_to_shost(dev);
+ struct srp_internal *i = to_srp_internal(shost->transportt);
+
+ if (i->f->rport_delete) {
+ i->f->rport_delete(rport);
+ return count;
+ } else {
+ return -ENOSYS;
+ }
+}
+
+static DEVICE_ATTR(delete, S_IWUSR, NULL, store_srp_rport_delete);
+
static void srp_rport_release(struct device *dev)
{
struct srp_rport *rport = dev_to_rport(dev);
@@ -309,6 +327,8 @@ srp_attach_transport(struct srp_function_template *ft)
count = 0;
i->rport_attrs[count++] = &dev_attr_port_id;
i->rport_attrs[count++] = &dev_attr_roles;
+ if (ft->rport_delete)
+ i->rport_attrs[count++] = &dev_attr_delete;
i->rport_attrs[count++] = NULL;
BUG_ON(count > ARRAY_SIZE(i->rport_attrs));
diff --git a/include/scsi/scsi_transport_srp.h b/include/scsi/scsi_transport_srp.h
index 9c60ca1..f47549f 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -14,13 +14,21 @@ struct srp_rport_identifiers {
};
struct srp_rport {
+ /* for initiator and target drivers */
+
struct device dev;
u8 port_id[16];
u8 roles;
+
+ /* for initiator drivers */
+
+ void *lld_data; /* LLD private data */
};
struct srp_function_template {
+ /* for initiator drivers */
+ void (*rport_delete)(struct srp_rport *rport);
/* for target drivers */
int (* tsk_mgmt_response)(struct Scsi_Host *, u64, u64, int);
int (* it_nexus_response)(struct Scsi_Host *, u64, int);
--
1.7.7
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 13/15] ib_srp: Allow SRP disconnect through sysfs
2012-03-25 15:01 ` [PATCH 13/15] ib_srp: Allow SRP disconnect through sysfs Bart Van Assche
@ 2012-07-16 22:20 ` Mike Christie
[not found] ` <500493B4.4010303-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
0 siblings, 1 reply; 9+ messages in thread
From: Mike Christie @ 2012-07-16 22:20 UTC (permalink / raw)
To: Bart Van Assche
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA, dillowda-1Heg1YXhbW8,
roland-BHEL68pLQRGGvPXPguhicg,
fujita.tomonori-Zyj7fXuS5i5L9jVzuh4AOg,
brking-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8
On 03/25/2012 09:01 AM, Bart Van Assche wrote:
> +static void srp_rport_delete(struct srp_rport *rport)
> +{
> + struct srp_target_port *target = rport->lld_data;
> +
> + BUG_ON(!target);
> +
I don't think this null check is needed, because below you set the
lld_data before you call srp_rport_add which does the transport driver
model/sysfs file addition for the rport. So I think the rport delete
sysfs file won't show up before you set the lld_data.
> static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
> {
> struct srp_rport_identifiers ids;
> @@ -2002,6 +2021,8 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
> return PTR_ERR(rport);
> }
>
> + rport->lld_data = target;
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes
2012-03-25 14:45 [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
` (3 preceding siblings ...)
2012-03-25 15:01 ` [PATCH 13/15] ib_srp: Allow SRP disconnect through sysfs Bart Van Assche
@ 2012-03-25 15:18 ` Bart Van Assche
2012-03-27 16:37 ` Dave Dillow
4 siblings, 1 reply; 9+ messages in thread
From: Bart Van Assche @ 2012-03-25 15:18 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
Cc: dillowda-1Heg1YXhbW8, roland-BHEL68pLQRGGvPXPguhicg,
vuhuong-VPRAkNaXOzVWk0Htik3J/w
On Sunday 25 March 2012 15:17, Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org> wrote:
> This patch series makes the ib_srp driver better suited for use in a H.A. setup because [ ... ]
The patch series is also available here: http://github.com/bvanassche/linux/commits/srp-ha/.
Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes
2012-03-25 15:18 ` [PATCH 00/15, v3] Make ib_srp better suited for H.A. purposes Bart Van Assche
@ 2012-03-27 16:37 ` Dave Dillow
0 siblings, 0 replies; 9+ messages in thread
From: Dave Dillow @ 2012-03-27 16:37 UTC (permalink / raw)
To: Bart Van Assche
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org,
vuhuong-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org
On Sun, Mar 25, 2012 at 11:18:09AM -0400, Bart Van Assche wrote:
> On Sunday 25 March 2012 15:17, Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
> wrote:
> > This patch series makes the ib_srp driver better suited for use in a
> > H.A. setup because [ ... ]
>
> The patch series is also available here:
> http://github.com/bvanassche/linux/commits/srp-ha/.
Thanks Bart, seems the work mail server is still mangling whitespace, so
the repo link is much appreciated. I'll try to review these tomorrow
afternoon.
--
Dave Dillow
National Center for Computational Science
Oak Ridge National Laboratory
(865) 241-6602 office
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread