Remove 'fd' arg from sysfs_add_disk
authorNeil Brown <neilb@suse.de>
Mon, 26 May 2008 23:18:32 +0000 (09:18 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 26 May 2008 23:18:32 +0000 (09:18 +1000)
It it never used, and removing means there are several 'open's that can
go.

Assemble.c
Create.c
Incremental.c
mdadm.h
sysfs.c

index ed40e57..9c320c2 100644 (file)
@@ -913,19 +913,12 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
                        if (j >= 0 /* && devices[j].uptodate */) {
 #ifndef MDASSEMBLE
                                if (st->ss->external) {
-                                       int fd = dev_open(devices[j].devname,
-                                                         O_RDONLY);
-                                       if (fd < 0)
-                                               rv = 1;
-                                       else {
-                                               devices[j].i.disk.number =
-                                                       devices[j].i.disk.raid_disk;
-                                               st->ss->getinfo_super_n(st,
-                                                              &devices[j].i);
-                                               rv = sysfs_add_disk(sra, fd,
-                                                             &devices[j].i);
-                                               close(fd);
-                                       }
+                                       devices[j].i.disk.number =
+                                               devices[j].i.disk.raid_disk;
+                                       st->ss->getinfo_super_n(st,
+                                                               &devices[j].i);
+                                       rv = sysfs_add_disk(sra,
+                                                           &devices[j].i);
                                } else
 #endif
                                        rv = ioctl(mdfd, ADD_NEW_DISK,
index 2b59d03..ee73548 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -640,16 +640,15 @@ int Create(struct supertype *st, char *mddev, int mdfd,
                                                     fd, dv->devname);
                                break;
                        case 2:
+                               close(fd);
                                info.component_size = info.array.size * 2;
                                info.errors = 0;
                                rv = 0;
 
                                if (st->ss->external) {
                                        st->ss->getinfo_super_n(st, &info);
-                                       rv = sysfs_add_disk(sra, fd, &info);
-                                       close(fd);
+                                       rv = sysfs_add_disk(sra, &info);
                                } else {
-                                       close(fd);
                                        rv = ioctl(mdfd, ADD_NEW_DISK,
                                                 &info.disk);
                                }
index 04e2e15..2c03a14 100644 (file)
@@ -793,14 +793,10 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
                sysfs_set_str(sra, NULL, "metadata_version", ver);
 
                sysfs_set_array(sra, ra);
-               for (dev = ra->devs; dev; dev = dev->next) {
-                       char buf[20];
-                       int dfd;
-                       sprintf(buf, "%d:%d", dev->disk.major, dev->disk.minor);
-                       dfd = dev_open(buf, O_RDONLY);
-                       if (sysfs_add_disk(sra, dfd, dev) == 0)
+               for (dev = ra->devs; dev; dev = dev->next)
+                       if (sysfs_add_disk(sra, dev) == 0)
                                working++;
-               }
+
                if (runstop > 0 || working >= ra->array.working_disks) {
                        switch(ra->array.level) {
                        case LEVEL_LINEAR:
diff --git a/mdadm.h b/mdadm.h
index c576095..6bf0c62 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -342,7 +342,7 @@ extern int sysfs_get_ll(struct mdinfo *sra, struct mdinfo *dev,
                        char *name, unsigned long long *val);
 extern int sysfs_set_array(struct mdinfo *sra,
                           struct mdinfo *info);
-extern int sysfs_add_disk(struct mdinfo *sra, int fd, struct mdinfo *sd);
+extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd);
 
 
 
diff --git a/sysfs.c b/sysfs.c
index 34840f7..87d314c 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -359,7 +359,7 @@ int sysfs_set_array(struct mdinfo *sra,
        return rv;
 }
 
-int sysfs_add_disk(struct mdinfo *sra, int fd, struct mdinfo *sd)
+int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd)
 {
        char dv[100];
        char nm[100];