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.
This commit is contained in:
Luca Berra 2006-10-16 15:26:53 +10:00 committed by Neil Brown
parent b39827de21
commit 435d4ebb2e
6 changed files with 29 additions and 9 deletions

View File

@ -4,6 +4,10 @@ Changes Prior to this release
- Reduce maximum bitmap usage when working with bitmap files, - Reduce maximum bitmap usage when working with bitmap files,
so that a only single-page allocations are made, even on so that a only single-page allocations are made, even on
64bit hosts with 4K pages. 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 Changes Prior to 2.5.4 release
- When creating devices in /dev/md/ create matching symlinks - When creating devices in /dev/md/ create matching symlinks

View File

@ -76,7 +76,7 @@ SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
STATICSRC = pwgr.c STATICSRC = pwgr.c
STATICOBJS = pwgr.o 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 ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
ifdef MDASSEMBLE_AUTO ifdef MDASSEMBLE_AUTO
ASSEMBLE_SRCS += mdopen.c mdstat.c ASSEMBLE_SRCS += mdopen.c mdstat.c

View File

@ -72,6 +72,8 @@ int Manage_ro(char *devname, int fd, int readonly)
return 0; return 0;
} }
#ifndef MDASSEMBLE
int Manage_runstop(char *devname, int fd, int runstop, int quiet) int Manage_runstop(char *devname, int fd, int runstop, int quiet)
{ {
/* Run or stop the array. array must already be configured /* Run or stop the array. array must already be configured
@ -394,3 +396,4 @@ int Manage_subdevs(char *devname, int fd,
return 0; return 0;
} }
#endif

View File

@ -25,6 +25,13 @@ Invoking
.B mdassemble .B mdassemble
has the same effect as invoking has the same effect as invoking
.B mdadm --assemble --scan. .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 .SH OPTIONS
@ -54,6 +61,5 @@ define.
.PP .PP
.BR mdadm (8), .BR mdadm (8),
.BR mdadm.conf (5), .BR mdadm.conf (5),
.BR md (4). .BR md (4),
.PP
.BR diet (1). .BR diet (1).

View File

@ -91,13 +91,14 @@ int main(int argc, char *argv[]) {
rv |= 1; rv |= 1;
continue; continue;
} }
if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0) if (ioctl(mdfd, GET_ARRAY_INFO, &array) < 0) {
/* already assembled, skip */
continue;
rv |= Assemble(array_list->st, array_list->devname, mdfd, rv |= Assemble(array_list->st, array_list->devname, mdfd,
array_list, array_list, NULL, NULL,
NULL, NULL,
readonly, runstop, NULL, NULL, verbose, force); readonly, runstop, NULL, NULL, verbose, force);
} else {
rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */
}
close(mdfd);
} }
return rv; return rv;
} }

6
util.c
View File

@ -241,6 +241,7 @@ int same_uuid(int a[4], int b[4], int swapuuid)
} }
} }
#ifndef MDASSEMBLE
int check_ext2(int fd, char *name) int check_ext2(int fd, char *name)
{ {
/* /*
@ -338,6 +339,7 @@ int ask(char *mesg)
fprintf(stderr, Name ": assuming 'no'\n"); fprintf(stderr, Name ": assuming 'no'\n");
return 0; return 0;
} }
#endif /* MDASSEMBLE */
char *map_num(mapping_t *map, int num) char *map_num(mapping_t *map, int num)
{ {
@ -534,6 +536,7 @@ unsigned long calc_csum(void *super, int bytes)
return csum; return csum;
} }
#ifndef MDASSEMBLE
char *human_size(long long bytes) char *human_size(long long bytes)
{ {
static char buf[30]; static char buf[30];
@ -586,7 +589,9 @@ char *human_size_brief(long long bytes)
); );
return buf; return buf;
} }
#endif
#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
int get_mdp_major(void) int get_mdp_major(void)
{ {
static int mdp_major = -1; static int mdp_major = -1;
@ -670,6 +675,7 @@ void put_md_name(char *name)
if (strncmp(name, "/dev/.tmp.md", 12)==0) if (strncmp(name, "/dev/.tmp.md", 12)==0)
unlink(name); unlink(name);
} }
#endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
int dev_open(char *dev, int flags) int dev_open(char *dev, int flags)
{ {