]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: allow any valid minor number in md device name
authorMartin Wilck <mwilck@suse.com>
Wed, 30 Apr 2025 19:18:36 +0000 (21:18 +0200)
committerMariusz Tkaczyk <mtkaczyk@kernel.org>
Thu, 8 May 2025 07:08:26 +0000 (09:08 +0200)
Since 25aa732 ("mdadm: numbered names verification"), it is not possible
any more to create arrays /dev/md${N} with N >= 127. The limit has later
been increased to 1024, which is also artificial. The error message printed
by mdadm is misleading, as the problem is not POSIX compatibility here.

  # mdadm -C -v /dev/md9999 --name=foo -l1 -n2 /dev/loop0 /dev/loop1
  mdadm: Value "/dev/md9999" cannot be set as devname. Reason: Not POSIX compatible.

Given that mdadm creates an array with minor number ${N} if the argument is
/dev/md${N}, the natural limit for the number is the highest minor number
available, which is (1 << MINORBITS) with MINORBITS=20 on Linux.

Fixes: 25aa732 ("mdadm: numbered names verification")
Fixes: f786072 ("mdadm: Increase number limit in md device name to 1024.")
Signed-off-by: Martin Wilck <mwilck@suse.com>
util.c

diff --git a/util.c b/util.c
index 9fe2d2276712909559841e8a2df07c9aa6ba1190..0f77521149f8161bf1a243e0ce4f0cd4c64a2f1d 100644 (file)
--- a/util.c
+++ b/util.c
@@ -972,7 +972,8 @@ static bool is_devname_numbered(const char *devname, const char *pref, const int
        if (parse_num(&val, devname + pref_len) != 0)
                return false;
 
-       if (val > 1024)
+       /* Allow any number that represents a valid minor number */
+       if (val >= (1 << 20))
                return false;
 
        return true;