All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Caulfield <pcaulfie@redhat.com>
To: dm-devel@redhat.com
Subject: PATCH - multipath UUID
Date: Thu, 29 Sep 2005 17:03:47 +0100	[thread overview]
Message-ID: <433C1063.3070202@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

If you use aliases to rename the multipath devices to something sensible you
lose the WWIDs, this patch stores them as the device-mapper UUID and retrieves
them so they can be displayed using multipath -l.
-- 

patrick

[-- Attachment #2: multipath-uuid.patch --]
[-- Type: text/x-patch, Size: 2366 bytes --]

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -102,7 +102,7 @@ dm_simplecmd (int task, const char *name
 
 extern int
 dm_addmap (int task, const char *name, const char *target,
-	   const char *params, unsigned long long size) {
+	   const char *params, unsigned long long size, const char *uuid) {
 	int r = 0;
 	struct dm_task *dmt;
 
@@ -115,6 +115,9 @@ dm_addmap (int task, const char *name, c
 	if (!dm_task_add_target (dmt, 0, size, target, params))
 		goto addout;
 
+	if (uuid && !dm_task_set_uuid(dmt, uuid))
+		goto addout;
+
 	dm_task_no_open_count(dmt);
 
 	r = dm_task_run (dmt);
@@ -188,6 +191,34 @@ out:
 }
 
 extern int
+dm_get_uuid(char *name, char *uuid)
+{
+	struct dm_task *dmt;
+	const char *uuidtmp;
+
+	dmt = dm_task_create(DM_DEVICE_INFO);
+	if (!dmt)
+		return 1;
+
+        if (!dm_task_set_name (dmt, name))
+                goto uuidout;
+
+	if (!dm_task_run(dmt))
+                goto uuidout;
+
+	uuidtmp = dm_task_get_uuid(dmt);
+	if (uuidtmp)
+		strcpy(uuid, uuidtmp);
+	else
+		uuid[0] = '\0';
+
+uuidout:
+	dm_task_destroy(dmt);
+
+	return 0;
+}
+
+extern int
 dm_get_status(char * name, char * outstatus)
 {
 	int r = 1;
@@ -556,6 +587,8 @@ dm_get_maps (vector mp, char * type)
 			if (dm_get_status(names->name, mpp->status))
 				goto out1;
 
+			dm_get_uuid(names->name, mpp->wwid);
+
 			mpp->alias = MALLOC(strlen(names->name) + 1);
 
 			if (!mpp->alias)
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -1,7 +1,7 @@
 int dm_prereq (char *, int, int, int);
 int dm_simplecmd (int, const char *);
 int dm_addmap (int, const char *, const char *, const char *,
-	       unsigned long long);
+	       unsigned long long, const char *uuid);
 int dm_map_present (char *);
 int dm_get_map(char *, unsigned long long *, char *);
 int dm_get_status(char *, char *);
diff --git a/multipath/main.c b/multipath/main.c
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -625,7 +625,7 @@ domap (struct multipath * mpp)
 	 */
 	dm_log_init_verbose(0);
 
-	r = dm_addmap(op, mpp->alias, DEFAULT_TARGET, mpp->params, mpp->size);
+	r = dm_addmap(op, mpp->alias, DEFAULT_TARGET, mpp->params, mpp->size, mpp->wwid);
 
 	if (r == 0)
 		dm_simplecmd(DM_DEVICE_REMOVE, mpp->alias);

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



             reply	other threads:[~2005-09-29 16:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-29 16:03 Patrick Caulfield [this message]
2005-09-29 22:16 ` PATCH - multipath UUID Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=433C1063.3070202@redhat.com \
    --to=pcaulfie@redhat.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.