* [PATCH] multipath: make tgt_node_name work for iscsi devices
@ 2012-01-13 4:14 Benjamin Marzinski
2012-01-14 11:21 ` Christophe Varoqui
0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Marzinski @ 2012-01-13 4:14 UTC (permalink / raw)
To: device-mapper development; +Cc: Christophe Varoqui
tgt_node_name wasn't displaying anything for iscsi devices. With this
change, if multipath can't get the node_name, it will check
sys/devices/platform/hostX/sessionY/iscsi_session/sessionY/targetname
and if this is available, it will get the node name from there.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/discovery.c | 20 ++++++++++++++++++--
libmultipath/structs.h | 2 +-
2 files changed, 19 insertions(+), 3 deletions(-)
Index: multipath-tools-111219/libmultipath/discovery.c
===================================================================
--- multipath-tools-111219.orig/libmultipath/discovery.c
+++ multipath-tools-111219/libmultipath/discovery.c
@@ -210,10 +210,11 @@ sysfs_get_size (struct sysfs_device * de
}
int
-sysfs_get_fc_nodename (struct sysfs_device * dev, char * node,
+sysfs_get_tgt_nodename (struct sysfs_device * dev, char * node,
unsigned int host, unsigned int channel,
unsigned int target)
{
+ unsigned int checkhost, session;
char attr_path[SYSFS_PATH_SIZE];
size_t len;
@@ -225,6 +226,21 @@ sysfs_get_fc_nodename (struct sysfs_devi
}
len = sysfs_attr_get_value(attr_path, "node_name", node, NODE_NAME_SIZE);
+ if (len)
+ return 0;
+
+ if (sscanf(dev->devpath, "/devices/platform/host%u/session%u/",
+ &checkhost, &session) != 2)
+ return 1;
+ if (checkhost != host)
+ return 1;
+ if (safe_sprintf(attr_path, "/devices/platform/host%u/session%u/iscsi_session/session%u", host, session, session)) {
+ condlog(0, "attr_path too small");
+ return 1;
+ }
+
+ len = sysfs_attr_get_value(attr_path, "targetname", node,
+ NODE_NAME_SIZE);
if (!len)
return 1;
@@ -562,7 +578,7 @@ scsi_sysfs_pathinfo (struct path * pp, s
/*
* target node name
*/
- if(!sysfs_get_fc_nodename(parent, pp->tgt_node_name,
+ if(!sysfs_get_tgt_nodename(parent, pp->tgt_node_name,
pp->sg_id.host_no,
pp->sg_id.channel,
pp->sg_id.scsi_id)) {
Index: multipath-tools-111219/libmultipath/structs.h
===================================================================
--- multipath-tools-111219.orig/libmultipath/structs.h
+++ multipath-tools-111219/libmultipath/structs.h
@@ -5,7 +5,7 @@
#define WWID_SIZE 128
#define SERIAL_SIZE 65
-#define NODE_NAME_SIZE 65
+#define NODE_NAME_SIZE 224
#define PATH_STR_SIZE 16
#define PARAMS_SIZE 1024
#define FILE_NAME_SIZE 256
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] multipath: make tgt_node_name work for iscsi devices
2012-01-13 4:14 [PATCH] multipath: make tgt_node_name work for iscsi devices Benjamin Marzinski
@ 2012-01-14 11:21 ` Christophe Varoqui
0 siblings, 0 replies; 2+ messages in thread
From: Christophe Varoqui @ 2012-01-14 11:21 UTC (permalink / raw)
To: Benjamin Marzinski; +Cc: dm-devel
On jeu., 2012-01-12 at 22:14 -0600, Benjamin Marzinski wrote:
> tgt_node_name wasn't displaying anything for iscsi devices. With this
> change, if multipath can't get the node_name, it will check
> sys/devices/platform/hostX/sessionY/iscsi_session/sessionY/targetname
> and if this is available, it will get the node name from there.
>
Applied.
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---
> libmultipath/discovery.c | 20 ++++++++++++++++++--
> libmultipath/structs.h | 2 +-
> 2 files changed, 19 insertions(+), 3 deletions(-)
>
> Index: multipath-tools-111219/libmultipath/discovery.c
> ===================================================================
> --- multipath-tools-111219.orig/libmultipath/discovery.c
> +++ multipath-tools-111219/libmultipath/discovery.c
> @@ -210,10 +210,11 @@ sysfs_get_size (struct sysfs_device * de
> }
>
> int
> -sysfs_get_fc_nodename (struct sysfs_device * dev, char * node,
> +sysfs_get_tgt_nodename (struct sysfs_device * dev, char * node,
> unsigned int host, unsigned int channel,
> unsigned int target)
> {
> + unsigned int checkhost, session;
> char attr_path[SYSFS_PATH_SIZE];
> size_t len;
>
> @@ -225,6 +226,21 @@ sysfs_get_fc_nodename (struct sysfs_devi
> }
>
> len = sysfs_attr_get_value(attr_path, "node_name", node, NODE_NAME_SIZE);
> + if (len)
> + return 0;
> +
> + if (sscanf(dev->devpath, "/devices/platform/host%u/session%u/",
> + &checkhost, &session) != 2)
> + return 1;
> + if (checkhost != host)
> + return 1;
> + if (safe_sprintf(attr_path, "/devices/platform/host%u/session%u/iscsi_session/session%u", host, session, session)) {
> + condlog(0, "attr_path too small");
> + return 1;
> + }
> +
> + len = sysfs_attr_get_value(attr_path, "targetname", node,
> + NODE_NAME_SIZE);
> if (!len)
> return 1;
>
> @@ -562,7 +578,7 @@ scsi_sysfs_pathinfo (struct path * pp, s
> /*
> * target node name
> */
> - if(!sysfs_get_fc_nodename(parent, pp->tgt_node_name,
> + if(!sysfs_get_tgt_nodename(parent, pp->tgt_node_name,
> pp->sg_id.host_no,
> pp->sg_id.channel,
> pp->sg_id.scsi_id)) {
> Index: multipath-tools-111219/libmultipath/structs.h
> ===================================================================
> --- multipath-tools-111219.orig/libmultipath/structs.h
> +++ multipath-tools-111219/libmultipath/structs.h
> @@ -5,7 +5,7 @@
>
> #define WWID_SIZE 128
> #define SERIAL_SIZE 65
> -#define NODE_NAME_SIZE 65
> +#define NODE_NAME_SIZE 224
> #define PATH_STR_SIZE 16
> #define PARAMS_SIZE 1024
> #define FILE_NAME_SIZE 256
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-14 11:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-13 4:14 [PATCH] multipath: make tgt_node_name work for iscsi devices Benjamin Marzinski
2012-01-14 11:21 ` Christophe Varoqui
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.