From d17c1f8cbddb322f61c0b1ab4a06b5539dce4c52 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 4 Apr 2005 05:16:24 +0000 Subject: [PATCH] Reverse order of arrays when --stop --scan so that stacked arrays are stopped properly. Signed-off-by: Neil Brown --- ChangeLog | 2 ++ mdadm.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8a28181..9047116 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ Changes Prior to 1.9.0 release - Add some missing closes of open file descriptors. - Reread /proc/partition for every array assembled when using it to find devices, rather than only once. + - Make "mdadm -Ss" stop stacked devices properly, by reversing the + order in which arrays are stopped. Changes Prior to 1.8.0 release - Makefile cleanup from Luca Berra diff --git a/mdadm.c b/mdadm.c index 79f2886..798d638 100644 --- a/mdadm.c +++ b/mdadm.c @@ -793,6 +793,16 @@ int main(int argc, char *argv[]) /* apply to all devices in /proc/mdstat */ struct mdstat_ent *ms = mdstat_read(0); struct mdstat_ent *e; + if (devmode == 'S') { + /* reverse order so that arrays made of arrays are stopped properly */ + struct mdstat_ent *sm = NULL; + while ((e=ms) != NULL) { + ms = e->next; + e->next = sm; + sm = e; + } + ms = sm; + } for (e=ms ; e ; e=e->next) { char *name = get_md_name(e->devnum);