Skip to contentSkip to conversation

dm-multipath [PATCH] multipathd adding devices.

PATCH Benjamin Marzinski 2 participants 3 messages Feb 25, 2006 – Mar 2, 2006 Device mapper

lore
Share & tools
lore

Benjamin Marzinski

author maintainer
#0 lore raw

The way multipathd currently works, if you add a map that isn't known to device mapper from multipathd, the first time you run the command, it won't add the map to the mpvec vector. With the attached patch, multipathd will initialize the map and add it to the mpvec vector.

-Ben

multipathd/main.c +25 -1
diff -urpN mp-devel-clean/multipathd/main.c mp-devel-patched/multipathd/main.c
@@ -550,6 +550,7 @@ ev_add_map (char * devname, struct vecto
 	char * alias;
 	char * refwwid;
 	struct multipath * mpp;
+	vector mpvec;
 	int map_present;
 	int r = 1;
 
@@ -597,10 +598,33 @@ ev_add_map (char * devname, struct vecto
 	refwwid = get_refwwid(devname, DEV_DEVMAP, vecs->pathvec);
 
 	if (refwwid) {
-		r = coalesce_paths(vecs, NULL, refwwid);
+		int i;
+		if (!(mpvec = vector_alloc()))
+			goto out;
+		r = coalesce_paths(vecs, mpvec, refwwid);
 		dm_lib_release();
+		if (r)
+			goto out_free;
+		r = 1;
+		vector_foreach_slot(mpvec, mpp, i){
+			if (!vector_alloc_slot(vecs->mpvec)) {
+				orphan_paths(vecs->pathvec, mpp);
+				free_multipath(mpp, KEEP_PATHS);
+				goto out_free;
+			}
+			vector_set_slot(vecs->mpvec, mpp);
+			sync_map_state(mpp);
+			if (setup_multipath(vecs, mpp))
+				goto out_free;
+			if (start_waiter_thread(mpp, vecs))
+				goto out_free;
+			r = 0;
+		}
 	}
 	
+out_free:
+	vector_free(mpvec);
+out:
 	if (!r)
 		condlog(3, "%s: devmap %s added", alias, devname);
 	else
#1 lore raw
Quoted 5 lines · Benjamin Marzinski

The way multipathd currently works, if you add a map that isn't known to device mapper from multipathd, the first time you run the command, it won't add the map to the mpvec vector. With the attached patch, multipathd will initialize the map and add it to the mpvec vector.

How does the current behaviour affects you ? Is this about races between DM and netlink events ?

Regards,
cvaroqui

Quoted 51 lines

diff -urpN mp-devel-clean/multipathd/main.c mp-devel-patched/multipathd/main.c

multipathd/main.c +25 -2
@@ -550,6 +550,7 @@ ev_add_map (char * devname, struct vecto
 	char * alias;
 	char * refwwid;
 	struct multipath * mpp;
+	vector mpvec;
 	int map_present;
 	int r = 1;
 
@@ -597,10 +598,33 @@ ev_add_map (char * devname, struct vecto
 	refwwid = get_refwwid(devname, DEV_DEVMAP, vecs->pathvec);
 
 	if (refwwid) {
-		r = coalesce_paths(vecs, NULL, refwwid);
+		int i;
+		if (!(mpvec = vector_alloc()))
+			goto out;
+		r = coalesce_paths(vecs, mpvec, refwwid);
 		dm_lib_release();
+		if (r)
+			goto out_free;
+		r = 1;
+		vector_foreach_slot(mpvec, mpp, i){
+			if (!vector_alloc_slot(vecs->mpvec)) {
+				orphan_paths(vecs->pathvec, mpp);
+				free_multipath(mpp, KEEP_PATHS);
+				goto out_free;
+			}
+			vector_set_slot(vecs->mpvec, mpp);
+			sync_map_state(mpp);
+			if (setup_multipath(vecs, mpp))
+				goto out_free;
+			if (start_waiter_thread(mpp, vecs))
+				goto out_free;
+			r = 0;
+		}
 	}
 
+out_free:
+	vector_free(mpvec);
+out:
 	if (!r)
 		condlog(3, "%s: devmap %s added", alias, devname);
 	else
 
--

dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#2 lore raw
Quoted 9 lines · Christophe Varoqui
Quoted 5 lines · Benjamin Marzinski

The way multipathd currently works, if you add a map that isn't known to device mapper from multipathd, the first time you run the command, it won't add the map to the mpvec vector. With the attached patch, multipathd will initialize the map and add it to the mpvec vector.

How does the current behaviour affects you ? Is this about races between DM and netlink events ?

To be more specific, I think the current code rely on the netlink "map add" event triggered by coalesce_paths() to feed the mpvec asynchronously.

... which seems ok to me, but I may miss a point.

Regards,
cvaroqui