All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/12] fixes for kpartx -d
@ 2017-05-15 15:37 Martin Wilck
  2017-05-15 15:37 ` [PATCH v2 01/12] kpartx: test-kpartx: new unit test program Martin Wilck
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: Martin Wilck @ 2017-05-15 15:37 UTC (permalink / raw)
  To: Christophe Varoqui, Hannes Reinecke, Benjamin Marzinski; +Cc: dm-devel

Working on a bug report about kpartx not properly removing
partitions for loop devices, I realized a number of glitches
and improperly handled corner cases in the kpartx code for
deleting partitions. Some mappings are not deleted although
they should be, and others are deleted although that is clearly
wrong.

This patch series fixes the issues I found. The series starts
with a test program demonstrating the problems. The program
succeeds only after all patches of this series are applied.

Here is my summary of what I think how kpartx should behave:

  1) kpartx should delete all mappings it created beforehand.
  2) kpartx should handle partitions on dm devices and other devices
     (e.g. loop devices) equally well.
  3) kpartx should only delete "partitions", which are single-target
     linear mappings into a block device. Other maps should not be touched.
  4) kpartx should only delete mappings it created itself beforehand.
     In particular, it shouldn't delete LVM LVs, even if they are fully
     contained in the block device at hand and thus look like partitions
     in the first place. (For historical compatibility reasons, allow
     such mappings to be deleted with the -f/--force flag).
  5) DM map names may be changed, thus kpartx shouldn't rely on them to
     check whether a mapping is a partition of a particular device. It is
     legal for a partition of /dev/loop0 to be named "loop0".

One patch has an obvious libdevmapper equivalent and is therefore
included (08/12) although this series is otherwise focused only on kpartx.
Patch 04/12 would also have a libdevmapper equivalent, but I haven't
included it because it would conflict with Ben's previously posted
patch "libmultipath: fix partition detection".

The patches are based on Christophe's tree; Christophe, if you prefer,
I can rebase them on top of Ben's late submissions.

Feedback is welcome.

Changes wrt v1:
- Test program (01/12): improved cleanup, and used "kpartx -s" rather than waiting.
- At Ben's suggestion, removed "no_partitions" support rather than fixing it.
- Previous 04/12 split into two patches (04+05/12), improving and separating
  out the part that would similarly apply to libmultipath (see above).
- New UUID format in patch 09/12 since the previous one wasn't well-received;
  the "-kpartx-" part was superfluous, as partition UUIDs start with "part%s-" anyway.
- Added the trivial fix 12/12.

Martin Wilck (12):
  kpartx: test-kpartx: new unit test program
  kpartx: remove "no_partitions" support
  kpartx: remove is_loop_device
  kpartx: relax and improve UUID check in dm_compare_uuid
  kpartx: dm_remove_partmaps: support non-dm devices
  kpartx: dm_devn: return error for non-existent device
  kpartx: don't treat multi-linear mappings as partitions
  libmultipath: don't treat multi-linear mappings as partitions
  kpartx: use partition UUID for non-DM devices
  kpartx: use absolute path for regular files
  kpartx: find_loop_by_file: use sysfs
  kpartx: include sys/sysmacros.h

 kpartx/devmapper.c       |  80 ++++++---------
 kpartx/devmapper.h       |   2 +-
 kpartx/kpartx.c          |  50 ++++++++--
 kpartx/lopart.c          |  75 ++++++--------
 kpartx/lopart.h          |   1 -
 kpartx/sysmacros.h       |   9 --
 kpartx/test-kpartx       | 254 +++++++++++++++++++++++++++++++++++++++++++++++
 libmultipath/devmapper.c |  15 +--
 8 files changed, 371 insertions(+), 115 deletions(-)
 delete mode 100644 kpartx/sysmacros.h
 create mode 100755 kpartx/test-kpartx

-- 
2.12.2

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-05-17 22:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 15:37 [PATCH v2 00/12] fixes for kpartx -d Martin Wilck
2017-05-15 15:37 ` [PATCH v2 01/12] kpartx: test-kpartx: new unit test program Martin Wilck
2017-05-15 15:37 ` [PATCH v2 02/12] kpartx: remove "no_partitions" support Martin Wilck
2017-05-15 15:37 ` [PATCH v2 03/12] kpartx: remove is_loop_device Martin Wilck
2017-05-15 15:37 ` [PATCH v2 04/12] kpartx: relax and improve UUID check in dm_compare_uuid Martin Wilck
2017-05-15 15:37 ` [PATCH v2 05/12] kpartx: dm_remove_partmaps: support non-dm devices Martin Wilck
2017-05-15 15:37 ` [PATCH v2 06/12] kpartx: dm_devn: return error for non-existent device Martin Wilck
2017-05-15 15:37 ` [PATCH v2 07/12] kpartx: don't treat multi-linear mappings as partitions Martin Wilck
2017-05-15 15:37 ` [PATCH v2 08/12] libmultipath: " Martin Wilck
2017-05-15 15:37 ` [PATCH v2 09/12] kpartx: use partition UUID for non-DM devices Martin Wilck
2017-05-15 15:37 ` [PATCH v2 10/12] kpartx: use absolute path for regular files Martin Wilck
2017-05-15 15:37 ` [PATCH v2 11/12] kpartx: find_loop_by_file: use sysfs Martin Wilck
2017-05-15 15:37 ` [PATCH v2 12/12] kpartx: include sys/sysmacros.h Martin Wilck
2017-05-17 17:06 ` [PATCH v2 00/12] fixes for kpartx -d Benjamin Marzinski
2017-05-17 22:25   ` Christophe Varoqui

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.