DM-Devel Archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Mateusz Kusiak <mateusz.kusiak@linux.intel.com>,
	DM-devel-linux <dm-devel@lists.linux.dev>
Cc: linux-raid@vger.kernel.org, "yukuai (C)" <yukuai3@huawei.com>
Subject: Re: regression: mdadm detects dm-device as partition
Date: Mon, 25 Mar 2024 10:41:47 +0800	[thread overview]
Message-ID: <c7db2443-06d4-a199-02ac-f58204118cb6@huaweicloud.com> (raw)
In-Reply-To: <35e0eae0-7fb0-4029-8445-997e22c21482@linux.intel.com>

Hi,

在 2024/03/21 17:17, Mateusz Kusiak 写道:
> Hello,
> We discovered an issue when trying to create imsm container with mdadm 
> on dm-device.
> 
> The scenario is as follows:
> 
> 1. Create dm device
> # echo -e '0 195312 linear /dev/nvme2n1 0' | dmsetup create nvme2n1DM
> 
> 2. Create IMSM container.
> # dmdev=$(readlink -f /dev/mapper/nvme2n1DM)
> # export IMSM_DEVNAME_AS_SERIAL=1 IMSM_NO_PLATFORM=1; mdadm --create 
> /dev/md/container --metadata=imsm --raid-disks=1 $dmdev --force
> 
> Result:
> 
> Error message is displayed
> # mdadm: imsm: /dev/dm-0 is a partition, cannot be used in IMSM
> 
> Mdadm's function for checking "if partition" looks like so.
> 
> int test_partition(int fd)
> {
>      /* Check if fd is a whole-disk or a partition.
>       * BLKPG will return EINVAL on a partition, and BLKPG_DEL_PARTITION
>       * will return ENXIO on an invalid partition number.
>       */
>      struct blkpg_ioctl_arg a;
>      struct blkpg_partition p;
>      a.op = BLKPG_DEL_PARTITION;
>      a.data = (void*)&p;
>      a.datalen = sizeof(p);
>      a.flags = 0;
>      memset(a.data, 0, a.datalen);
>      p.pno = 1<<30;
>      if (ioctl(fd, BLKPG, &a) == 0)
>          /* Very unlikely, but not a partition */
>          return 0;
>      if (errno == ENXIO || errno == ENOTTY)
>          /* not a partition */
>          return 0;
> 
>      return 1;
> }
> 
> I plugged in with debugger and established that when ioctl is run on 
> dm-device errno is EINVAL, as if it was a partition.

This is a known regression, reported here:

https://lore.kernel.org/all/CAOYeF9VsmqKMcQjo1k6YkGNujwN-nzfxY17N3F-CMikE1tYp+w@mail.gmail.com/

please try this patch:

https://lore.kernel.org/all/20240118130401.792757-1-lilingfeng@huaweicloud.com/

Thanks,
Kuai

> 
> The issue is reproducible only with newer kernels which leads me te 
> believe there is a regression in device mapper. This code has been 
> working stable for last 10+ years, which is another reason. I tested 
> this on RHEL 8.9 with inbox 5.14 kernel and 6.5.7-1 I happen to have 
> installed. The issue reproduced only on 6.5.7-1 kernel. I also observed 
> same regression on stock Ubuntu 24.04 with inbox 6.6.0 kernel.
> 
> Can you please point me to when it was introduced and are there any 
> plans for fixing it?
> 
> Thanks,
> Mateusz
> 
> .
> 


      reply	other threads:[~2024-03-25  2:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21  9:17 regression: mdadm detects dm-device as partition Mateusz Kusiak
2024-03-25  2:41 ` Yu Kuai [this message]

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=c7db2443-06d4-a199-02ac-f58204118cb6@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-raid@vger.kernel.org \
    --cc=mateusz.kusiak@linux.intel.com \
    --cc=yukuai3@huawei.com \
    /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).