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

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