You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

236 lines
6.9 KiB

---
libmpathpersist/mpath_persist.c | 14 ++++++------
libmultipath/discovery.c | 46 ++++++++++++++++++++--------------------
libmultipath/discovery.h | 4 +++
multipath/main.c | 2 -
multipathd/main.c | 6 +++--
5 files changed, 39 insertions(+), 33 deletions(-)
Index: multipath-tools-130222/libmpathpersist/mpath_persist.c
===================================================================
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.c
+++ multipath-tools-130222/libmpathpersist/mpath_persist.c
@@ -178,7 +178,7 @@ int mpath_persistent_reserve_in (int fd,
goto out;
}
- if (path_discovery(pathvec, conf, DI_SYSFS | DI_CHECKER)) {
+ if (path_discovery(pathvec, conf, DI_SYSFS | DI_CHECKER) < 0) {
ret = MPATH_PR_DMMP_ERROR;
goto out1;
}
@@ -262,13 +262,13 @@ int mpath_persistent_reserve_out ( int f
curmp = vector_alloc ();
pathvec = vector_alloc ();
- if (!curmp || !pathvec){
- condlog (0, "%s: vector allocation failed.", alias);
- ret = MPATH_PR_DMMP_ERROR;
- goto out;
- }
+ if (!curmp || !pathvec){
+ condlog (0, "%s: vector allocation failed.", alias);
+ ret = MPATH_PR_DMMP_ERROR;
+ goto out;
+ }
- if (path_discovery(pathvec, conf, DI_SYSFS | DI_CHECKER)) {
+ if (path_discovery(pathvec, conf, DI_SYSFS | DI_CHECKER) < 0) {
ret = MPATH_PR_DMMP_ERROR;
goto out1;
}
Index: multipath-tools-130222/libmultipath/discovery.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/discovery.c
+++ multipath-tools-130222/libmultipath/discovery.c
@@ -32,7 +32,7 @@ int
store_pathinfo (vector pathvec, vector hwtable, struct udev_device *udevice,
int flag, struct path **pp_ptr)
{
- int err = 1;
+ int err = PATHINFO_FAILED;
struct path * pp;
const char * devname;
@@ -41,12 +41,12 @@ store_pathinfo (vector pathvec, vector h
devname = udev_device_get_sysname(udevice);
if (!devname)
- return 1;
+ return PATHINFO_FAILED;
pp = alloc_path();
if (!pp)
- return 1;
+ return PATHINFO_FAILED;
if(safe_sprintf(pp->dev, "%s", devname)) {
condlog(0, "pp->dev too small");
@@ -80,19 +80,16 @@ path_discover (vector pathvec, struct co
devname = udev_device_get_sysname(udevice);
if (!devname)
- return 0;
+ return PATHINFO_FAILED;
if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
(char *)devname) > 0)
- return 0;
+ return PATHINFO_SKIPPED;
pp = find_path_by_dev(pathvec, (char *)devname);
if (!pp) {
- if (store_pathinfo(pathvec, conf->hwtable,
- udevice, flag, NULL) != 1)
- return 0;
- else
- return 1;
+ return store_pathinfo(pathvec, conf->hwtable,
+ udevice, flag, NULL);
}
return pathinfo(pp, conf->hwtable, flag);
}
@@ -104,11 +101,11 @@ path_discovery (vector pathvec, struct c
struct udev_list_entry *entry;
struct udev_device *udevice;
const char *devpath;
- int r = 0;
+ int num_paths = 0, total_paths = 0;
udev_iter = udev_enumerate_new(conf->udev);
if (!udev_iter)
- return 1;
+ return -ENOMEM;
udev_enumerate_add_match_subsystem(udev_iter, "block");
udev_enumerate_scan_devices(udev_iter);
@@ -121,17 +118,20 @@ path_discovery (vector pathvec, struct c
udevice = udev_device_new_from_syspath(conf->udev, devpath);
if (!udevice) {
condlog(4, "%s: no udev information", devpath);
- r++;
continue;
}
devtype = udev_device_get_devtype(udevice);
- if(devtype && !strncmp(devtype, "disk", 4))
- r += path_discover(pathvec, conf, udevice, flag);
+ if(devtype && !strncmp(devtype, "disk", 4)) {
+ total_paths++;
+ if (path_discover(pathvec, conf,
+ udevice, flag) == PATHINFO_OK)
+ num_paths++;
+ }
udev_device_unref(udevice);
}
udev_enumerate_unref(udev_iter);
- condlog(4, "Discovery status %d", r);
- return r;
+ condlog(4, "Discovered %d/%d paths", num_paths, total_paths);
+ return (total_paths - num_paths);
}
#define declare_sysfs_get_str(fname) \
@@ -1021,7 +1021,7 @@ get_state (struct path * pp, int daemon)
if (!checker_selected(c)) {
if (daemon) {
- if (pathinfo(pp, conf->hwtable, DI_SYSFS) != 0) {
+ if (pathinfo(pp, conf->hwtable, DI_SYSFS) != PATHINFO_OK) {
condlog(3, "%s: couldn't get sysfs pathinfo",
pp->dev);
return PATH_UNCHECKED;
@@ -1140,7 +1140,7 @@ pathinfo (struct path *pp, vector hwtabl
int path_state;
if (!pp)
- return 1;
+ return PATHINFO_FAILED;
condlog(3, "%s: mask = 0x%x", pp->dev, mask);
@@ -1148,12 +1148,12 @@ pathinfo (struct path *pp, vector hwtabl
* fetch info available in sysfs
*/
if (mask & DI_SYSFS && sysfs_pathinfo(pp))
- return 1;
+ return PATHINFO_FAILED;
if (mask & DI_BLACKLIST && mask & DI_SYSFS) {
if (filter_device(conf->blist_device, conf->elist_device,
pp->vendor_id, pp->product_id) > 0) {
- return 2;
+ return PATHINFO_SKIPPED;
}
}
@@ -1199,7 +1199,7 @@ pathinfo (struct path *pp, vector hwtabl
if (mask & DI_BLACKLIST && mask & DI_WWID) {
if (filter_wwid(conf->blist_wwid, conf->elist_wwid,
pp->wwid) > 0) {
- return 2;
+ return PATHINFO_SKIPPED;
}
}
@@ -1213,7 +1213,7 @@ pathinfo (struct path *pp, vector hwtabl
}
}
- return 0;
+ return PATHINFO_OK;
blank:
/*
Index: multipath-tools-130222/libmultipath/discovery.h
===================================================================
--- multipath-tools-130222.orig/libmultipath/discovery.h
+++ multipath-tools-130222/libmultipath/discovery.h
@@ -24,6 +24,10 @@
#define SCSI_COMMAND_TERMINATED 0x22
#define SG_ERR_DRIVER_SENSE 0x08
+#define PATHINFO_OK 0
+#define PATHINFO_FAILED 1
+#define PATHINFO_SKIPPED 2
+
struct config;
int sysfs_get_dev (struct udev_device *udev, char * buff, size_t len);
Index: multipath-tools-130222/multipath/main.c
===================================================================
--- multipath-tools-130222.orig/multipath/main.c
+++ multipath-tools-130222/multipath/main.c
@@ -343,7 +343,7 @@ configure (void)
/* maximum info */
di_flag = DI_ALL;
- if (path_discovery(pathvec, conf, di_flag))
+ if (path_discovery(pathvec, conf, di_flag) < 0)
goto out;
if (conf->verbosity > 2)
Index: multipath-tools-130222/multipathd/main.c
===================================================================
--- multipath-tools-130222.orig/multipathd/main.c
+++ multipath-tools-130222/multipathd/main.c
@@ -1515,7 +1515,7 @@ configure (struct vectors * vecs, int st
struct multipath * mpp;
struct path * pp;
vector mpvec;
- int i;
+ int i, ret;
if (!vecs->pathvec && !(vecs->pathvec = vector_alloc()))
return 1;
@@ -1529,7 +1529,9 @@ configure (struct vectors * vecs, int st
/*
* probe for current path (from sysfs) and map (from dm) sets
*/
- path_discovery(vecs->pathvec, conf, DI_ALL);
+ ret = path_discovery(vecs->pathvec, conf, DI_ALL);
+ if (ret < 0)
+ return 1;
vector_foreach_slot (vecs->pathvec, pp, i){
if (filter_path(conf, pp) > 0){