]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Mdassemble improvements
authorLuca Berra <bluca@comedia.it>
Mon, 16 Oct 2006 05:26:53 +0000 (15:26 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 16 Oct 2006 05:26:53 +0000 (15:26 +1000)
From: Luca Berra <bluca@comedia.it>

- Fix a bug where mdassemble didn't close a filedescriptor and so couldn't assembele
  stacked arrays.
- Allow mdassemble, when run a second time, to mark all arrays as writable.
  This is useful if they are started read-only as is best at boot-time.

ChangeLog
Makefile
Manage.c
mdassemble.8
mdassemble.c
util.c

index 44fd296494f86a91f7e582fc0782c7bae516aac0..0f087a71379f7642ed9952cd7305c131f491efe7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@ Changes Prior to this release
     -   Reduce maximum bitmap usage when working with bitmap files,
        so that a only single-page allocations are made, even on
        64bit hosts with 4K pages.
+    -   Close stray fd in mdassemble so that it can assemble stacked
+       devices
+    -   If mdassemble finds an array already assembled, it marks it
+        read-write.
 
 Changes Prior to 2.5.4 release
     -   When creating devices in /dev/md/ create matching symlinks
index 73fdf5822461b3b91f32af9473f335bdc88bded7..79aa88f5188a0b553634291f0df76caf9fba42d8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -76,7 +76,7 @@ SRCS =  mdadm.c config.c mdstat.c  ReadMe.c util.c Manage.c Assemble.c Build.c \
 STATICSRC = pwgr.c
 STATICOBJS = pwgr.o
 
-ASSEMBLE_SRCS := mdassemble.c Assemble.c config.c dlink.c util.c super0.c super1.c sha1.c
+ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c dlink.c util.c super0.c super1.c sha1.c
 ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
 ifdef MDASSEMBLE_AUTO
 ASSEMBLE_SRCS += mdopen.c mdstat.c
index aea21e65945118505b30d4c82fc68275d78e1103..0378b6ee1f68f2446214782911c1a71af0029c6b 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -72,6 +72,8 @@ int Manage_ro(char *devname, int fd, int readonly)
        return 0;                       
 }
 
+#ifndef MDASSEMBLE
+
 int Manage_runstop(char *devname, int fd, int runstop, int quiet)
 {
        /* Run or stop the array. array must already be configured
@@ -394,3 +396,4 @@ int Manage_subdevs(char *devname, int fd,
        return 0;
        
 }
+#endif
index 84479b74c66edbaca44777f1250cadb99139bd0c..3c6544f0d6b4a5d18314755784c3ea258a9a7501 100644 (file)
@@ -25,6 +25,13 @@ Invoking
 .B mdassemble
 has the same effect as invoking
 .B mdadm --assemble --scan.
+.PP
+Invoking
+.B mdassemble
+a second time will make all defined arrays readwrite, this is useful if
+using the
+.B start_ro
+module parameter.
 
 .SH OPTIONS
 
@@ -54,6 +61,5 @@ define.
 .PP
 .BR mdadm (8),
 .BR mdadm.conf (5),
-.BR md (4).
-.PP
+.BR md (4),
 .BR diet (1).
index 1de5688da54108e720b51c8d9df8d395c010cf60..9926dde29404a125cae306fa9eca415804d612ea 100644 (file)
@@ -91,13 +91,14 @@ int main(int argc, char *argv[]) {
                                rv |= 1;
                                continue;
                        }
-                       if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0)
-                               /* already assembled, skip */
-                               continue;
-                       rv |= Assemble(array_list->st, array_list->devname, mdfd,
-                                          array_list,
-                                          NULL, NULL,
+                       if (ioctl(mdfd, GET_ARRAY_INFO, &array) < 0) {
+                               rv |= Assemble(array_list->st, array_list->devname, mdfd,
+                                          array_list, NULL, NULL,
                                           readonly, runstop, NULL, NULL, verbose, force);
+                       } else {
+                               rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */
+                       }
+                       close(mdfd);
                }
        return rv;
 }
diff --git a/util.c b/util.c
index 1ccf4e1623dbe1f3002d381a0a7acb8c98ade55f..97707d0df2f7584ffdfe23c18bd4a3ab2a7f93ef 100644 (file)
--- a/util.c
+++ b/util.c
@@ -241,6 +241,7 @@ int same_uuid(int a[4], int b[4], int swapuuid)
        }
 }
 
+#ifndef MDASSEMBLE
 int check_ext2(int fd, char *name)
 {
        /*
@@ -338,6 +339,7 @@ int ask(char *mesg)
        fprintf(stderr, Name ": assuming 'no'\n");
        return 0;
 }
+#endif /* MDASSEMBLE */
 
 char *map_num(mapping_t *map, int num)
 {
@@ -534,6 +536,7 @@ unsigned long calc_csum(void *super, int bytes)
        return csum;
 }
 
+#ifndef MDASSEMBLE
 char *human_size(long long bytes)
 {
        static char buf[30];
@@ -586,7 +589,9 @@ char *human_size_brief(long long bytes)
                        );
        return buf;
 }
+#endif
 
+#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
 int get_mdp_major(void)
 {
 static int mdp_major = -1;
@@ -670,6 +675,7 @@ void put_md_name(char *name)
        if (strncmp(name, "/dev/.tmp.md", 12)==0)
                unlink(name);
 }
+#endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
 
 int dev_open(char *dev, int flags)
 {