Skip to contentSkip to conversation

multipath-tools kpartx/Makefile libmultipath/d ...

PATCH [email protected] 1 participant 1 message Oct 12, 2006 Device mapper

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/dm
Module name: multipath-tools
Changes by: [email protected] 2006-10-12 16:16:10

Modified files:

	kpartx         : Makefile 
	libmultipath   : discovery.c discovery.h hwtable.c 
	multipath      : Makefile 
	multipathd     : main.c 

Added files:
multipath : mpath_faker.c

Log message:
This makes multipath and gnbd work together.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/kpartx/Makefile.diff?cvsroot=dm&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/discovery.c.diff?cvsroot=dm&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/discovery.h.diff?cvsroot=dm&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/libmultipath/hwtable.c.diff?cvsroot=dm&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipath/mpath_faker.c.diff?cvsroot=dm&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipath/Makefile.diff?cvsroot=dm&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/multipath-tools/multipathd/main.c.diff?cvsroot=dm&r1=1.68&r2=1.69

kpartx/Makefile +1 -1
@@ -46,4 +46,4 @@
 	rm -f $(DESTDIR)$(mandir)/$(EXEC).8
 
 clean:
-	rm -f core *.o $(EXEC) *.gz
+	rm -f core *.o $(EXEC) $(EXEC).static *.gz
libmultipath/discovery.c +48 -24

93 lines not on this page · raw message

libmultipath/discovery.h +1 -0
@@ -24,6 +24,7 @@
 #define SCSI_COMMAND_TERMINATED 0x22
 #define SG_ERR_DRIVER_SENSE     0x08
 
+int device_ok_to_add(char *devname);
 int sysfs_get_vendor (char * sysfs_path, char * dev, char * buff, int len);
 int sysfs_get_model (char * sysfs_path, char * dev, char * buff, int len);
 int sysfs_get_rev (char * sysfs_path, char * dev, char * buff, int len);
libmultipath/hwtable.c +1 -1
@@ -519,7 +519,7 @@
 	{
 		.vendor        = "GNBD",
 		.product       = "GNBD",
-		.getuid        = "/sbin/gnbd_import -U /block/%n",
+		.getuid        = "/sbin/gnbd_import -q -U /block/%n",
 		.getprio       = NULL,
 		.features      = DEFAULT_FEATURES,
 		.hwhandler     = DEFAULT_HWHANDLER,
multipath/Makefile +4 -2
diff -u -r1.7 -r1.8
@@ -22,6 +22,7 @@
 glibc: clean $(OBJS)
 	$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
 	$(CC) $(OBJS) -o $(EXEC).static -static $(LDFLAGS) -lselinux -lsepol
+	$(CC) mpath_faker.c -o mpath_ctl $(CFLAGS) -static
 
 klibc: $(OBJS)
 	$(CC) -static -o $(EXEC) $(CRT0) $(OBJS) $(KLIBC) $(LIBGCC)
@@ -35,7 +36,7 @@
 
 install:
 	install -d $(DESTDIR)$(bindir)
-	install -m 755 $(EXEC) $(EXEC).static mpath_get_name kpartx_get_name $(DESTDIR)$(bindir)/
+	install -m 755 $(EXEC) $(EXEC).static mpath_ctl mpath_wait $(DESTDIR)$(bindir)/
 	install -d $(DESTDIR)/etc/udev/rules.d
 	install -m 644 multipath.rules $(DESTDIR)/etc/udev/rules.d/40-multipath.rules
 	install -d $(DESTDIR)$(mandir)
@@ -49,8 +50,9 @@
 	rm $(DESTDIR)$(bindir)/$(EXEC)
 	rm $(DESTDIR)$(bindir)/$(EXEC).static
 	rm $(DESTDIR)$(bindir)/mpath_wait
+	rm $(DESTDIR)$(bindir)/mpath_ctl
 	rm $(DESTDIR)$(mandir)/$(EXEC).8
 
 clean:
 	$(MAKE) -C $(multipathdir) clean
-	rm -f core *.o $(EXEC) $(EXEC).static *.gz
+	rm -f core *.o $(EXEC) $(EXEC).static mpath_ctl *.gz
multipathd/main.c +21 -0
@@ -348,6 +348,14 @@
 	struct multipath * mpp;
 	struct path * pp;
 	char empty_buff[WWID_SIZE] = {0};
+	int ret;
+
+	ret = device_ok_to_add(devname);
+	if (ret < 0)
+		return 1;
+	if (ret == 0)
+		/* Is 2 the best return code? */
+		return 2;
 
 	pp = find_path_by_dev(vecs->pathvec, devname);
 
@@ -1016,6 +1024,18 @@
 	return NULL;
 }
 
+static void
+orphan_unused_paths (struct vectors *vecs)
+{
+	int i;
+	struct path *pp;
+
+	vector_foreach_slot(vecs->pathvec, pp, i) {
+		if (pp->mpp == NULL)
+			orphan_path(pp);
+	}
+}
+
 int
 configure (struct vectors * vecs, int start_waiters)
 {
@@ -1082,6 +1102,7 @@
 	vector_free(vecs->mpvec);
 	vecs->mpvec = mpvec;
 
+	orphan_unused_paths(vecs);
 	/*
 	 * start dm event waiter threads for these new maps
 	 */