DM-Devel Archive mirror
 help / color / mirror / Atom feed
From: Glenn Washburn <development@efficientek.com>
To: Jens Axboe <axboe@kernel.dk>, Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>
Cc: dm-devel@lists.linux.dev, linux-block@vger.kernel.org,
	linux-kernel@vger.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
Date: Wed, 20 Mar 2024 16:56:09 -0500	[thread overview]
Message-ID: <20240320165339.1c6b4d39@crass-HP-ZBook-15-G2> (raw)

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

                 reply	other threads:[~2024-03-20 21:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240320165339.1c6b4d39@crass-HP-ZBook-15-G2 \
    --to=development@efficientek.com \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).