|
|
45d01a |
---
|
|
|
45d01a |
libmultipath/devmapper.c | 31 +++++++++++++++++++++----------
|
|
|
45d01a |
1 file changed, 21 insertions(+), 10 deletions(-)
|
|
|
45d01a |
|
|
|
45d01a |
Index: multipath-tools-130222/libmultipath/devmapper.c
|
|
|
45d01a |
===================================================================
|
|
|
45d01a |
--- multipath-tools-130222.orig/libmultipath/devmapper.c
|
|
|
45d01a |
+++ multipath-tools-130222/libmultipath/devmapper.c
|
|
|
45d01a |
@@ -264,12 +264,15 @@ dm_device_remove (const char *name, int
|
|
|
45d01a |
|
|
|
45d01a |
static int
|
|
|
45d01a |
dm_addmap (int task, const char *target, struct multipath *mpp, char * params,
|
|
|
45d01a |
- int use_uuid, int ro, int skip_kpartx) {
|
|
|
45d01a |
+ int use_uuid, int ro, uint16_t udev_flags) {
|
|
|
45d01a |
int r = 0;
|
|
|
45d01a |
struct dm_task *dmt;
|
|
|
45d01a |
char *prefixed_uuid = NULL;
|
|
|
45d01a |
uint32_t cookie = 0;
|
|
|
45d01a |
- uint16_t udev_flags = ((conf->daemon)? DM_UDEV_DISABLE_LIBRARY_FALLBACK : 0) | ((skip_kpartx == SKIP_KPARTX_ON)? MPATH_UDEV_NO_KPARTX_FLAG : 0);
|
|
|
45d01a |
+
|
|
|
45d01a |
+ /* Need to add this here to allow 0 to be passed in udev_flags */
|
|
|
45d01a |
+ if (conf->daemon)
|
|
|
45d01a |
+ udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
|
|
|
45d01a |
|
|
|
45d01a |
if (!(dmt = dm_task_create (task)))
|
|
|
45d01a |
return 0;
|
|
|
45d01a |
@@ -326,16 +329,28 @@ dm_addmap (int task, const char *target,
|
|
|
45d01a |
return r;
|
|
|
45d01a |
}
|
|
|
45d01a |
|
|
|
45d01a |
+static uint16_t build_udev_flags(const struct multipath *mpp, int reload)
|
|
|
45d01a |
+{
|
|
|
45d01a |
+ /* DM_UDEV_DISABLE_LIBRARY_FALLBACK is added in dm_addmap */
|
|
|
45d01a |
+ return (mpp->skip_kpartx == SKIP_KPARTX_ON ?
|
|
|
45d01a |
+ MPATH_UDEV_NO_KPARTX_FLAG : 0) |
|
|
|
45d01a |
+ (mpp->nr_active == 0 ?
|
|
|
45d01a |
+ MPATH_UDEV_NO_PATHS_FLAG : 0) |
|
|
|
45d01a |
+ (reload && !mpp->force_udev_reload ?
|
|
|
45d01a |
+ MPATH_UDEV_RELOAD_FLAG : 0);
|
|
|
45d01a |
+}
|
|
|
45d01a |
+
|
|
|
45d01a |
extern int
|
|
|
45d01a |
dm_addmap_create (struct multipath *mpp, char * params) {
|
|
|
45d01a |
int ro;
|
|
|
45d01a |
+ uint16_t udev_flags = build_udev_flags(mpp, 0);
|
|
|
45d01a |
|
|
|
45d01a |
sysfs_set_max_sectors_kb(mpp, 0);
|
|
|
45d01a |
for (ro = 0; ro <= 1; ro++) {
|
|
|
45d01a |
int err;
|
|
|
45d01a |
|
|
|
45d01a |
if (dm_addmap(DM_DEVICE_CREATE, TGT_MPATH,
|
|
|
45d01a |
- mpp, params, 1, ro, mpp->skip_kpartx))
|
|
|
45d01a |
+ mpp, params, 1, ro, udev_flags))
|
|
|
45d01a |
return 1;
|
|
|
45d01a |
/*
|
|
|
45d01a |
* DM_DEVICE_CREATE is actually DM_DEV_CREATE + DM_TABLE_LOAD.
|
|
|
45d01a |
@@ -358,21 +373,17 @@ dm_addmap_create (struct multipath *mpp,
|
|
|
45d01a |
extern int
|
|
|
45d01a |
dm_addmap_reload (struct multipath *mpp, char *params, int flush) {
|
|
|
45d01a |
int r = 0;
|
|
|
45d01a |
- uint16_t udev_flags = ((mpp->force_udev_reload)?
|
|
|
45d01a |
- 0 : MPATH_UDEV_RELOAD_FLAG) |
|
|
|
45d01a |
- ((mpp->skip_kpartx == SKIP_KPARTX_ON)?
|
|
|
45d01a |
- MPATH_UDEV_NO_KPARTX_FLAG : 0) |
|
|
|
45d01a |
- ((mpp->nr_active)? 0 : MPATH_UDEV_NO_PATHS_FLAG);
|
|
|
45d01a |
+ uint16_t udev_flags = build_udev_flags(mpp, 1);
|
|
|
45d01a |
|
|
|
45d01a |
sysfs_set_max_sectors_kb(mpp, 1);
|
|
|
45d01a |
if (!mpp->force_readonly)
|
|
|
45d01a |
r = dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, 0,
|
|
|
45d01a |
- ADDMAP_RW, SKIP_KPARTX_OFF);
|
|
|
45d01a |
+ ADDMAP_RW, 0);
|
|
|
45d01a |
if (!r) {
|
|
|
45d01a |
if (!mpp->force_readonly && errno != EROFS)
|
|
|
45d01a |
return 0;
|
|
|
45d01a |
r = dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, 0,
|
|
|
45d01a |
- ADDMAP_RO, SKIP_KPARTX_OFF);
|
|
|
45d01a |
+ ADDMAP_RO, 0);
|
|
|
45d01a |
}
|
|
|
45d01a |
if (r)
|
|
|
45d01a |
r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, !flush,
|