miscellaneous dm-multipath patches
Benjamin Marzinski
maintainercover miscellaneous dm-multipath patches
Here are a number of bugfixes and minor features. The first 8 are a resubmit of the patches I sent on Jun 28th. I didn't see any objection to any of them, so I just rebased them.
Benjamin Marzinski (16):
Add multipath path format wildcard
Fix multipath rename from user_friendly_name to wwid Turn off user_friendly_names for netapp devices
Don't detect prioritizers that don't work
Only load a multipath device RO if RW load fails with EROFS signal waiter thread to stop waiting on dm events
fix mutipath -W on empty wwids file
multipathd: Add envp variable
libmultipath: try to deal with bindings file hand editting
kpartx: Make kpartx able to create read-only loop devices
libmultipath: show default configurations
multipathd: Don't touch the multipath device after setup_multipath
fails
kpartx: fix strict aliasing warning
libmultipath: blacklist blktap devices
multipathd: allow /dev/<devnode> to be used for multipathd commands
kpartx: autoload loop module on loop partition creation
kpartx/dasd.c | 4 +- kpartx/kpartx.c | 3 +- kpartx/lopart.c | 19 +++++++-- libmultipath/alias.c | 39 ++++++++++++++----- libmultipath/blacklist.c | 2 +- libmultipath/configure.c | 7 ---- libmultipath/devmapper.c | 98 ++++++++++++----------------------------------- libmultipath/devmapper.h | 3 -- libmultipath/dict.c | 4 -- libmultipath/hwtable.c | 1 + libmultipath/print.c | 11 ++++++ libmultipath/propsel.c | 13 +++++-- libmultipath/util.c | 22 +++++++++++ libmultipath/util.h | 1 + libmultipath/waiter.c | 9 +++++ libmultipath/wwids.c | 6 +++ multipath/main.c | 23 +---------- multipathd/cli_handlers.c | 21 +++++++++- multipathd/main.c | 21 +++++++--- 19 files changed, 171 insertions(+), 136 deletions(-)
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 1/16 Add multipath path format wildcard
This adds a new format wildcard, 'm', to be used with
multipathd show paths format
It prints the multipath device associated with the path.
--- libmultipath/print.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
libmultipath/print.c +11 -0
@@ -426,6 +426,16 @@ snprint_path_serial (char * buff, size_t len, struct path * pp) }static int +snprint_path_mpp (char * buff,size_t len,struct path * pp) +{ +if (!pp->mpp) +return snprintf (buff, len,"[orphan]" ); +if (!pp->mpp->alias) +return snprintf (buff, len,"[unknown]" ); +return snprint_str (buff, len, pp->mpp->alias); +} + +static int snprint_path_checker (char * buff,size_t len,struct path * pp) {struct checker * c = &pp->checker;
@@ -468,6 +478,7 @@ struct path_data pd[] = { {'p', "pri", 0, snprint_pri}, {'S', "size", 0, snprint_path_size}, {'z', "serial", 0, snprint_path_serial}, + {'m', "multipath", 0, snprint_path_mpp}, {0, NULL, 0 , NULL} };
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 2/16 Fix multipath rename from user_friendly_name to wwid
In reply to Benjamin MarzinskiWhen multipath was selecting an alias for a device on reload, if it didn't have an explicit alias, and user_friendly_names wasn't set, multipath would use the existing alias, if one existed. This made it impossible to turn off user_friendly_names, and then reconfigure to change the device names back to wwids.
Instead, multipath should just use the wwid as an alias, if that's what it's configured to do, regardless of the existing name.
--- libmultipath/devmapper.c | 45 --------------------------------------------- libmultipath/devmapper.h | 1 - libmultipath/propsel.c | 2 -- 3 files changed, 48 deletions(-)
libmultipath/devmapper.c +0 -45
@@ -922,51 +922,6 @@ out:return r; } -extern char * -dm_get_name (char *uuid) -{ -struct dm_task *dmt; -struct dm_info info; -char *prefixed_uuid, *name =NULL ; -const char *nametmp; - - dmt =dm_task_create (DM_DEVICE_INFO ); -if (!dmt) -return NULL ; - - prefixed_uuid =MALLOC (UUID_PREFIX_LEN +strlen (uuid) +1 ); -if (!prefixed_uuid) { -condlog (0 ,"cannot create prefixed uuid : %s" , -strerror (errno)); - goto freeout; - } -sprintf (prefixed_uuid,UUID_PREFIX "%s" , uuid); -if (!dm_task_set_uuid (dmt, prefixed_uuid)) - goto freeout; - -if (!dm_task_run (dmt)) - goto freeout; - -if (!dm_task_get_info (dmt, &info) || !info.exists) - goto freeout; - - nametmp =dm_task_get_name (dmt); -if (nametmp &&strlen (nametmp)) { - name =MALLOC (strlen (nametmp) +1 ); -if (name) -strcpy (name, nametmp); - }else { -condlog (2 ,"%s: no device-mapper name found" , uuid); - } - -freeout: -if (prefixed_uuid) -FREE (prefixed_uuid); -dm_task_destroy (dmt); - -return name; -} -int dm_geteventnr (char *name) {
libmultipath/devmapper.h +0 -1
@@ -39,7 +39,6 @@ int dm_remove_partmaps (const char * mapname, int need_sync);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); -char *dm_get_name (char * uuid);int dm_reassign (const char * mapname);int dm_reassign_table (const char *name,char *old,char *new);int dm_setgeometry (struct multipath *mpp);
libmultipath/propsel.c +0 -2
@@ -263,8 +263,6 @@ select_alias (struct multipath * mp) conf->bindings_file, mp->alias_prefix, conf->bindings_read_only); }if (mp->alias ==NULL ) - mp->alias =dm_get_name (mp->wwid); -if (mp->alias ==NULL ) mp->alias =STRDUP (mp->wwid); }
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 3/16 Turn off user_friendly_names for netapp devices
In reply to Benjamin MarzinskiNetapp has requested that even if user friendly names is enabled in the defaults section, they would like it disabled for their devices.
--- libmultipath/hwtable.c | 1 + 1 file changed, 1 insertion(+)
libmultipath/hwtable.c +1 -0
@@ -794,6 +794,7 @@ static struct hwentry default_hw[] = { .prio_name = PRIO_ONTAP, .prio_args = NULL, .retain_hwhandler = RETAIN_HWHANDLER_ON, + .user_friendly_names = USER_FRIENDLY_NAMES_OFF, .detect_prio = DETECT_PRIO_ON, },/*
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 4/16 Don't detect prioritizers that don't work
In reply to Benjamin MarzinskiThe current method used by detect_prio was selecting the ALUA prioritizer for devices that didn't have ALUA enabled. This patch makes detect_prio go through all the steps to get a priority with the ALUA prioritizer. If it is able to successfully get a priority, then it selects the ALUA proritizer for the device.
--- libmultipath/propsel.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
libmultipath/propsel.c +9 -2
@@ -396,10 +396,17 @@ select_getuid (struct path * pp)void detect_prio (struct path * pp) { +int ret;struct prio *p = &pp->prio; -if (get_target_port_group_support (pp->fd) >0 ) -prio_get (p,PRIO_ALUA ,DEFAULT_PRIO_ARGS ); +if (get_target_port_group_support (pp->fd) <=0 ) +return ; + ret =get_target_port_group (pp->fd); +if (ret <0 ) +return ; +if (get_asymmetric_access_state (pp->fd, ret) <0 ) +return ; +prio_get (p,PRIO_ALUA ,DEFAULT_PRIO_ARGS ); } extern int
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 5/16 Only load a multipath device RO if RW load fails with EROFS
In reply to Benjamin MarzinskiIf a transient error keeps multipath from being able to reload a multipath device read/write, it will retry the reload with the device set to read-only. This can suddenly turn a read/write multipath device read-only. If device-mapper cannot load the device read/write because a path device can't be opened for writing, it will return EROFS. This is the only time it makes sense to reload the device read-only.
--- libmultipath/configure.c | 7 ------- libmultipath/devmapper.c | 53 +++++++++++++++++++++++------------------------- libmultipath/devmapper.h | 2 -- 3 files changed, 25 insertions(+), 37 deletions(-)
libmultipath/configure.c +0 -7
@@ -383,24 +383,17 @@ domap (struct multipath * mpp, char * params) r =dm_addmap_create (mpp, params); -if (!r) - r =dm_addmap_create_ro (mpp, params); -lock_multipath (mpp,0 );break ;case ACT_RELOAD : r =dm_addmap_reload (mpp, params); -if (!r) - r =dm_addmap_reload_ro (mpp, params);if (r) r =dm_simplecmd_noflush (DM_DEVICE_RESUME , mpp->alias);break ;case ACT_RESIZE : r =dm_addmap_reload (mpp, params); -if (!r) - r =dm_addmap_reload_ro (mpp, params);if (r) r =dm_simplecmd_flush (DM_DEVICE_RESUME , mpp->alias,1 );break ;
libmultipath/devmapper.c +25 -28
67 lines not on this page · raw message
libmultipath/devmapper.h +0 -2
@@ -12,9 +12,7 @@ int dm_drv_version (unsigned int * version, char * str);int dm_simplecmd_flush (int ,const char *,int );int dm_simplecmd_noflush (int ,const char *);int dm_addmap_create (struct multipath *mpp,char *params); -int dm_addmap_create_ro (struct multipath *mpp,char *params);int dm_addmap_reload (struct multipath *mpp,char *params); -int dm_addmap_reload_ro (struct multipath *mpp,char *params);int dm_map_present (const char *);int dm_get_map (const char *,unsigned long long *,char *);int dm_get_status (char *,char *);
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 6/16 signal waiter thread to stop waiting on dm events
In reply to Benjamin MarzinskiThe ioctl syscall is not a pthread cancellation point. So, when device-mapper is waiting on events, pthread_cancel won't cancel the waiter thread. This patch makes the waiter threads handle SIGUSR2, and has stop_waiter_thread() signal it to break out of waiting on dm events. Unfortunately, there is still a possibility of the signal arriving before the ioctl, and the waiter thread still hanging until the devices are reloaded.
--- libmultipath/waiter.c | 9 +++++++++ multipathd/main.c | 8 ++++++++ 2 files changed, 17 insertions(+)
libmultipath/waiter.c +9 -0
@@ -57,6 +57,7 @@ void stop_waiter_thread (struct multipath *mpp, struct vectors *vecs) thread = mpp->waiter; mpp->waiter = (pthread_t )0 ;pthread_cancel (thread); +pthread_kill (thread,SIGUSR2 ); }/*
@@ -65,6 +66,7 @@ void stop_waiter_thread (struct multipath *mpp, struct vectors *vecs)*/ int waiteventloop (struct event_thread *waiter) { +sigset_t set, oldset;int event_nr;int r;
@@ -97,8 +99,15 @@ int waiteventloop (struct event_thread *waiter)dm_task_no_open_count (waiter->dmt);/* wait */ +sigemptyset (&set); +sigaddset (&set,SIGUSR2 ); +pthread_sigmask (SIG_UNBLOCK , &set, &oldset); + +pthread_testcancel (); r =dm_task_run (waiter->dmt); +pthread_testcancel (); +pthread_sigmask (SIG_SETMASK , &oldset,NULL );dm_task_destroy (waiter->dmt); waiter->dmt =NULL ;
multipathd/main.c +8 -0
@@ -1521,6 +1521,12 @@ sigusr1 (int sig) }static void +sigusr2 (int sig) +{ +condlog (3 ,"SIGUSR2 received" ); +} + +static void signal_init (void ) {sigset_t set;
@@ -1528,10 +1534,12 @@ signal_init(void)sigemptyset (&set);sigaddset (&set,SIGHUP );sigaddset (&set,SIGUSR1 ); +sigaddset (&set,SIGUSR2 );pthread_sigmask (SIG_BLOCK , &set,NULL );signal_set (SIGHUP , sighup);signal_set (SIGUSR1 , sigusr1); +signal_set (SIGUSR2 , sigusr2);signal_set (SIGINT , sigend);signal_set (SIGTERM , sigend);signal (SIGPIPE ,SIG_IGN );
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 7/16 fix mutipath -W on empty wwids file
In reply to Benjamin MarzinskiWhen multipath tries to open the wwids file and finds it empty or missing, it writes the header to the file. When it tried to wipe the wwids from an empty or missing file, it didn't seek back to the start of the file after truncating it. This caused the the wwids file to have a patch of zeroed bytes at the start. This patch fixes this by always seeking back to the start of the file before rewriting the header.
--- libmultipath/wwids.c | 6 ++++++ 1 file changed, 6 insertions(+)
libmultipath/wwids.c +6 -0
@@ -4,6 +4,7 @@#include <string.h> #include <limits.h> #include <stdio.h> +#include <sys/types.h> #include "checkers.h" #include "vector.h"
@@ -100,6 +101,11 @@ replace_wwids(vector mp)condlog (0 ,"cannot truncate wwids file : %s" ,strerror (errno)); goto out_file; } +if (lseek (fd,0 ,SEEK_SET ) <0 ) { +condlog (0 ,"cannot seek to the start of the file : %s" , +strerror (errno)); + goto out_file; + } len =strlen (WWIDS_FILE_HEADER );if (write_all (fd,WWIDS_FILE_HEADER , len) != len) { condlog(0, "Can't write wwid file header : %s",
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 8/16 multipathd: Add envp variable
In reply to Benjamin MarzinskiA missing variable declaration was keeping multipathd from compiling.
--- multipathd/main.c | 1 + 1 file changed, 1 insertion(+)
multipathd/main.c +1 -0
@@ -1617,6 +1617,7 @@ child (void * param)struct multipath * mpp;int i;int rc, pid_rc; +char *envp;mlockall (MCL_CURRENT |MCL_FUTURE );sem_init (&exit_sem,0 ,0 );
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerRe: [PATCH 08/16] multipathd: Add envp variable
On Wed, Dec 11, 2013 at 12:43:02AM -0600, Benjamin Marzinski wrote:
I just thought I'd get in on the fun too.
Oops.
-Ben
Quoted 26 lines
A missing variable declaration was keeping multipathd from compiling.
Signed-off-by Benjamin Marzinski <[email protected]>--- multipathd/main.c | 1 + 1 file changed, 1 insertion(+)multipathd/main.c +1
-0@@ -1617,6 +1617,7 @@ child (void * param)struct multipath * mpp;int i;int rc, pid_rc; +char *envp;mlockall (MCL_CURRENT |MCL_FUTURE );sem_init (&exit_sem,0 ,0 );Signature · 6 lines
1.8.4.2 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Benjamin Marzinski
maintainerPATCH 9/16 libmultipath: try to deal with bindings file hand editting
In reply to Benjamin MarzinskiUnfortunately, instead of adding aliases to /etc/multipath.conf like they should, some users add aliases to the bindings file. If they add aliases that look like user_friendly_names, like mpathfoo, they interfere with the code to find the next available user_friendly_name (giving you mpathfop as the next user_friendly_name in this case). This patch will fix this by giving the next name available name after an unbroken string of names starting with the smallest possible name. It order to keep the choice quick, it won't handle situation where the list of names starting at the smallest possible is not in order. There are a number of ways to do a better job finding the smallest possible name, but this will fix most of the cases I've seen, without slowing things down at all.
--- libmultipath/alias.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-)
libmultipath/alias.c +30 -9
@@ -46,11 +46,11 @@ format_devname(char *name, int id, int len, char *prefix)memset (name,0 , len);strcpy (name, prefix);for (pos = len -1 ; pos >= prefix_len; pos--) { + id--; name[pos] ='a' + id %26 ;if (id <26 )break ; id /=26 ; - id--; }memmove (name + prefix_len, name + pos, len - pos); name[prefix_len + len - pos] ='\0' ;
@@ -66,13 +66,22 @@ scan_devname(char *alias, char *prefix)if (!prefix ||strncmp (alias, prefix,strlen (prefix)))return -1 ; +if (strlen (alias) ==strlen (prefix)) +return -1 ; + +if (strlen (alias) >strlen (prefix) +7 ) +/* id of 'aaaaaaaa' overflows int */ +return -1 ; + c = alias +strlen (prefix);while (*c !='\0' && *c !=' ' && *c !='\t' ) { +if (*c <'a' || *c >'z' ) +return -1 ; i = *c -'a' ; n = ( n *26 ) + i; +if (n <0 ) +return -1 ; c++; -if (*c <'a' || *c >'z' ) -break ; n++; }
@@ -84,7 +93,9 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias, char *prefix) {char buf[LINE_MAX ];unsigned int line_nr =0 ; -int id =0 ; +int id =1 ; +int biggest_id =1 ; +int smallest_bigger_id =INT_MAX ; *map_alias =NULL ;
@@ -100,8 +111,12 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias, char *prefix)if (!alias)/* blank line */ continue ; curr_id =scan_devname (alias, prefix); -if (curr_id >= id) - id = curr_id +1 ; +if (curr_id == id) + id++; +if (curr_id > biggest_id) + biggest_id = curr_id; +if (curr_id > id && curr_id < smallest_bigger_id) + smallest_bigger_id = curr_id; wwid =strtok (NULL ," \t" );if (!wwid){ condlog(3,
@@ -116,11 +131,17 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias, char *prefix)if (*map_alias ==NULL )condlog (0 ,"Cannot copy alias from bindings " "file : %s" ,strerror (errno)); -return id; +return 0 ; } }condlog (3 ,"No matching wwid [%s] in bindings file." , map_wwid); -return id; +if (id <0 ) { +condlog (0 ,"no more available user_friendly_names" ); +return 0 ; + } +if (id < smallest_bigger_id) +return id; +return biggest_id +1 ; } static int
@@ -254,7 +275,7 @@ get_user_friendly_alias(char *wwid, char *file, char *prefix,return NULL ; } -if (!alias && can_write && !bindings_read_only) +if (!alias && can_write && !bindings_read_only && id) alias =allocate_binding (fd, wwid, id, prefix);fclose (f);
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 10/16 kpartx: Make kpartx able to create read-only loop devices
In reply to Benjamin MarzinskiThis just passes the read-only value into set_loop, and falls back to read-only mapping on EACCESS to handle immutable files.
--- kpartx/kpartx.c | 3 +-- kpartx/lopart.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
kpartx/kpartx.c +1 -2
@@ -205,7 +205,6 @@ main(int argc, char **argv){char * delim =NULL ;char *uuid =NULL ;char *mapname =NULL ; -int loopro =0 ;int hotplug =0 ;int loopcreated =0 ;struct stat buf;
@@ -316,7 +315,7 @@ main(int argc, char **argv){if (!loopdev) { loopdev =find_unused_loop_device (); -if (set_loop (loopdev, device,0 , &loopro)) { +if (set_loop (loopdev, device,0 , &ro)) {fprintf (stderr,"can't set up loop\n" );exit (1 ); }
kpartx/lopart.c +1 -1
@@ -230,7 +230,7 @@ set_loop (const char *device, const char *file, int offset, int *loopro)if ((ffd =open (file, mode)) <0 ) { -if (!*loopro && errno ==EROFS ) +if (!*loopro && (errno ==EROFS || errno ==EACCES )) ffd =open (file, mode =O_RDONLY );if (ffd <0 ) {
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 11/16 libmultipath: show default configurations
In reply to Benjamin Marzinski"multipathd show config" should show the current configuration, even if the current values match the default values. Omitting the values when they match the compiled in defaults just makes it harder for users to see how multipath configured.
--- libmultipath/dict.c | 4 ---- 1 file changed, 4 deletions(-)
libmultipath/dict.c +0 -4
@@ -2459,16 +2459,12 @@ snprint_def_verbosity (char * buff, int len, void * data)static int snprint_def_max_polling_interval (char * buff,int len,void * data) { -if (conf->max_checkint ==MAX_CHECKINT (conf->checkint)) -return 0 ;return snprintf (buff, len,"%i" , conf->max_checkint); }static int snprint_reassign_maps (char * buff,int len,void * data) { -if (conf->reassign_maps ==DEFAULT_REASSIGN_MAPS ) -return 0 ;return snprintf (buff, len,"\"%s\"" , conf->reassign_maps?"yes" :"no" ); }
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 12/16 multipathd: Don't touch the multipath device after setup_multipath fails
In reply to Benjamin MarzinskiIf setup_multipath fails, it removes the device. multipath always needs to check its return value and not touch the device if setup_multipath failed.
--- multipathd/cli_handlers.c | 3 ++- multipathd/main.c | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-)
multipathd/cli_handlers.c +2 -1
@@ -634,7 +634,8 @@ cli_resize(void *v, char **reply, int *len, void *data)return 1 ;dm_lib_release (); -setup_multipath (vecs, mpp); +if (setup_multipath (vecs, mpp) !=0 ) +return 1 ;sync_map_state (mpp);return 0 ;
multipathd/main.c +6 -6
@@ -139,7 +139,6 @@ coalesce_maps(struct vectors *vecs, vector nmpv)struct multipath * ompp;vector ompv = vecs->mpvec;unsigned int i; -int j; vector_foreach_slot (ompv, ompp, i) {condlog (3 ,"%s: coalesce map" , ompp->alias);
@@ -154,16 +153,17 @@ coalesce_maps(struct vectors *vecs, vector nmpv)/* * may be just because the device is open */ +if (setup_multipath (vecs, ompp) !=0 ) { + i--; +continue ; + }if (!vector_alloc_slot (nmpv))return 1 ;vector_set_slot (nmpv, ompp); -setup_multipath (vecs, ompp); -if ((j =find_slot (ompv, (void *)ompp)) !=-1 ) -vector_del_slot (ompv, j); - -continue ; +vector_del_slot (ompv, i); + i--; }else {dm_lib_release ();
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 13/16 kpartx: fix strict aliasing warning
In reply to Benjamin MarzinskiCompiling with strict aliasing throws warnings about aliasing volume_label_t to an array of unsigned ints. Adding __may_alias__ lets it know that we meant to do this.
--- kpartx/dasd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kpartx/dasd.c +3 -1
@@ -46,6 +46,8 @@ unsigned long long sectors512(unsigned long long sectors, int blocksize)return sectors * (blocksize >>9 ); } +typedef unsigned int __attribute__((__may_alias__)) label_ints_t; +/* */ int
@@ -169,7 +171,7 @@ read_dasd_pt(int fd, struct slice all, struct slice *sp, int ns)/* * VM style CMS1 labeled disk */ -unsigned int *label = (unsigned int *) &vlabel; +label_ints_t *label = (label_ints_t *) &vlabel; blocksize = label[4 ];if (label[14 ] !=0 ) {
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 14/16 libmultipath: blacklist blktap devices
In reply to Benjamin MarzinskiMultipath can't run on top of blktap devices, so it should just ignore them.
--- libmultipath/blacklist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/blacklist.c +1 -1
@@ -164,7 +164,7 @@ setup_default_blist (struct config * conf)if (store_ble (conf->blist_devnode, str,ORIGIN_DEFAULT ))return 1 ; - str =STRDUP ("^hd[a-z]" ); + str =STRDUP ("^(td|hd)[a-z]" );if (!str)return 1 ;if (store_ble (conf->blist_devnode, str,ORIGIN_DEFAULT ))
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 15/16 multipathd: allow /dev/<devnode> to be used for multipathd commands
In reply to Benjamin MarzinskiMultipathd expects that path and map names used in its interactive commands are sysfs names with no directory. However, users often try used /dev names instead. This patch makes multipathd convert the /dev names to sysfs names like the multipath command does.
--- libmultipath/util.c | 22 ++++++++++++++++++++++ libmultipath/util.h | 1 + multipath/main.c | 23 +---------------------- multipathd/cli_handlers.c | 18 ++++++++++++++++++ 4 files changed, 42 insertions(+), 22 deletions(-)
libmultipath/util.c +22 -0
@@ -235,6 +235,28 @@ skip_proc:return 0 ; } +/* This function returns a pointer inside of the supplied pathname string. +* If is_path_device is true, it may also modify the supplied string */ +char *convert_dev (char *name,int is_path_device) +{ +char *ptr; + +if (!name) +return NULL ; +if (is_path_device) { + ptr =strstr (name,"cciss/" ); +if (ptr) { + ptr +=5 ; + *ptr ='!' ; + } + } +if (!strncmp (name,"/dev/" ,5 ) &&strlen (name) >5 ) + ptr = name +5 ; +else + ptr = name; +return ptr; +} +dev_t parse_devt (const char *dev_t) {int maj, min;
libmultipath/util.h +1 -0
@@ -10,6 +10,7 @@ size_t strlcat(char *dst, const char *src, size_t size);void remove_trailing_chars (char *path,char c);int devt2devname (char *,int ,char *);dev_t parse_devt (const char *dev_t); +char *convert_dev (char *dev,int is_path_device); #define safe_sprintf(var, format, args...) \ snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
multipath/main.c +1 -22
@@ -255,16 +255,7 @@ configure (void) vecs.pathvec = pathvec; vecs.mpvec = curmp; -/* -* dev is "/dev/" . "sysfs block dev" -*/ -if (conf->dev) { -if (!strncmp (conf->dev,"/dev/" ,5 ) && -strlen (conf->dev) >5 ) - dev = conf->dev +5 ; -else - dev = conf->dev; - } + dev =convert_dev (conf->dev, (conf->dev_type ==DEV_DEVNODE ));/* * if we have a blacklisted device parameter, exit early
@@ -428,16 +419,6 @@ get_dev_type(char *dev) {return DEV_DEVMAP ; } -static void -convert_dev (char *dev) -{ -char *ptr =strstr (dev,"cciss/" ); -if (ptr) { - ptr +=5 ; - *ptr ='!' ; - } -} -int main (int argc,char *argv[]) {
@@ -552,8 +533,6 @@ main (int argc, char *argv[])strncpy (conf->dev, argv[optind],FILE_NAME_SIZE ); conf->dev_type =get_dev_type (conf->dev); -if (conf->dev_type ==DEV_DEVNODE ) -convert_dev (conf->dev); } conf->daemon =0 ;
multipathd/cli_handlers.c +18 -0
@@ -235,6 +235,7 @@ cli_list_map_topology (void * v, char ** reply, int * len, void * data)struct vectors * vecs = (struct vectors *)data;char * param =get_keyparam (v,MAP ); + param =convert_dev (param,0 );get_path_layout (vecs->pathvec,0 ); mpp =find_mp_by_str (vecs->mpvec, param);
@@ -416,6 +417,7 @@ cli_add_path (void * v, char ** reply, int * len, void * data)struct path *pp;int r; + param =convert_dev (param,1 );condlog (2 ,"%s: add path (operator)" , param); if (filter_devnode(conf->blist_devnode, conf->elist_devnode,
@@ -459,6 +461,7 @@ cli_del_path (void * v, char ** reply, int * len, void * data)char * param =get_keyparam (v,PATH );struct path *pp; + param =convert_dev (param,1 );condlog (2 ,"%s: remove path (operator)" , param); pp =find_path_by_dev (vecs->pathvec, param);if (!pp) {
@@ -478,6 +481,7 @@ cli_add_map (void * v, char ** reply, int * len, void * data)char *alias;int rc; + param =convert_dev (param,0 );condlog (2 ,"%s: add map (operator)" , param);if (filter_wwid (conf->blist_wwid, conf->elist_wwid, param) >0 ) {
@@ -518,6 +522,7 @@ cli_del_map (void * v, char ** reply, int * len, void * data)char *alias;int rc; + param =convert_dev (param,0 );condlog (2 ,"%s: remove map (operator)" , param); minor =dm_get_minor (param);if (minor <0 ) {
@@ -549,6 +554,7 @@ cli_reload(void *v, char **reply, int *len, void *data)struct multipath *mpp;int minor; + mapname =convert_dev (mapname,0 );condlog (2 ,"%s: reload map (operator)" , mapname);if (sscanf (mapname,"dm-%d" , &minor) ==1 ) mpp =find_mp_by_minor (vecs->mpvec, minor);
@@ -593,6 +599,7 @@ cli_resize(void *v, char **reply, int *len, void *data)struct pathgroup *pgp;struct path *pp; + mapname =convert_dev (mapname,0 );condlog (2 ,"%s: resize map (operator)" , mapname);if (sscanf (mapname,"dm-%d" , &minor) ==1 ) mpp =find_mp_by_minor (vecs->mpvec, minor);
@@ -667,6 +674,7 @@ cli_restore_queueing(void *v, char **reply, int *len, void *data)struct multipath *mpp;int minor; + mapname =convert_dev (mapname,0 );condlog (2 ,"%s: restore map queueing (operator)" , mapname);if (sscanf (mapname,"dm-%d" , &minor) ==1 ) mpp =find_mp_by_minor (vecs->mpvec, minor);
@@ -718,6 +726,7 @@ cli_disable_queueing(void *v, char **reply, int *len, void *data)struct multipath *mpp;int minor; + mapname =convert_dev (mapname,0 );condlog (2 ,"%s: disable map queueing (operator)" , mapname);if (sscanf (mapname,"dm-%d" , &minor) ==1 ) mpp =find_mp_by_minor (vecs->mpvec, minor);
@@ -755,6 +764,7 @@ cli_switch_group(void * v, char ** reply, int * len, void * data)char * mapname =get_keyparam (v,MAP );int groupnum =atoi (get_keyparam (v,GROUP )); + mapname =convert_dev (mapname,0 );condlog (2 ,"%s: switch to path group #%i (operator)" , mapname, groupnum);return dm_switchgroup (mapname, groupnum);
@@ -777,6 +787,7 @@ cli_suspend(void * v, char ** reply, int * len, void * data)char * param =get_keyparam (v,MAP );int r =dm_simplecmd_noflush (DM_DEVICE_SUSPEND , param); + param =convert_dev (param,0 );condlog (2 ,"%s: suspend (operator)" , param);if (!r)/* error */
@@ -798,6 +809,7 @@ cli_resume(void * v, char ** reply, int * len, void * data)char * param =get_keyparam (v,MAP );int r =dm_simplecmd_noflush (DM_DEVICE_RESUME , param); + param =convert_dev (param,0 );condlog (2 ,"%s: resume (operator)" , param);if (!r)/* error */
@@ -819,6 +831,7 @@ cli_reinstate(void * v, char ** reply, int * len, void * data)char * param =get_keyparam (v,PATH );struct path * pp; + param =convert_dev (param,1 ); pp =find_path_by_dev (vecs->pathvec, param);if (!pp)
@@ -839,6 +852,7 @@ cli_reassign (void * v, char ** reply, int * len, void * data) {char * param =get_keyparam (v,MAP ); + param =convert_dev (param,0 );condlog (3 ,"%s: reset devices (operator)" , param);dm_reassign (param);
@@ -853,6 +867,7 @@ cli_fail(void * v, char ** reply, int * len, void * data)struct path * pp;int r; + param =convert_dev (param,1 ); pp =find_path_by_dev (vecs->pathvec, param);if (!pp)
@@ -964,6 +979,7 @@ cli_getprstatus (void * v, char ** reply, int * len, void * data)struct vectors * vecs = (struct vectors *)data;char * param =get_keyparam (v,MAP ); + param =convert_dev (param,0 );get_path_layout (vecs->pathvec,0 ); mpp =find_mp_by_str (vecs->mpvec, param);
@@ -993,6 +1009,7 @@ cli_setprstatus(void * v, char ** reply, int * len, void * data)struct vectors * vecs = (struct vectors *)data;char * param =get_keyparam (v,MAP ); + param =convert_dev (param,0 );get_path_layout (vecs->pathvec,0 ); mpp =find_mp_by_str (vecs->mpvec, param);
@@ -1015,6 +1032,7 @@ cli_unsetprstatus(void * v, char ** reply, int * len, void * data)struct vectors * vecs = (struct vectors *)data;char * param =get_keyparam (v,MAP ); + param =convert_dev (param,0 );get_path_layout (vecs->pathvec,0 ); mpp =find_mp_by_str (vecs->mpvec, param);
Signature · 1 line
1.8.4.2
Benjamin Marzinski
maintainerPATCH 16/16 kpartx: autoload loop module on loop partition creation
In reply to Benjamin MarzinskiCurrently kpartx doesn't do anything to force the loop module to autoload, so creating partitions over files fails if the loop module isn't already loaded. This patch makes kpartx try to find the next available loop device by ioctling /dev/loop-control, which will autoload kpartx.
--- kpartx/lopart.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
kpartx/lopart.c +15 -2
@@ -32,6 +32,10 @@#include "lopart.h" #include "xstrncpy.h" +#ifndef LOOP_CTL_GET_FREE +#define LOOP_CTL_GET_FREE 0x4C82 +#endif +#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) \ && !defined (__s390x__)#define int2ptr (x) ((void *) ((int) x))
@@ -140,14 +144,23 @@ find_unused_loop_device (void)char dev[20 ];char *loop_formats[] = {"/dev/loop%d" ,"/dev/loop/%d" }; -int i, j, fd, somedev =0 , someloop =0 , loop_known =0 ; +int i, j, fd, first =0 , somedev =0 , someloop =0 , loop_known =0 ;struct stat statbuf;struct loop_info loopinfo;FILE *procdev; +if (stat ("/dev/loop-control" , &statbuf) ==0 && +S_ISCHR (statbuf.st_mode)) { + fd =open ("/dev/loop-control" ,O_RDWR ); +if (fd >=0 ) + first =ioctl (fd,LOOP_CTL_GET_FREE ); +close (fd); +if (first <0 ) + first =0 ; + }for (j =0 ; j <SIZE (loop_formats); j++) { -for (i =0 ; i <256 ; i++) { +for (i = first; i <256 ; i++) {sprintf (dev, loop_formats[j], i);if (stat (dev, &statbuf) ==0 &&S_ISBLK (statbuf.st_mode)) {
Signature · 1 line
1.8.4.2
Nice collection of fixes.
Merged, with many thanks.
Christophe Varoqui
www.opensvc.com
Quoted 50 lines · Benjamin Marzinski
Here are a number of bugfixes and minor features. The first 8 are a resubmit of the patches I sent on Jun 28th. I didn't see any objection to any of them, so
I just rebased them.Benjamin Marzinski (16):
Add multipath path format wildcard
Fix multipath rename fromuser_friendly_nameto wwid Turn offuser_friendly_namesfor netapp devices
Don't detect prioritizers that don't work
Only load a multipath device RO if RW load fails with EROFS signal waiter thread to stop waiting on dm events
fix mutipath -W on empty wwids file
multipathd: Add envp variable
libmultipath: try to deal with bindings file hand editting
kpartx: Make kpartx able to create read-only loop devices
libmultipath: show default configurations
multipathd: Don't touch the multipath device aftersetup_multipath
fails
kpartx: fix strict aliasing warning
libmultipath: blacklist blktap devices
multipathd: allow /dev/<devnode> to be used for multipathd commands
kpartx: autoload loop module on loop partition creationkpartx/dasd.c | 4 +- kpartx/kpartx.c | 3 +- kpartx/lopart.c | 19 +++++++-- libmultipath/alias.c | 39 ++++++++++++++----- libmultipath/blacklist.c | 2 +- libmultipath/configure.c | 7 ---- libmultipath/devmapper.c | 98 ++++++++++++----------------------------------- libmultipath/devmapper.h | 3 -- libmultipath/dict.c | 4 -- libmultipath/hwtable.c | 1 + libmultipath/print.c | 11 ++++++ libmultipath/propsel.c | 13 +++++-- libmultipath/util.c | 22 +++++++++++ libmultipath/util.h | 1 + libmultipath/waiter.c | 9 +++++ libmultipath/wwids.c | 6 +++ multipath/main.c | 23 +---------- multipathd/cli_handlers.c | 21 +++++++++- multipathd/main.c | 21 +++++++--- 19 files changed, 171 insertions(+), 136 deletions(-)--
1.8.4.2