Re: [dm-devel] [PATCH 00/10] fixes for kpartx -d

2017-05-05 Thread Martin Wilck
On Sat, 2017-05-06 at 00:30 +0200, Martin Wilck wrote: > On Fri, 2017-05-05 at 23:18 +0100, Alasdair G Kergon wrote: > > On Sat, May 06, 2017 at 12:05:49AM +0200, Martin Wilck wrote: > > >   3) kpartx should only delete "partitions", which are single- > > > target > > >  linear mappings into a

Re: [dm-devel] [PATCH 00/10] fixes for kpartx -d

2017-05-05 Thread Martin Wilck
On Fri, 2017-05-05 at 23:18 +0100, Alasdair G Kergon wrote: > On Sat, May 06, 2017 at 12:05:49AM +0200, Martin Wilck wrote: > >   3) kpartx should only delete "partitions", which are single- > > target > >  linear mappings into a block device. Other maps should not be > > touched. > > The pref

Re: [dm-devel] [PATCH 08/10] kpartx: use partition UUID for non-DM devices

2017-05-05 Thread Alasdair G Kergon
On Sat, May 06, 2017 at 12:05:57AM +0200, Martin Wilck wrote: > Introduce a "fake" UUID for these devices to make sure kpartx > deletes only devices it had created previously. Otherwise kpartx > might e.g. delete LVM LVs that are inside a device it is trying > to delete partitions for. It seems to

Re: [dm-devel] [PATCH 00/10] fixes for kpartx -d

2017-05-05 Thread Alasdair G Kergon
On Sat, May 06, 2017 at 12:05:49AM +0200, Martin Wilck wrote: > 3) kpartx should only delete "partitions", which are single-target > linear mappings into a block device. Other maps should not be touched. The prefix on the dm device's uuid should guarantee this: all devices kpartx creates sh

[dm-devel] [PATCH 03/10] kpartx: remove is_loop_device

2017-05-05 Thread Martin Wilck
This function is not used any more. Signed-off-by: Martin Wilck --- kpartx/lopart.c | 31 --- kpartx/lopart.h | 1 - 2 files changed, 32 deletions(-) diff --git a/kpartx/lopart.c b/kpartx/lopart.c index 2eb3f631..44f0c277 100644 --- a/kpartx/lopart.c +++ b/kpartx/lo

[dm-devel] [PATCH 08/10] kpartx: use partition UUID for non-DM devices

2017-05-05 Thread Martin Wilck
For dm devices, kpartx uses an UUID check at partition removal to make sure it only deletes partitions it previously created. Non-DM parent devices such as loop devices don't generally have a UUID. Introduce a "fake" UUID for these devices to make sure kpartx deletes only devices it had created pr

[dm-devel] [PATCH 02/10] kpartx: avoid ioctl error for loop devices

2017-05-05 Thread Martin Wilck
Commit 3d709241 causes kpartx to attempt a dm ioctl on a loop device. This causes an error message "device-mapper: table ioctl on loop4 failed: No such device or address". Fixes: 3d709241 "kpartx: sanitize delete partitions" Signed-off-by: Martin Wilck --- kpartx/kpartx.c | 2 +- 1 file changed,

[dm-devel] [PATCH 01/10] kpartx: test-kpartx: new unit test program

2017-05-05 Thread Martin Wilck
This is a unit test program for kpartx, in particular for deleting partitions. NOTE: This test program fails with current kpartx; full patch series needed to make it work. Signed-off-by: Martin Wilck --- kpartx/test-kpartx | 253 + 1 file chan

[dm-devel] [PATCH 06/10] kpartx: don't treat multi-linear mappings as partitions

2017-05-05 Thread Martin Wilck
kpartx -d treats any map that has a "linear" mapping into a device as first target as a partition of this device. This is wrong, because linear mappings may consist of several pieces, combining multiple devices into one (LVM logical volumes are an example of such a mapping). Partitions have to be s

[dm-devel] [PATCH 09/10] kpartx: use absolute path for regular files

2017-05-05 Thread Martin Wilck
kpartx supports being called for a regular file, in which case it assumes that it should set up a loop device or use an existing one. Because the loopinfo.lo_name field contains an absolute path, matching with existing loop devices fails for relative paths. Matching by basename only would be unreli

[dm-devel] [PATCH 10/10] kpartx: find_loop_by_file: use sysfs

2017-05-05 Thread Martin Wilck
Rather then searching through all of /dev, look up loop devices in /sys/devices/virtual/block. This is cleaner and more robust (/dev/loop$Xp$Y symlinks may confuse kpartx). Signed-off-by: Martin Wilck --- kpartx/lopart.c | 42 +++--- 1 file changed, 31 inserti

[dm-devel] [PATCH 07/10] libmultipath: don't treat multi-linear mappings as partitions

2017-05-05 Thread Martin Wilck
dm_type is used in libmultipath only to check whether a mapping is "linear", with the intention to test if it represents a "partition". This test returns TRUE also for mappings with multiple targets, the first of which happens to be a linear mapping into the target device. This is questionable, it'

[dm-devel] [PATCH 05/10] kpartx: dm_devn: return error for non-existent device

2017-05-05 Thread Martin Wilck
For non-existent maps (ENXIO from ioctl()), dm_task_run and dm_task_get_info return success. We need to check info.exists. Signed-off-by: Martin Wilck --- kpartx/devmapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c index 8f48a705

[dm-devel] [PATCH 04/10] kpartx: dm_remove_partmaps: support non-dm devices

2017-05-05 Thread Martin Wilck
Commit 3d709241 improved partition removal, but broke support for handling partitions of non-dm devices such as loop devices or RAM disks. This requires passing the dev_t of the device down to do_foreach_partmap(). Doing so, there's little use in trying to derive major/minor numbers from the "map

[dm-devel] [PATCH 00/10] fixes for kpartx -d

2017-05-05 Thread Martin Wilck
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 clea

[dm-devel] [git pull] device mapper fixes for 4.12-rc1

2017-05-05 Thread Mike Snitzer
Hi Linus, The following changes since commit 7b66f13207e60e7c550af730986e77e38a0c69a3: Merge tag 'for-4.12/dm-post-merge-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm (2017-05-03 10:34:03 -0700) are available in the git repository at: git://git.kernel.or

Re: [dm-devel] remove REQ_OP_WRITE_SAME

2017-05-05 Thread Christoph Hellwig
On Thu, Apr 13, 2017 at 10:23:10PM -0400, Martin K. Petersen wrote: > The other thing that keeps me a bit on the fence is that a bunch of the > plumbing to handle a bio with a payload different from bi_size is needed > for the copy offload token. I'm hoping to have those patches ready for > 4.13. R

Re: [dm-devel] [PATCH 25/27] block: remove the discard_zeroes_data flag

2017-05-05 Thread Nicholas A. Bellinger
On Wed, 2017-05-03 at 10:33 -0400, Mike Snitzer wrote: > On Tue, May 02 2017 at 11:33pm -0400, > Nicholas A. Bellinger wrote: > > > On Tue, 2017-05-02 at 09:23 +0200, h...@lst.de wrote: > > > On Tue, May 02, 2017 at 12:16:13AM -0700, Nicholas A. Bellinger wrote: > > > > Or, another options is use