summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Berra <bluca@comedia.it>2006-10-16 15:26:53 +1000
committerNeil Brown <neilb@suse.de>2006-10-16 15:26:53 +1000
commit435d4ebb2e39fec062e201d287e8f73369291522 (patch)
treee545579e6e07580ada3237aef9e9bf72bce4dc25
parentb39827de21032f5bda931242f232ec9c3cb7da98 (diff)
downloadmdadm-435d4ebb2e39fec062e201d287e8f73369291522.tar.gz
mdadm-435d4ebb2e39fec062e201d287e8f73369291522.tar.xz
mdadm-435d4ebb2e39fec062e201d287e8f73369291522.zip
Mdassemble improvements
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.
-rw-r--r--ChangeLog4
-rw-r--r--Makefile2
-rw-r--r--Manage.c3
-rw-r--r--mdassemble.810
-rw-r--r--mdassemble.c13
-rw-r--r--util.c6
6 files changed, 29 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 44fd296..0f087a7 100644
--- 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
diff --git a/Makefile b/Makefile
index 73fdf58..79aa88f 100644
--- 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
diff --git a/Manage.c b/Manage.c
index aea21e6..0378b6e 100644
--- 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
diff --git a/mdassemble.8 b/mdassemble.8
index 84479b7..3c6544f 100644
--- a/mdassemble.8
+++ b/mdassemble.8
@@ -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).
diff --git a/mdassemble.c b/mdassemble.c
index 1de5688..9926dde 100644
--- a/mdassemble.c
+++ b/mdassemble.c
@@ -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 1ccf4e1..97707d0 100644
--- 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)
{