Skip to contentSkip to conversation

missing close in mdassemble

PATCH In review Luca Berra 1 participant 2 messages Sep 13, 2006 – Sep 15, 2006

Subsystems (2)
lore
Share & tools
lore

Luca Berra

author
#0 lore raw

PATCH 1/1 missing close in mdassemble

attached, please apply
without this mdassemble cannot activate stacked arrays, i wonder how i managed to miss it :(

L.

Signature · 6 lines
Luca Berra -- [email protected]
       Communication Media & Services S.r.l.
/"\
\ /     ASCII RIBBON CAMPAIGN
 X        AGAINST HTML MAIL
/ \
mdassemble.c renamed from mdassemble.c.close +2 -3
@@ -91,13 +91,12 @@
 				rv |= 1;
 				continue;
 			}
-			if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0)
-				/* already assembled, skip */
-				continue;
+			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);
+			close(mdfd);
 		}
 	return rv;
 }
author
#1 lore raw
Quoted 4 lines · Luca Berra

attached, please apply
without this mdassemble cannot activate stacked arrays, i wonder how i managed to miss it :(

Another patch which obsoletes the previous one
this will make mdassemble, if run a second time, try to make arrays read-write. Useful if one starts arrays readonly as described in README.initramfs, after resume fails.

L.

Signature · 6 lines
Luca Berra -- [email protected]
       Communication Media & Services S.r.l.
/"\
\ /     ASCII RIBBON CAMPAIGN
 X        AGAINST HTML MAIL
/ \
mdassemble.c renamed from mdassemble.c.close +7 -6
@@ -91,13 +91,14 @@
 				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;
 }
Makefile renamed from Makefile.close +1 -1
@@ -76,7 +76,7 @@
 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
Manage.c renamed from Manage.c.close +4 -0
@@ -72,6 +72,8 @@
 	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
@@ -393,3 +395,5 @@
 	return 0;
 	
 }
+
+#endif /* MDASSEMBLE */
util.c renamed from util.c.close +6 -1
@@ -189,6 +189,7 @@
 	}
 }
 
+#ifndef MDASSEMBLE
 int check_ext2(int fd, char *name)
 {
 	/*
@@ -286,6 +287,7 @@
 	fprintf(stderr, Name ": assuming 'no'\n");
 	return 0;
 }
+#endif /* MDASSEMBLE */
 
 char *map_num(mapping_t *map, int num)
 {
@@ -307,7 +309,6 @@
 	return UnSet;
 }
 
-
 int is_standard(char *dev, int *nump)
 {
 	/* tests if dev is a "standard" md dev name.
@@ -482,6 +483,7 @@
 	return csum;
 }
 
+#ifndef MDASSEMBLE
 char *human_size(long long bytes)
 {
 	static char buf[30];
@@ -534,7 +536,9 @@
 			);
 	return buf;
 }
+#endif /* MDASSEMBLE */
 
+#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
 int get_mdp_major(void)
 {
 static int mdp_major = -1;
@@ -618,6 +622,7 @@
 	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)
 {
mdassemble.8 renamed from mdassemble.8.close +8 -2
@@ -25,6 +25,13 @@
 .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 @@
 .PP
 .BR mdadm (8),
 .BR mdadm.conf (5),
-.BR md (4).
-.PP
+.BR md (4),
 .BR diet (1).