Skip to content

multipath/kpartx udev rules cleanup, and fixes

Martin Wilck dm-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest31 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/31libmultipath: fix partition_delimiter config optionlibmultipath/devmapper.c+6 -40 replies
2/31kpartx: helper functions for name and uuid generationkpartx/devmapper.c+38 -60 replies
3/31kpartx: search partitions by UUID, and renamekpartx/devmapper.c kpartx/devmapper.h kpartx/kpartx.c+120 -420 replies
4/31test-kpartx: add tests for renaming functionalitykpartx/test-kpartx+36 -00 replies
5/31kpartx: fix a corner case when renaming partitionskpartx/devmapper.c kpartx/devmapper.h kpartx/kpartx.c+56 -260 replies
6/31kpartx: fix part deletion without partition tablekpartx/kpartx.c+17 -140 replies
7/31test-kpartx: test deletion with empty part tablekpartx/test-kpartx+14 -00 replies
8/31kpartx: only recognize dasd part table on DASDkpartx/dasd.c+3 -00 replies
9/31libmultipath: support MPATH_UDEV_NO_PATHS_FLAG on map creationlibmultipath/devmapper.c+20 -102 replies
10/31libmultipath: add get_udev_devicelibmultipath/configure.c libmultipath/configure.h+36 -00 replies
11/31libmultipath: get_refwwid: use get_udev_devicelibmultipath/configure.c+11 -120 replies
12/31libmultipath: use const char* in some dm helperslibmultipath/devmapper.c libmultipath/devmapper.h+4 -40 replies
13/31libmultipath: add DI_NOIO flag for pathinfolibmultipath/discovery.c libmultipath/discovery.h+10 -00 replies
14/31libmultipath: add dm_get_multipathlibmultipath/devmapper.c libmultipath/devmapper.h+28 -160 replies
15/31multipath: implement "check usable paths" (-C/-U)libmultipath/config.h multipath/main.c multipath/multipath.8+101 -33 replies
16/3111-dm-mpath.rules: multipath -U for READY checkmultipath/11-dm-mpath.rules+13 -20 replies
17/3111-dm-mpath.rules: import more ID_FS_xxx vars from dbmultipath/11-dm-mpath.rules+3 -10 replies
18/3111-dm-mpath.rules: no need to test before IMPORTmultipath/11-dm-mpath.rules+7 -70 replies
19/3111-dm-mpath.rules: handle new maps with READY==0multipath/11-dm-mpath.rules+4 -40 replies
20/3111-dm-mpath.rules: don't set READY->ACTIVATIONmultipath/11-dm-mpath.rules+1 -24 replies
21/3111-dm-mpath.rules: Remember DM_ACTIVATIONmultipath/11-dm-mpath.rules+8 -04 replies
22/31multipath.rules: set ID_FS_TYPE to "mpath_member"multipath/multipath.rules+1 -10 replies
23/31kpartx.rules: don't rely on DM_DEPS and DM_TABLE_STATEkpartx/kpartx.rules+5 -50 replies
24/31kpartx.rules: respect DM_UDEV_LOW_PRIORITY_FLAGkpartx/kpartx.rules+1 -10 replies
25/31kpartx.rules: improved logic for by-uuid and by-label linkskpartx/kpartx.rules+18 -60 replies
26/31kpartx.rules: create by-partuuid and by-partlabel symlinkskpartx/kpartx.rules+6 -00 replies
27/31kpartx.rules: generate type-name links only for multipath deviceskpartx/kpartx.rules+1 -10 replies
28/31kpartx.rules: fix logic for adding partitionskpartx/kpartx.rules+21 -60 replies
29/31multipath/kpartx rules: avoid superfluous scanningkpartx/kpartx.rules multipath/11-dm-mpath.rules+10 -10 replies
30/31kpartx/del-part-nodes.rules: new udev filekpartx/Makefile kpartx/del-part-nodes.rules+33 -01 reply
31/31kpartx.rules: move symlink code to other fileskpartx/Makefile kpartx/dm-parts.rules kpartx/kpartx.rules +1 more+61 -451 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/31] multipath/kpartx udev rules cleanup, and fixes

The main part of this series is a cleanup of the udev rules for multipath and kpartx. More about that further down.

- patch 01 is an obvious bug fix
- patch 02-08 are fixes for kpartx problems that I encountered during testing, with related tests. The interesting one here is 04, which adds the ability to rename partition mappings if the current name doesn't match the specified scheme. The purpose is to provide consistent naming of partition mappings across the OS, even in the presence of other tools such as parted that may follow different conventions.
- 09-15 are changes to the core code I found necessary for the udev rules cleanup, most importantly a helper to figure out quickly whether a given multipath has usable paths (multipath -U). This replaces the former SUSE-specific tests for DM_DEPS and DM_TABLE_STATE.
- 16ff are the actual changes to the udev rules. This was motivated by Ben Marzinski who asked Hannes and me a while ago to remove the SUSE-isms in the rules files (patch 23), and cleanup mainly kpartx.rules.

More about the udev rules changes:

Multipath maps are special because they can exist without any usable members/paths, and users expect them to be at least partly functional in such situations. Care has to be taken to avoid I/O on maps that may not be able to process it, and not to loose any symlinks that might be used by systemd to access the partition. Partitions on multipath maps have similar semantics, with the added difficulty that no first-hand information about the parent device is available. A lot of the existing code was trying to fix these corner case situations, but sometimes incorrectly or not cleanly. I have pointed out the issues in the individual commit messages. One important point is that checking DM_NR_VALID_PATHS>0 is not in sufficient to affirm that I/O will succeed. That was the reason for writing the "multipath -U" helper.

Also, multipath maps receive frequent udev events that don't matter to upper layers at all. In such cases, further scanning should be avoided. This is implemented much more cleanly now, I hope.

Following the example of the dm core, I split the kpartx rules up in "early" rules for setting properties and symlinks, and "late" rules for taking actions such as running kpartx. I believe that this makes the code better readable.
CAUTION: The new rules files matter for other packages such as dracut. Distribution package builders have to be careful here. If this patch set is accepted, respective patches will be send to the dracut maintainers.

Following Ben's suggestions, a new rules file is added that is responsible for deleting partition device nodes for multipath member devices.

I didn't expect this series to grow so large, but after having worked and tested for considerable time, this is the first version that I find ready for serious review. I smoke-tested the interaction of rules files, multipathd, udev, systemd, and kpartx quite a bit with failover and 0-paths scenarios, successfully.

The changes are less drastic than the stats below suggest. A considerable part just moves functionality out of existing code into separate functions in order to use it elsewhere.

Regards,
Martin

Martin Wilck (31):
libmultipath: fix partition_delimiter config option
kpartx: helper functions for name and uuid generation
kpartx: search partitions by UUID, and rename
test-kpartx: add tests for renaming functionality
kpartx: fix a corner case when renaming partitions
kpartx: fix part deletion without partition table
test-kpartx: test deletion with empty part table
kpartx: only recognize dasd part table on DASD
libmultipath: support MPATH_UDEV_NO_PATHS_FLAG on map creation
libmultipath: add get_udev_device
libmultipath: get_refwwid: use get_udev_device
libmultipath: use const char* in some dm helpers
libmultipath: add DI_NOIO flag for pathinfo
libmultipath: add dm_get_multipath
multipath: implement "check usable paths" (-C/-U) 11-dm-mpath.rules: multipath -U for READY check 11-dm-mpath.rules: import more ID_FS_xxx vars from db 11-dm-mpath.rules: no need to test before IMPORT 11-dm-mpath.rules: handle new maps with READY==0 11-dm-mpath.rules: don't set READY->ACTIVATION 11-dm-mpath.rules: Remember DM_ACTIVATION multipath.rules: set ID_FS_TYPE to "mpath_member" kpartx.rules: don't rely on DM_DEPS and DM_TABLE_STATE kpartx.rules: respect DM_UDEV_LOW_PRIORITY_FLAG kpartx.rules: improved logic for by-uuid and by-label links kpartx.rules: create by-partuuid and by-partlabel symlinks kpartx.rules: generate type-name links only for multipath devices kpartx.rules: fix logic for adding partitions multipath/kpartx rules: avoid superfluous scanning kpartx/del-part-nodes.rules: new udev file kpartx.rules: move symlink code to other files

 kpartx/Makefile             |   2 +
 kpartx/dasd.c               |   3 +
 kpartx/del-part-nodes.rules |  32 ++++++++
 kpartx/devmapper.c          | 194 ++++++++++++++++++++++++++++++++++++++++++--
 kpartx/devmapper.h          |  18 +++-
 kpartx/dm-parts.rules       |  39 +++++++++
 kpartx/kpartx.c             | 105 +++++++-----------------
 kpartx/kpartx.rules         |  58 ++++++-------
 kpartx/test-kpartx          |  50 ++++++++++++
 libmultipath/config.h       |   1 +
 libmultipath/configure.c    |  58 ++++++++++---
 libmultipath/configure.h    |   1 +
 libmultipath/devmapper.c    |  87 ++++++++++++--------
 libmultipath/devmapper.h    |   5 +-
 libmultipath/discovery.c    |   8 ++
 libmultipath/discovery.h    |   2 +
 multipath/11-dm-mpath.rules |  76 +++++++++++++----
 multipath/main.c            |  90 +++++++++++++++++++-
 multipath/multipath.8       |  13 ++-
 multipath/multipath.rules   |   2 +-
 20 files changed, 659 insertions(+), 185 deletions(-)
 create mode 100644 kpartx/del-part-nodes.rules
 create mode 100644 kpartx/dm-parts.rules
Signature · 1 line
2.14.0