[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240320165339.1c6b4d39@crass-HP-ZBook-15-G2>
Date: Wed, 20 Mar 2024 16:56:09 -0500
From: Glenn Washburn <development@...icientek.com>
To: Jens Axboe <axboe@...nel.dk>, Alasdair Kergon <agk@...hat.com>, Mike
Snitzer <snitzer@...nel.org>, Mikulas Patocka <mpatocka@...hat.com>
Cc: dm-devel@...ts.linux.dev, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Cannot create dm-linear or dm-crypt mapping on scsi or mmc block
device if mapping already exists on partition of device
Saludos,
I've hit some unexpected behavior that is not intuitive and might be
considered a bug. A dm-linear or dm-crypt (possibly others) mapping is
attempted to be created on a scsi or mmc block device (again, possibly
others) when there already exists a mapping on a sub block device, the
mapping creation will fail with EBUSY. Here's a concrete example:
# dmsetup create --concise "dm-test,,,ro,0 8 linear /dev/sda1 0"
# dmsetup create --concise "dm-test2,,,ro,0 4 linear /dev/sda1 2"
# dmsetup create --concise "dm-test3,,,ro,0 4 linear /dev/sda 2"
[ 968.046906] device-mapper: table: 252:2: linear: Device lookup failed (-EBUSY)
[ 968.047305] device-mapper: ioctl: error adding target to table
device-mapper: reload ioctl on dm-test3 (252:2) failed: Device or resource busy
Command failed.
# dmsetup create --concise "dm-test4,,,ro,0 4 linear ${DEV}2 8"
# dmsetup table --show
dm-test: 0 8 linear 8:1 0
dm-test2: 0 4 linear 8:1 2
dm-test4: 0 4 linear 8:2 8
The second command shows that dm-linear has no issues with creating an
overlapping mapping on the same device. It makes little sense that the
third command fails where the second and fourth succeed. Further testing
shows that if there is an existing linear mapping on the full block device,
then mappings fail to be created on any partition block devices. This has
been tested on scsi and mmc devices. It is also true for the dm-crypt
target and mixing dm-linear and dm-crypt mappings. I've tested on Ubuntu's
6.8.1 test kernel. I doubt this is affected by any Ubuntu patching, but
perhaps someone could confirm this on a vanilla kernel.
I noticed this because I tried to create a dm-linear mapping of a scsi
device to capture sectors not contained in a partition, but it failed
because I already had a dm-crypt mapping on a partition of the device.
Any ideas what's going on? Are there good reasons for this behavior that
I'm unaware of? I've done some searching but haven't found it having been
reported anywhere. If this has been discussed, please point me in that
direction.
Glenn
Powered by blists - more mailing lists