Linux RAID subsystem development
 help / color / mirror / Atom feed
* [PATCH] mapfile: fix relative devname resolution in resolve_md_path
@ 2026-11-02 10:31 Milan P. Gandhi
  0 siblings, 0 replies; only message in thread
From: Milan P. Gandhi @ 2026-11-02 10:31 UTC (permalink / raw)
  To: linux-raid; +Cc: mariusz.tkaczyk, jes, Milan P. Gandhi

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-02 10:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 10:31 [PATCH] mapfile: fix relative devname resolution in resolve_md_path Milan P. Gandhi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox