]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Avoid opening md device twice in particular '--assemble' instance.
authorNeilBrown <neilb@suse.de>
Mon, 3 Nov 2008 23:35:35 +0000 (10:35 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 3 Nov 2008 23:35:35 +0000 (10:35 +1100)
When
   mdadm --assemble /dev/whatever

is given, mdadm will treat it as though '--scan' were given, even
though it wasn't.
In this case, the code opens /dev/whatever twice, which is pointless.
We already know /dev/whatever is open at this point, so remove the
'open' and the tests, and make sure it is always closed afterwards.

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.c

diff --git a/mdadm.c b/mdadm.c
index b33f605bb9bd6798226d9c4b0dba1a62b779c963..c25f0078dad9568c4248817d06a2af8585ba7f85 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -1008,17 +1008,12 @@ int main(int argc, char *argv[])
                                fprintf(stderr, Name ": %s not identified in config file.\n",
                                        devlist->devname);
                                rv |= 1;
+                               close(mdfd);
                        } else {
-                               mdfd = create_mddev(devlist->devname,
-                                                 array_ident->autof ? array_ident->autof : autof);
-                               if (mdfd < 0)
-                                       rv |= 1;
-                               else {
-                                       rv |= Assemble(ss, devlist->devname, mdfd, array_ident,
+                               rv |= Assemble(ss, devlist->devname, mdfd, array_ident,
                                                       NULL, backup_file,
                                                       readonly, runstop, update, homehost, verbose-quiet, force);
-                                       close(mdfd);
-                               }
+                               close(mdfd);
                        }
                } else if (!scan)
                        rv = Assemble(ss, devlist->devname, mdfd, &ident,