if (!find_mp_by_wwid(curmp, mpp->wwid)) {
condlog(2, "%s: remove (wwid changed)", cmpp->alias);
- dm_flush_map(mpp->alias, DEFAULT_TARGET);
+ dm_flush_map(mpp->alias);
strncat(cmpp->wwid, mpp->wwid, WWID_SIZE);
drop_multipath(curmp, cmpp->wwid, KEEP_PATHS);
mpp->action = ACT_CREATE;
break;
}
- r = dm_addmap(DM_DEVICE_CREATE, mpp->alias, DEFAULT_TARGET,
- mpp->params, mpp->size, mpp->wwid);
-
- /*
- * DM_DEVICE_CREATE is actually DM_DEV_CREATE plus
- * DM_TABLE_LOAD. Failing the second part leaves an
- * empty map. Clean it up.
- */
- if (!r && dm_map_present(mpp->alias)) {
- condlog(3, "%s: failed to load map "
- "(a path might be in use)",
- mpp->alias);
- dm_flush_map(mpp->alias, DEFAULT_TARGET);
- }
+ r = dm_addmap_create(mpp->alias, mpp->params, mpp->size,
+ mpp->wwid);
lock_multipath(mpp, 0);
break;
case ACT_RELOAD:
- r = (dm_addmap(DM_DEVICE_RELOAD, mpp->alias, DEFAULT_TARGET,
- mpp->params, mpp->size, NULL) &&
- dm_simplecmd(DM_DEVICE_RESUME, mpp->alias));
+ r = (dm_addmap_reload(mpp->alias, mpp->params, mpp->size, NULL)
+ && dm_simplecmd(DM_DEVICE_RESUME, mpp->alias));
break;
case ACT_RENAME:
/* multipath daemon mode */
mpp->stat_map_loads++;
condlog(2, "%s: load table [0 %llu %s %s]", mpp->alias,
- mpp->size, DEFAULT_TARGET, mpp->params);
+ mpp->size, TGT_MPATH, mpp->params);
/*
* Required action is over, reset for the stateful daemon
*/
remove_map(mpp, vecs, 0);
- if (dm_flush_map(mpp->alias, DEFAULT_TARGET))
+ if (dm_flush_map(mpp->alias))
condlog(2, "%s: remove failed (dead)",
mpp->alias);
else
#define DEFAULT_CHECKINT 5
#define MAX_CHECKINT(a) (a << 2)
-#define DEFAULT_TARGET "multipath"
#define DEFAULT_PIDFILE "/var/run/multipathd.pid"
#define DEFAULT_SOCKET "/var/run/multipathd.sock"
#define DEFAULT_CONFIGFILE "/etc/multipath.conf"
}
extern int
-dm_prereq (char * str)
+dm_prereq (void)
{
if (dm_libprereq())
return 1;
- return dm_drvprereq(str);
+ return dm_drvprereq(TGT_MPATH);
}
extern int
addout:
dm_task_destroy (dmt);
+
+ return r;
+}
+
+extern int
+dm_addmap_create (const char *name, const char *params,
+ unsigned long long size, const char *uuid) {
+ int r;
+ r = dm_addmap(DM_DEVICE_CREATE, name, TGT_MPATH, params, size, uuid);
+ /*
+ * DM_DEVICE_CREATE is actually DM_DEV_CREATE + DM_TABLE_LOAD.
+ * Failing the second part leaves an empty map. Clean it up.
+ */
+ if (!r && dm_map_present(name)) {
+ condlog(3, "%s: failed to load map (a path might be in use)",
+ name);
+ dm_flush_map(name);
+ }
+ return r;
+}
+
+extern int
+dm_addmap_reload (const char *name, const char *params,
+ unsigned long long size, const char *uuid) {
+ int r;
+ r = dm_addmap(DM_DEVICE_RELOAD, name, TGT_MPATH, params, size, uuid);
return r;
}
extern int
-dm_map_present (char * str)
+dm_map_present (const char * str)
{
int r = 0;
struct dm_task *dmt;
* -1 : empty map
*/
extern int
-dm_type(char * name, char * type)
+dm_type(const char * name, char * type)
{
int r = 0;
struct dm_task *dmt;
}
static int
-dm_dev_t (char * mapname, char * dev_t, int len)
+dm_dev_t (const char * mapname, char * dev_t, int len)
{
int r = 1;
struct dm_task *dmt;
}
int
-dm_get_opencount (char * mapname)
+dm_get_opencount (const char * mapname)
{
int r = -1;
struct dm_task *dmt;
}
extern int
-dm_flush_map (char * mapname, char * type)
+dm_flush_map (const char * mapname)
{
int r;
if (!dm_map_present(mapname))
return 0;
- if (dm_type(mapname, type) <= 0)
+ if (dm_type(mapname, TGT_MPATH) <= 0)
return 1;
if (dm_remove_partmaps(mapname))
}
extern int
-dm_flush_maps (char * type)
+dm_flush_maps (void)
{
int r = 0;
struct dm_task *dmt;
goto out;
do {
- r += dm_flush_map(names->name, type);
+ r += dm_flush_map(names->name);
next = names->next;
names = (void *) names + next;
} while (next);
}
int
-dm_get_maps (vector mp, char * type)
+dm_get_maps (vector mp)
{
struct multipath * mpp;
int r = 1;
struct dm_names *names;
unsigned next = 0;
- if (!type || !mp)
+ if (!mp)
return 1;
if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
}
do {
- info = dm_type(names->name, type);
+ info = dm_type(names->name, TGT_MPATH);
if (info <= 0)
goto next;
}
extern int
-dm_get_name(char *uuid, char *type, char *name)
+dm_get_name(char *uuid, char *name)
{
vector vec;
struct multipath *mpp;
if (!vec)
return 0;
- if (dm_get_maps(vec, type)) {
+ if (dm_get_maps(vec)) {
vector_free(vec);
return 0;
}
}
int
-dm_remove_partmaps (char * mapname)
+dm_remove_partmaps (const char * mapname)
{
struct dm_task *dmt;
struct dm_names *names;
/*
* if devmap target is "linear"
*/
- (dm_type(names->name, "linear") > 0) &&
+ (dm_type(names->name, TGT_PART) > 0) &&
/*
* and the multipath mapname and the part mapname start
/*
* if devmap target is "linear"
*/
- (dm_type(names->name, "linear") > 0) &&
+ (dm_type(names->name, TGT_PART) > 0) &&
/*
* and the multipath mapname and the part mapname start
+#define TGT_MPATH "multipath"
+#define TGT_PART "linear"
+
void dm_init(void);
-int dm_prereq (char *);
+int dm_prereq (void);
int dm_simplecmd (int, const char *);
-int dm_addmap (int, const char *, const char *, const char *,
- unsigned long long, const char *uuid);
-int dm_map_present (char *);
+int dm_addmap_create (const char *, const char *,
+ unsigned long long size, const char *uuid);
+int dm_addmap_reload (const char *, const char *,
+ unsigned long long size, const char *uuid);
+int dm_map_present (const char *);
int dm_get_map(char *, unsigned long long *, char *);
int dm_get_status(char *, char *);
-int dm_type(char *, char *);
-int dm_flush_map (char *, char *);
-int dm_flush_maps (char *);
+int dm_type(const char *, char *);
+int dm_flush_map (const char *);
+int dm_flush_maps (void);
int dm_fail_path(char * mapname, char * path);
int dm_reinstate_path(char * mapname, char * path);
int dm_queue_if_no_path(char *mapname, int enable);
int dm_switchgroup(char * mapname, int index);
int dm_enablegroup(char * mapname, int index);
int dm_disablegroup(char * mapname, int index);
-int dm_get_maps (vector mp, char * type);
+int dm_get_maps (vector mp);
int dm_geteventnr (char *name);
int dm_get_minor (char *name);
char * dm_mapname(int major, int minor);
-int dm_remove_partmaps (char * mapname);
+int dm_remove_partmaps (const char * mapname);
int dm_get_uuid(char *name, char *uuid);
int dm_get_info (char * mapname, struct dm_info ** dmi);
int dm_rename (char * old, char * new);
-int dm_get_name(char * uuid, char * type, char * name);
+int dm_get_name(char * uuid, char * name);
#include "parser.h"
#include "blacklist.h"
#include "switchgroup.h"
+#include "devmapper.h"
#define MAX(x,y) (x > y) ? x : y
#define TAIL (line + len - 1 - c)
{
if (mpp->size && mpp->params)
printf("0 %llu %s %s\n",
- mpp->size, DEFAULT_TARGET, mpp->params);
+ mpp->size, TGT_MPATH, mpp->params);
return;
}
if (mp->alias == NULL){
char *alias;
if ((alias = MALLOC(WWID_SIZE)) != NULL){
- if (dm_get_name(mp->wwid, DEFAULT_TARGET,
- alias) == 1)
+ if (dm_get_name(mp->wwid, alias) == 1)
mp->alias = alias;
else
FREE(alias);
/*
* detect an external rename of the multipath device
*/
- if (dm_get_name(mpp->wwid, DEFAULT_TARGET, new_alias)) {
+ if (dm_get_name(mpp->wwid, new_alias)) {
condlog(3, "%s multipath mapped device name has "
"changed from %s to %s", mpp->wwid,
mpp->alias, new_alias);
int i;
struct multipath * mpp;
- if (dm_get_maps(curmp, DEFAULT_TARGET))
+ if (dm_get_maps(curmp))
return 1;
vector_foreach_slot (curmp, mpp, i) {
exit(1);
}
- if (dm_prereq(DEFAULT_TARGET))
+ if (dm_prereq())
exit(1);
if (load_config(DEFAULT_CONFIGFILE))
if (conf->remove == FLUSH_ONE) {
if (conf->dev_type == DEV_DEVMAP)
- dm_flush_map(conf->dev, DEFAULT_TARGET);
+ dm_flush_map(conf->dev);
else
condlog(0, "must provide a map name to remove");
goto out;
}
else if (conf->remove == FLUSH_ALL) {
- dm_flush_maps(DEFAULT_TARGET);
+ dm_flush_maps();
goto out;
}
while ((r = configure()) < 0)
* remove all current maps not allowed by the
* current configuration
*/
- if (dm_flush_map(ompp->alias, DEFAULT_TARGET)) {
+ if (dm_flush_map(ompp->alias)) {
condlog(0, "%s: unable to flush devmap",
ompp->alias);
/*
* clear references to this map before flushing so we can ignore
* the spurious uevent we may generate with the dm_flush_map call below
*/
- if (dm_flush_map(mpp->alias, DEFAULT_TARGET)) {
+ if (dm_flush_map(mpp->alias)) {
/*
* May not really be an error -- if the map was already flushed
* from the device mapper by dmsetup(8) for instance.
map_present = dm_map_present(alias);
- if (map_present && dm_type(alias, DEFAULT_TARGET) <= 0) {
+ if (map_present && dm_type(alias, TGT_MPATH) <= 0) {
condlog(4, "%s: not a multipath map", alias);
return 0;
}
struct multipath * mpp;
unsigned int i;
- if (dm_get_maps(vecs->mpvec, "multipath"))
+ if (dm_get_maps(vecs->mpvec))
return 1;
vector_foreach_slot (vecs->mpvec, mpp, i)