Linux RAID subsystem development
 help / color / mirror / Atom feed
From: "Milan P. Gandhi" <mgandhi@redhat.com>
To: linux-raid@vger.kernel.org
Cc: mariusz.tkaczyk@linux.intel.com, jes@trained-monkey.org,
	"Milan P. Gandhi" <mgandhi@redhat.com>
Subject: [PATCH] mapfile: fix relative devname resolution in resolve_md_path
Date: Mon,  2 Nov 2026 16:01:36 +0530	[thread overview]
Message-ID: <20261102103136.163554-1-mgandhi@redhat.com> (raw)

When an array is defined in mdadm.conf using a relative device name
(e.g., 'ARRAY customalias UUID=...'), resolve_md_path() fails to resolve
it under DEV_MD_DIR during mapfile reconstruction.

The outer condition:
    if (match && match->devname && match->devname[0] == '/')
requires the configured devname to start with '/', rendering the nested
relative path handling unreachable:
    if (path[0] != '/') {
        strcpy(namebuf, DEV_MD_DIR);
        strcat(namebuf, path);
        path = namebuf;
    }

Consequently, commands that rebuild the runtime map (such as 'mdadm
--incremental --rebuild-map') bypass the configured relative alias and
fall back to the superblock's metadata name, creating an inconsistency
with assemble-time symlink creation.

Drop the redundant 'match->devname[0] == '/'' check from the outer
conditional so relative device names configured in mdadm.conf reach the
nested block, receive the DEV_MD_DIR prefix, and resolve to
/dev/md/<name>.

Test reproduction (RAID1 created with metadata name 'origarray',
mdadm.conf configured with 'ARRAY customalias UUID=<UUID>'):

    # rm -f /run/mdadm/map /dev/md/customalias

    Before patch (unpatched mdadm):
    # mdadm --incremental --rebuild-map --config=/tmp/test_mdadm.conf
    # cat /run/mdadm/map
    md99 1.2 fb1db62a:62817869:f8c2ab3f:f422a06d /dev/md/origarray

    After patch (patched mdadm):
    # ./mdadm --incremental --rebuild-map --config=/tmp/test_mdadm.conf
    # cat /run/mdadm/map
    md99 1.2 55f91d31:c1cc4a13:a18b124d:a8b77987 /dev/md/customalias

Fixes: 360b463696e8 ("mapfile - when rebuilding, choose an appropriate name is none is found.")
Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
---
 mapfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mapfile.c b/mapfile.c
index 2f198a92..f1cdee7a 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -381,7 +381,7 @@ static char *resolve_md_path(struct supertype *st, struct mdinfo *info, char *ho
 	struct stat stb;
 	int unum = -1;
 
-	if (match && match->devname && match->devname[0] == '/') {
+	if (match && match->devname) {
 		char *path = match->devname;
 
 		if (path[0] != '/') {
-- 
2.56.0


                 reply	other threads:[~2026-11-02 10:34 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=20261102103136.163554-1-mgandhi@redhat.com \
    --to=mgandhi@redhat.com \
    --cc=jes@trained-monkey.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mariusz.tkaczyk@linux.intel.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