Blame SOURCES/mdadm-set-journal_clean-after-scanning-all-disks.patch

2c1b57
From 3b8c7127558bad386c8350e039061107c9cf6cde Mon Sep 17 00:00:00 2001
2c1b57
From: Song Liu <songliubraving@fb.com>
2c1b57
Date: Tue, 29 Aug 2017 09:53:02 -0700
2c1b57
Subject: [RHEL7.5 PATCH 03/13] mdadm: set journal_clean after scanning all
2c1b57
 disks
2c1b57
2c1b57
Summary:
2c1b57
In Incremental.c:count_active(), max_events is tracked to show to
2c1b57
which devices are up to date. If a device has events==max_events+1,
2c1b57
getinfo_super() is called to reload the superblock from this
2c1b57
device. getinfo_super1() blindly set journal_clean to 0, which is
2c1b57
wrong.
2c1b57
2c1b57
This patch fixes this by tracking max_journal_events for all the
2c1b57
disks. After scanning all disks, journal_clean is set if
2c1b57
max_journal_events >= max_events-1.
2c1b57
2c1b57
Signed-off-by: Song Liu <songliubraving@fb.com>
2c1b57
Reviewed-by: NeilBrown <neilb@suse.com>
2c1b57
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2c1b57
---
2c1b57
 Incremental.c | 8 ++++++--
2c1b57
 1 file changed, 6 insertions(+), 2 deletions(-)
2c1b57
2c1b57
diff --git a/Incremental.c b/Incremental.c
2c1b57
index 6cf2174..91301eb 100644
2c1b57
--- a/Incremental.c
2c1b57
+++ b/Incremental.c
2c1b57
@@ -684,6 +684,7 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
2c1b57
 	int cnt = 0;
2c1b57
 	int replcnt = 0;
2c1b57
 	__u64 max_events = 0;
2c1b57
+	__u64 max_journal_events = 0;
2c1b57
 	char *avail = NULL;
2c1b57
 	int *best = NULL;
2c1b57
 	char *devmap = NULL;
2c1b57
@@ -714,8 +715,9 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
2c1b57
 
2c1b57
 		info.array.raid_disks = raid_disks;
2c1b57
 		st->ss->getinfo_super(st, &info, devmap + raid_disks * devnum);
2c1b57
-		if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL)
2c1b57
-			bestinfo->journal_clean = 1;
2c1b57
+		if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL &&
2c1b57
+		    info.events > max_journal_events)
2c1b57
+			max_journal_events = info.events;
2c1b57
 		if (!avail) {
2c1b57
 			raid_disks = info.array.raid_disks;
2c1b57
 			avail = xcalloc(raid_disks, 1);
2c1b57
@@ -765,6 +767,8 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
2c1b57
 			replcnt++;
2c1b57
 		st->ss->free_super(st);
2c1b57
 	}
2c1b57
+	if (max_journal_events >= max_events - 1)
2c1b57
+		bestinfo->journal_clean = 1;
2c1b57
 
2c1b57
 	if (!avail)
2c1b57
 		return 0;
2c1b57
-- 
2c1b57
2.7.4
2c1b57