multipath-patches for 0.8.2
cover multipath-patches for 0.8.2
From: Martin Wilck <[email protected]>
Hi Christophe,
as you requested, I'm resending the recent kpartx/DASD patch on top of 0.8.2. I'm resending 3 other previously posted patches, too. First and foremost, Ben's "vector_foreach_slot_backwards" patch. The last two have not been acked by Ben, or otherwise reviewed, yet.
Benjamin Marzinski (1):
libmultipath: make vector_foreach_slot_backwards work as expected
Martin Wilck (3):
kpartx: recognize DASD on loop devices again multipath-tools (coverity): assert availability of CLOCK_MONOTONIC
libmultipath: trigger uevents for partitions, too
kpartx/dasd.c | 7 ++++--- libmultipath/checkers/tur.c | 6 +++--- libmultipath/configure.c | 38 +++++++++++++++++++++++++++++++++++++ libmultipath/time-util.c | 9 +++++++++ libmultipath/time-util.h | 1 + libmultipath/vector.h | 2 +- multipathd/main.c | 34 +++++++++++++-------------------- multipathd/uxlsnr.c | 8 +++----- 8 files changed, 72 insertions(+), 33 deletions(-)
Signature · 1 line
2.22.0
PATCH 1/4 libmultipath: make vector_foreach_slot_backwards work as expected
From: Benjamin Marzinski <[email protected]>
All of the code that uses vector_foreach_slot_backwards() treats "i" as the index of the entry "p", but the way it was coded, that wasn't the case. "i" was the number of the entry counting from 1, not 0.
--- libmultipath/vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmultipath/vector.h +1 -1
@@ -40,7 +40,7 @@ typedef struct _vector *vector;#define vector_foreach_slot_after (v,p,i) \ for (; (v) && i < VECTOR_SIZE(v) && ((p) = (v)->slot[i]); i++)#define vector_foreach_slot_backwards (v,p,i) \ - for (i = VECTOR_SIZE(v); i > 0 && ((p) = (v)->slot[i-1]); i--) + for (i = VECTOR_SIZE(v) - 1; (int)i >= 0 && ((p) = (v)->slot[i]); i--)#define identity (x) (x)/*
Signature · 1 line
2.22.0
PATCH 2/4 kpartx: recognize DASD on loop devices again
In reply to Martin WilckFrom: Martin Wilck <[email protected]>
Since 4d57b868, DASD partition tables are only recognized on DASD hardware. This turns out to break certain software that works e.g. with DASD partition tables on loop devices. The problem that 4d57b868 attempted to fix was that "unlabeled disk" format has no signature at all and is detected on any volume, including empty ones.
With this patch, DASD partition table formats other than "unlabeled disk" are detected on non-DASD devices again.
--- kpartx/dasd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kpartx/dasd.c +4 -3
@@ -133,9 +133,6 @@ read_dasd_pt(int fd, struct slice all, struct slice *sp, int ns)/* Couldn't open the device */ return -1 ; } - }else if ((unsigned int )major (sbuf.st_rdev) !=94 ) { -/* Not a DASD */ -return -1 ; }else { fd_dasd =dup (fd);if (fd_dasd <0 )
@@ -279,6 +276,10 @@ read_dasd_pt(int fd, struct slice all, struct slice *sp, int ns) size = disksize;if (fmt_size < size) size = fmt_size; + }else if ((unsigned int )major (sbuf.st_rdev) !=94 ) { +/* Not a DASD */ + retval =-1 ; + goto out; }else size = disksize;
Signature · 1 line
2.22.0
PATCH 3/4 multipath-tools (coverity): assert availability of CLOCK_MONOTONIC
In reply to Martin WilckFrom: Martin Wilck <[email protected]>
clock_gettime() fails only if either an invalid pointer is passed, or if the requested clock ID is not available. While availability of CLOCK_REALTIME is guaranteed, CLOCK_MONOTONIC is not, at least not by POSIX (Linux seems to have it, always). Provide a wrapper that can be called without error checking, and which aborts in the highly unlikely case that the monotonic clock can't be obtained. That saves us from checking the error code of clock_gettime() at every invocation (handling this sort of error "correctly" is almost impossible anyway), and should still satisfy coverity.
Not doing this for libdmmp here, as it has it's own error checking and doesn't use headers from libmultipath.
----
v2: Fix mistake that with -DNDEBUG, clock_gettime wouldn't be called at all (Bart van Assche).
--- libmultipath/checkers/tur.c | 6 +++--- libmultipath/time-util.c | 9 +++++++++ libmultipath/time-util.h | 1 + multipathd/main.c | 34 +++++++++++++--------------------- multipathd/uxlsnr.c | 8 +++----- 5 files changed, 29 insertions(+), 29 deletions(-)
libmultipath/checkers/tur.c +3 -3
@@ -290,7 +290,7 @@ static void *tur_thread(void *ctx)static void tur_timeout (struct timespec *tsp) { -clock_gettime (CLOCK_MONOTONIC , tsp); +get_monotonic_time (tsp); tsp->tv_nsec +=1000 *1000 ;/* 1 millisecond */ normalize_timespec (tsp); }
@@ -300,7 +300,7 @@ static void tur_set_async_timeout(struct checker *c)struct tur_checker_context *ct = c->context;struct timespec now; -clock_gettime (CLOCK_MONOTONIC , &now); +get_monotonic_time (&now); ct->time = now.tv_sec + c->timeout; }
@@ -309,7 +309,7 @@ static int tur_check_async_timeout(struct checker *c)struct tur_checker_context *ct = c->context;struct timespec now; -clock_gettime (CLOCK_MONOTONIC , &now); +get_monotonic_time (&now);return (now.tv_sec > ct->time); }
libmultipath/time-util.c +9 -0
@@ -3,6 +3,15 @@#include <time.h> #include "time-util.h" +void get_monotonic_time (struct timespec *res) +{ +struct timespec ts; +int rv =clock_gettime (CLOCK_MONOTONIC , &ts); + +assert (rv ==0 ); + *res = ts; +} +/* Initialize @cond as a condition variable that uses the monotonic clock */ void pthread_cond_init_mono (pthread_cond_t *cond) {
libmultipath/time-util.h +1 -0
@@ -5,6 +5,7 @@struct timespec ; +void get_monotonic_time (struct timespec *res);void pthread_cond_init_mono (pthread_cond_t *cond);void normalize_timespec (struct timespec *ts); void timespecsub(const struct timespec *a, const struct timespec *b,
multipathd/main.c +13 -21
@@ -283,11 +283,10 @@ int set_config_state(enum daemon_status state)else if (running_state !=DAEMON_IDLE ) {struct timespec ts; -if (clock_gettime (CLOCK_MONOTONIC , &ts) ==0 ) { - ts.tv_sec +=1 ; - rc =pthread_cond_timedwait (&config_cond, - &config_lock, &ts); - } +get_monotonic_time (&ts); + ts.tv_sec +=1 ; + rc =pthread_cond_timedwait (&config_cond, + &config_lock, &ts); }if (!rc && (running_state !=DAEMON_SHUTDOWN )) { running_state = state;
@@ -1888,15 +1887,12 @@ static int check_path_reinstate_state(struct path * pp) { }if (pp->disable_reinstate) { -/* If we don't know how much time has passed, automatically -* reinstate the path, just to be safe. Also, if there are -* no other usable paths, reinstate the path -*/ -if (clock_gettime (CLOCK_MONOTONIC , &curr_time) !=0 || - pp->mpp->nr_active ==0 ) { +/* If there are no other usable paths, reinstate the path */ +if (pp->mpp->nr_active ==0 ) {condlog (2 ,"%s : reinstating path early" , pp->dev); goto reinstate_path; } +get_monotonic_time (&curr_time);if ((curr_time.tv_sec - pp->dis_reinstate_time ) > pp->mpp->san_path_err_recovery_time) {condlog (2 ,"%s : reinstate the path after err recovery time" , pp->dev); goto reinstate_path;
@@ -1932,8 +1928,7 @@ static int check_path_reinstate_state(struct path * pp) {* delay the path, so there's no point in checking if we should */ -if (clock_gettime (CLOCK_MONOTONIC , &curr_time) !=0 ) -return 0 ; +get_monotonic_time (&curr_time);/* when path failures has exceeded the san_path_err_threshold * place the path in delayed state till san_path_err_recovery_time * so that the cutomer can rectify the issue within this time. After
@@ -2315,17 +2310,14 @@ checkerloop (void *ap)condlog (2 ,"path checkers start up" );/* Tweak start time for initial path check */ -if (clock_gettime (CLOCK_MONOTONIC , &last_time) !=0 ) - last_time.tv_sec =0 ; -else - last_time.tv_sec -=1 ; +get_monotonic_time (&last_time); + last_time.tv_sec -=1 ;while (1 ) {struct timespec diff_time, start_time, end_time;int num_paths =0 , ticks =0 , strict_timing, rc =0 ; -if (clock_gettime (CLOCK_MONOTONIC , &start_time) !=0 ) - start_time.tv_sec =0 ; +get_monotonic_time (&start_time);if (start_time.tv_sec && last_time.tv_sec) {timespecsub (&start_time, &last_time, &diff_time); condlog(4, "tick (%lu.%06lu secs)",
@@ -2384,8 +2376,8 @@ checkerloop (void *ap) } diff_time.tv_nsec =0 ; -if (start_time.tv_sec && -clock_gettime (CLOCK_MONOTONIC , &end_time) ==0 ) { +if (start_time.tv_sec) { +get_monotonic_time (&end_time);timespecsub (&end_time, &start_time, &diff_time);if (num_paths) {unsigned int max_checkint;
multipathd/uxlsnr.c +3 -5
@@ -130,10 +130,10 @@ void check_timeout(struct timespec start_time, char *inbuf, {struct timespec diff_time, end_time; -if (start_time.tv_sec && -clock_gettime (CLOCK_MONOTONIC , &end_time) ==0 ) { +if (start_time.tv_sec) {unsigned long msecs; +get_monotonic_time (&end_time);timespecsub (&end_time, &start_time, &diff_time); msecs = diff_time.tv_sec *1000 + diff_time.tv_nsec / (1000 *1000 );
@@ -280,9 +280,7 @@ void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, long ux_sock, i, polls[i].fd);continue ; } -if (clock_gettime (CLOCK_MONOTONIC , &start_time) - !=0 ) - start_time.tv_sec =0 ; +get_monotonic_time (&start_time);if (recv_packet_from_client (c->fd, &inbuf, uxsock_timeout) !=0 ) {
Signature · 1 line
2.22.0
PATCH 4/4 libmultipath: trigger uevents for partitions, too
In reply to Martin WilckFrom: Martin Wilck <[email protected]>
We have added code to re-trigger uevents in various cases where the status of a device changes from multipath to non-multipath, or vice-versa. When multipathd triggers uevents for paths of a map because the status of the map has changed, it needs to trigger events for the partitions of the path devices, too. The kernel doesn't do this automatically.
--- libmultipath/configure.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
libmultipath/configure.c +38 -0
@@ -519,6 +519,42 @@ trigger_udev_change(const struct multipath *mpp)udev_device_unref (udd); } +static void trigger_partitions_udev_change (struct udev_device *dev, +const char *action,int len) +{ +struct udev_enumerate *part_enum; +struct udev_list_entry *item; + + part_enum =udev_enumerate_new (udev); +if (!part_enum) +return ; + +if (udev_enumerate_add_match_parent (part_enum, dev) <0 || +udev_enumerate_add_match_subsystem (part_enum,"block" ) <0 || +udev_enumerate_scan_devices (part_enum) <0 ) + goto unref; + +udev_list_entry_foreach (item, + udev_enumerate_get_list_entry(part_enum)) { +const char *syspath; +struct udev_device *part; + + syspath =udev_list_entry_get_name (item); + part =udev_device_new_from_syspath (udev, syspath); +if (!part) +continue ; + +if (!strcmp ("partition" ,udev_device_get_devtype (part))) { +condlog (4 ,"%s: triggering %s event for %s" , __func__, + action, syspath); +sysfs_attr_set_value (part,"uevent" , action, len); + } +udev_device_unref (part); + } +unref: +udev_enumerate_unref (part_enum); +} +void trigger_paths_udev_change (struct multipath *mpp,bool is_mpath) {
@@ -569,6 +605,8 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath) action, pp->dev, is_mpath ? "" : "no ");sysfs_attr_set_value (pp->udev,"uevent" , action,strlen (action)); +trigger_partitions_udev_change (pp->udev, action, +strlen (action)); } }
Signature · 1 line
2.22.0
Re: [PATCH 4/4] libmultipath: trigger uevents for partitions, too
We have an observed behavior as follows:
When the host boots up, a uuid symbolic link is created pointing at /dev/sda1 (device for /boot)
Multipath starts up and creates an multipath device to manage /dev/sda and a udev rule deletes /dev/sda1 invalidating the symbolic link.
The symbolic link does not appear to get re-created to point to the new multipath device which would lead one to suspect that there was no event happening for when the multipath device is created.
When /boot attempts to mount via uuid it fails as the symbolic link is still pointing at /dev/sda1 that no longer exists in /dev.
Right now our solution is a manual solution of blacklisting the device with /boot on it.
Would this fix triggering an event on the multipath device partitions be expected to correct the above issue?
If so, I will submit a ticket to our OS vendor to have it backport it into the versions that are having the issue with.
Thanks.
Quoted 81 lines · Martin Wilck
From: Martin Wilck <[email protected]>
We have added code to re-trigger uevents in various cases where the status of a device changes from multipath to non-multipath, or vice-versa. When multipathd triggers uevents for paths of a map because the status of the map has changed, it needs to trigger events for the partitions of the path devices, too. The kernel doesn't do this automatically.
Fixes c5023200 libmultipath: indicate wwid failure in dm_addmap_create()Fixes e5d3c3a0 libmultipath: trigger change uevent on new device creationSigned-off-by Martin Wilck <[email protected]>--- libmultipath/configure.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)libmultipath/configure.c +38
-1@@ -519,6 +519,42 @@ trigger_udev_change(const struct multipath *mpp)udev_device_unref (udd); } +static void trigger_partitions_udev_change (struct udev_device *dev, +const char *action,int len) +{ +struct udev_enumerate *part_enum; +struct udev_list_entry *item; + + part_enum =udev_enumerate_new (udev); +if (!part_enum) +return ; + +if (udev_enumerate_add_match_parent (part_enum, dev) <0 || +udev_enumerate_add_match_subsystem (part_enum,"block" ) <0 || +udev_enumerate_scan_devices (part_enum) <0 ) + goto unref; + +udev_list_entry_foreach (item, + udev_enumerate_get_list_entry(part_enum)) { +const char *syspath; +struct udev_device *part; + + syspath =udev_list_entry_get_name (item); + part =udev_device_new_from_syspath (udev, syspath); +if (!part) +continue ; + +if (!strcmp ("partition" ,udev_device_get_devtype (part))) { +condlog (4 ,"%s: triggering %s event for %s" , __func__, + action, syspath); +sysfs_attr_set_value (part,"uevent" , action, len); + } +udev_device_unref (part); + } +unref: +udev_enumerate_unref (part_enum); +} +void trigger_paths_udev_change (struct multipath *mpp,bool is_mpath) {@@ -569,6 +605,8 @@ trigger_paths_udev_change(struct multipath *mpp, bool is_mpath) action, pp->dev, is_mpath ? "" : "no ");sysfs_attr_set_value (pp->udev,"uevent" , action,strlen (action)); +trigger_partitions_udev_change (pp->udev, action, +strlen (action)); } } --2.22.0
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
Re: [PATCH 4/4] libmultipath: trigger uevents for partitions, too
Quoted 8 lines · Roger Heflin
We have an observed behavior as follows:
When the host boots up, a uuid symbolic link is created pointing at
/dev/sda1(device for /boot)Multipath starts up and creates an multipath device to manage
/dev/sda
and a udev rule deletes/dev/sda1invalidating the symbolic link.
I suppose you are talking about 68-del-part-nodes.rules. Note that the rules in this file can be deactivated by setting ENV{DONT_DEL_PART_NODES}="1" in an early udev rule.
Also, the rule only removes partitions for devices that have been detected as being eligible for multipathing.
Quoted 4 lines
The symbolic link does not appear to get re-created to point to the new multipath device which would lead one to suspect that there was no
event happening for when the multipath device is created.
That's very unlikely. You should verify that the multipath device (for sda) is created. My patch here relates only to the case where creating the multipath device *fails*.
If the creation of the multipath device succeeded, my patch would have no effect on your system. In that case you should also verify that the kpartx devices on top of it were created. I advise to boot with "udev.log-priority=debug" and check what udev is actually doing.
Quoted 6 lines
Right now our solution is a manual solution of blacklisting the device
with /boot on it.Would this fix triggering an event on the multipath device partitions be expected to correct the above issue?
Maybe. I don't know enough details about your configuration to tell. But if this is a device that should not be multipathed, from my point of view, proper blacklisting via multipath.conf is the recommended way to handle this problem.
You can also use "find_multipaths"; please check the documentation. Note also that since 0.7.8, blacklisting "by protocol" is possible, which makes it possible e.g. to blacklist local SATA disks with a simple statement.
Regards,
Martin
Re: [PATCH 4/4] libmultipath: trigger uevents for partitions, too
Quoted 7 lines · Martin Wilck
Quoted 5 lines · Roger Heflin
We have an observed behavior as follows:
When the host boots up, a uuid symbolic link is created pointing at
/dev/sda1(device for /boot)
Quoted 7 lines
Quoted 3 lines
Multipath starts up and creates an multipath device to manage
/dev/sda
and a udev rule deletes/dev/sda1invalidating the symbolic link.I suppose you are talking about 68-del-part-nodes.rules. Note that the rules in this file can be deactivated by setting ENV{DONT_DEL_PART_NODES}="1" in an early udev rule.
The OS we have uses 62-multipath and does not have a global override like that.
I am looking at my notes on the issue and it was this:
rootvg gets started directly on /dev/sda2 and then multipath starts up and attempts to mange it and deletes the partition on /dev/sda1 causing the by-uuid link to be invalid but multipath fails to create the device with "map in use" because the lv's for rootvg are live on/dev/sda2 directly. So it does sound like your fix would would
correct this issue since on the multipath failure to manage it would recreate the /dev/sda1 device. There appears to be some race condition in the initramfs/systemd where sometimes rootvg gets started before multipath has managed the device causing the partition to be deleted (we have multipath is the initramfs, and that was confirmed). All of our other vg's dont have this issue as we are using the rd.lvm.vg= such that only the rootvg gets turned on early.
Quoted 4 lines
Also, the rule only removes partitions for devices that have been detected as being eligible for multipathing.
Quoted 9 lines
Quoted 4 lines
The symbolic link does not appear to get re-created to point to the new multipath device which would lead one to suspect that there was no
event happening for when the multipath device is created.That's very unlikely. You should verify that the multipath device (for sda) is created. My patch here relates only to the case where creating the multipath device *fails*.
?
Quoted 11 lines
Maybe. I don't know enough details about your configuration to tell. But if this is a device that should not be multipathed, from my point of view, proper blacklisting via multipath.conf is the recommended way to handle this problem.
You can also use "
find_multipaths"; please check the documentation. Note also that since 0.7.8, blacklisting "by protocol" is possible, which makes it possible e.g. to blacklist local SATA disks with a simple statement.
We intentionally have find_multipaths set to allow a single path. The issue is on a number of VM and using multipath for everything allows us to not have separate work instructions/scripts for VM's vs physical, and also allows using multipath to use io retries to work around short-term external vmhost and storage issues without having to identify what nodes were affected and reboot them all (they just pause and continue once the issue is fixed). It is a very large environment and things happen in the different sections of the environment and we have been tweaking various configuration settings to result in less
trouble/more stability when things happen. The environment has >5000
linux VM's and > 5000 physical linux hosts.
Quoted 2 lines
Martin
Re: [PATCH 4/4] libmultipath: trigger uevents for partitions, too
Quoted 4 lines · Roger Heflin
The OS we have uses 62-multipath and does not have a global override like that.
Quoted 9 lines
I am looking at my notes on the issue and it was this:
rootvg gets started directly on/dev/sda2and then multipath starts up
and attempts to mange it and deletes the partition on/dev/sda1causing the by-uuid link to be invalid but multipath fails to create the device with "map in use" because the lv's for rootvg are live on/dev/sda2directly. So it does sound like your fix would would
correct this issue since on the multipath failure to manage it would recreate the/dev/sda1device.
Yes, it's certainly worth a try. This is the case the patch was made for. You must make sure that your distro contains the commits it builds upon (c5023200, e5d3c3a0). All this is fairly recent stuff.
Quoted 5 lines
There appears to be some race
condition in the initramfs/systemd where sometimes rootvg gets started
before multipath has managed the device causing the partition to be deleted (we have multipath is the initramfs, and that was confirmed).
That should never happen. The multipath udev rules set SYSTEMD_READY=0 on the devices, thus lvm must refrain from grabbing them. Maybe multipath_component_detection is off in your LVM2 setup?
Quoted 28 lines
All of our other vg's dont have this issue as we are using the rd.lvm.vg= such that only the rootvg gets turned on early.
Quoted 10 lines
Also, the rule only removes partitions for devices that have been detected as being eligible for multipathing.
Quoted 6 lines
The symbolic link does not appear to get re-created to point to the
new multipath device which would lead one to suspect that there was
no
event happening for when the multipath device is created.Quoted 6 lines
That's very unlikely. You should verify that the multipath device (for
sda) is created. My patch here relates only to the case where creating
the multipath device *fails*.?
Quoted 8 lines
Maybe. I don't know enough details about your configuration to tell.
But if this is a device that should not be multipathed, from my point
of view, proper blacklisting via multipath.conf is the recommended way
to handle this problem.
Quoted 6 lines
Quoted 5 lines
You can also use "
find_multipaths"; please check the documentation. Note also that since 0.7.8, blacklisting "by protocol" is possible, which makes it possible e.g. to blacklist local SATA disks with a simple statement.We intentionally have
find_multipathsset to allow a single path.
But the map which is causing the problem does have multiple paths, if I understand correctly? Not all past versions of multipath-tools behaved consistently with "find_multipaths yes"; if you have such a version, that might even explain the race you were talking about. But this is speculation. The behavior depends on which commits exactly are in your code base.
Anyway, I can't say much about it without knowing all the details. It seems that you should contact your distro vendor.
Martin