multipath -f/-F exit status
Quoted 11 lines
Hi Folks,
Older versions of multipath-tools would always exit with status 0 (success) when flushing multipath device maps (-f/-F). This was never guaranteed but happened because the "r" local in
multipath/main.cwas used uninitialised in these code paths (by chance, it always lands on a freshly zeroed stack page, so although undefined the behaviour was pretty reliable).This was changed by commit
8497928514aa3df6d46f24d8d9b70b086e9fcfbd:
Then by a9a6c71592d4e2271a38c3d334bee7cbce963cff.
Does the upstream version works as you expect in this regard ?
Quoted 5 lines
multipath -F
-------------F flush all unused multipath device maps
Quoted 9 lines
Exit status
0 At least one unused multipath device map was flushed 1 No unused maps were found or no maps could be flushedThe alternative for -F seems to be to return 0 if all unused maps were flushed and 1 if there were unused maps that could not be flushed. This doesn't seem like a very likely occurrence, but maybe it should be handled separately?
I guess the current implementation return r as the number failures.
Regards,
cvaroqui
Quoted 9 lines · Christophe Varoqui
Quoted 9 lines
Hi Folks,
Older versions of multipath-tools would always exit with status 0 (success) when flushing multipath device maps (-f/-F). This was never guaranteed but happened because the "r" local in
multipath/main.cwas used uninitialised in these code paths (by chance, it always lands on a freshly zeroed stack page, so although undefined the behaviour was pretty reliable).
Quoted 5 lines
Quoted 2 lines
This was changed by commit
8497928514aa3df6d46f24d8d9b70b086e9fcfbd:Then by
a9a6c71592d4e2271a38c3d334bee7cbce963cff.Does the upstream version works as you expect in this regard ?
Sorry - not sure how I missed that last week.
Quoted 6 lines
Quoted 5 lines
The alternative for -F seems to be to return 0 if all unused maps were flushed and 1 if there were unused maps that could not be flushed. This doesn't seem like a very likely occurrence, but maybe it should be handled separately?
I guess the current implementation return r as the number failures.
It does, which seems a slightly strange thing to return - I don't see how it's useful as it's actually the number of device-mapper maps that we couldn't flush (sum of returns from dm_flush_map), i.e. the total number of maps that either weren't multipath, weren't unused etc :)
This will cause problems on systems that have 256 such maps since the exit status is truncated to 8-bits and we would falsely reported the status as zero.
It seems more useful to return an overall success/failure indication for these commands and would be more in-keeping with other similar tools and POSIX.
Regards,
Bryn.
The following patch will appear soon at k.org
It should do what you expect.
Thanks for the comment,
cvaroqui
libmultipath/devmapper.c +1 -1
@@ -568,7 +568,7 @@ dm_flush_maps (void) goto out;do { - r +=dm_flush_map (names->name); + r |=dm_flush_map (names->name); next = names->next; names = (void *) names + next; }while (next);
Quoted 2 lines · Christophe Varoqui
The following patch will appear soon at k.org
It should do what you expect.
Great - thanks! I've had the user who reported this test with an identical change and they are happy with this behaviour.
Cheers,
Bryn.