Dan Williams: Add scaffolding for handling md/dev-XXX/recovery_start

Martin F. Krafft madduck at alioth.debian.org
Wed Jan 27 02:04:08 UTC 2010


Module: mdadm
Branch: upstream
Commit: e1516be1db121e6f462b41a739106e33461a733a
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=e1516be1db121e6f462b41a739106e33461a733a

Author: Dan Williams <dan.j.williams at intel.com>
Date:   Mon Dec 21 10:06:14 2009 -0700

Add scaffolding for handling md/dev-XXX/recovery_start

Prepare the code to handle saving a recovery checkpoint.

Signed-off-by: Dan Williams <dan.j.williams at intel.com>

---

 managemon.c |    7 ++++++-
 mdadm.h     |    6 +++++-
 monitor.c   |    4 +++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/managemon.c b/managemon.c
index e77f045..e335077 100644
--- a/managemon.c
+++ b/managemon.c
@@ -112,8 +112,10 @@ static void close_aa(struct active_array *aa)
 {
 	struct mdinfo *d;
 
-	for (d = aa->info.devs; d; d = d->next)
+	for (d = aa->info.devs; d; d = d->next) {
+		close(d->recovery_fd);
 		close(d->state_fd);
+	}
 
 	close(aa->action_fd);
 	close(aa->info.state_fd);
@@ -517,6 +519,9 @@ static void manage_new(struct mdstat_ent *mdstat,
 			newd->state_fd = sysfs_open(new->devnum,
 						    newd->sys_name,
 						    "state");
+			newd->recovery_fd = sysfs_open(new->devnum,
+						      newd->sys_name,
+						      "recovery_start");
 
 			newd->prev_state = read_dev_state(newd->state_fd);
 			newd->curr_state = newd->prev_state;
diff --git a/mdadm.h b/mdadm.h
index c7f864b..7b75540 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -146,7 +146,10 @@ struct mdinfo {
 						    */
 	int			reshape_active;
 	unsigned long long	reshape_progress;
-	unsigned long long	resync_start;
+	union {
+		unsigned long long resync_start; /* per-array resync position */
+		unsigned long long recovery_start; /* per-device rebuild position */
+	};
 	unsigned long		safe_mode_delay; /* ms delay to mark clean */
 	int			new_level, delta_disks, new_layout, new_chunk;
 	int			errors;
@@ -168,6 +171,7 @@ struct mdinfo {
 	struct mdinfo *next;
 
 	/* Device info for mdmon: */
+	int recovery_fd;
 	int state_fd;
 	#define DS_FAULTY	1
 	#define	DS_INSYNC	2
diff --git a/monitor.c b/monitor.c
index a8e0af3..58752a8 100644
--- a/monitor.c
+++ b/monitor.c
@@ -208,8 +208,10 @@ static int read_and_act(struct active_array *a)
 	a->info.resync_start = read_resync_start(a->resync_start_fd);
 	for (mdi = a->info.devs; mdi ; mdi = mdi->next) {
 		mdi->next_state = 0;
-		if (mdi->state_fd >= 0)
+		if (mdi->state_fd >= 0) {
+			mdi->recovery_start = read_resync_start(mdi->recovery_fd);
 			mdi->curr_state = read_dev_state(mdi->state_fd);
+		}
 	}
 
 	if (a->curr_state <= inactive &&




More information about the pkg-mdadm-commits mailing list