NeilBrown: incremental_container: preserve 'in_sync' flag when adding to existing array.
Martin F. Krafft
madduck at alioth.debian.org
Thu May 7 12:11:42 UTC 2009
Module: mdadm
Branch: debian/experimental
Commit: 462906cdeebc07875a4c8653c86ca02c09280f78
URL: http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=462906cdeebc07875a4c8653c86ca02c09280f78
Author: NeilBrown <neilb at suse.de>
Date: Tue Apr 14 10:19:02 2009 +1000
incremental_container: preserve 'in_sync' flag when adding to existing array.
When building container members with -IR, we need to ensure that
devices added to an active array preserve the 'in_sync' status so they
don't needlessly get rebuilt.
So allow sysfs_add_disk to do this (only works in kernels since
2.6.30) and pass the relevant flag down.
Signed-off-by: NeilBrown <neilb at suse.de>
---
Assemble.c | 2 +-
Manage.c | 2 +-
managemon.c | 2 +-
mdadm.h | 3 ++-
sysfs.c | 8 ++++++--
util.c | 3 ++-
6 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 73d6ee2..4cf5405 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1228,7 +1228,7 @@ int assemble_container_content(struct supertype *st, int mdfd,
sysfs_free(sra);
for (dev = content->devs; dev; dev = dev->next)
- if (sysfs_add_disk(content, dev) == 0)
+ if (sysfs_add_disk(content, dev, 1) == 0)
working++;
else if (errno == EEXIST)
preexist++;
diff --git a/Manage.c b/Manage.c
index 7afd89b..1f38fa5 100644
--- a/Manage.c
+++ b/Manage.c
@@ -702,7 +702,7 @@ int Manage_subdevs(char *devname, int fd,
tst->ss->getinfo_super(tst, &new_mdi);
new_mdi.disk.major = disc.major;
new_mdi.disk.minor = disc.minor;
- if (sysfs_add_disk(sra, &new_mdi) != 0) {
+ if (sysfs_add_disk(sra, &new_mdi, 0) != 0) {
fprintf(stderr, Name ": add new device to external metadata"
" failed for %s\n", dv->devname);
close(container_fd);
diff --git a/managemon.c b/managemon.c
index e02c77e..3835c99 100644
--- a/managemon.c
+++ b/managemon.c
@@ -395,7 +395,7 @@ static void manage_member(struct mdstat_ent *mdstat,
* and open files for each newdev */
for (d = newdev; d ; d = d->next) {
struct mdinfo *newd;
- if (sysfs_add_disk(&newa->info, d) < 0)
+ if (sysfs_add_disk(&newa->info, d, 0) < 0)
continue;
newd = malloc(sizeof(*newd));
*newd = *d;
diff --git a/mdadm.h b/mdadm.h
index 83a7944..357dc43 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -373,7 +373,8 @@ extern int sysfs_get_str(struct mdinfo *sra, struct mdinfo *dev,
char *name, char *val, int size);
extern int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms);
extern int sysfs_set_array(struct mdinfo *info, int vers);
-extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd);
+extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd,
+ int in_sync);
extern int sysfs_disk_to_scsi_id(int fd, __u32 *id);
extern int sysfs_unique_holder(int devnum, long rdev);
extern int load_sys(char *path, char *buf);
diff --git a/sysfs.c b/sysfs.c
index d4a1e49..711dce1 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -530,7 +530,7 @@ int sysfs_set_array(struct mdinfo *info, int vers)
return rv;
}
-int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd)
+int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int in_sync)
{
char dv[100];
char nm[100];
@@ -556,8 +556,12 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd)
rv = sysfs_set_num(sra, sd, "offset", sd->data_offset);
rv |= sysfs_set_num(sra, sd, "size", (sd->component_size+1) / 2);
if (sra->array.level != LEVEL_CONTAINER) {
+ if (in_sync)
+ /* This can correctly fail if array isn't started,
+ * yet, so just ignore status for now.
+ */
+ sysfs_set_str(sra, sd, "state", "in_sync");
rv |= sysfs_set_num(sra, sd, "slot", sd->disk.raid_disk);
-// rv |= sysfs_set_str(sra, sd, "state", "in_sync");
}
return rv;
}
diff --git a/util.c b/util.c
index 02fc463..35bb91b 100644
--- a/util.c
+++ b/util.c
@@ -1092,7 +1092,8 @@ int add_disk(int mdfd, struct supertype *st,
int rv;
#ifndef MDASSEMBLE
if (st->ss->external) {
- rv = sysfs_add_disk(sra, info);
+ rv = sysfs_add_disk(sra, info,
+ info->disk.state & (1<<MD_DISK_SYNC));
if (! rv) {
struct mdinfo *sd2;
for (sd2 = sra->devs; sd2; sd2=sd2->next)
More information about the pkg-mdadm-commits
mailing list