* [PATCH v2] mdadm: set journal_clean after scanning all disks
@ 2017-08-29 16:53 Song Liu
2017-08-29 20:45 ` NeilBrown
2017-09-01 15:12 ` Jes Sorensen
0 siblings, 2 replies; 3+ messages in thread
From: Song Liu @ 2017-08-29 16:53 UTC (permalink / raw)
To: linux-raid
Cc: Song Liu, shli, neilb, kernel-team, dan.j.williams, hch, jes.sorensen
Summary:
In Incremental.c:count_active(), max_events is tracked to show to
which devices are up to date. If a device has events==max_events+1,
getinfo_super() is called to reload the superblock from this
device. getinfo_super1() blindly set journal_clean to 0, which is
wrong.
This patch fixes this by tracking max_journal_events for all the
disks. After scanning all disks, journal_clean is set if
max_journal_events >= max_events-1.
Signed-off-by: Song Liu <songliubraving@fb.com>
---
Incremental.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Incremental.c b/Incremental.c
index 6cf2174..91301eb 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -684,6 +684,7 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
int cnt = 0;
int replcnt = 0;
__u64 max_events = 0;
+ __u64 max_journal_events = 0;
char *avail = NULL;
int *best = NULL;
char *devmap = NULL;
@@ -714,8 +715,9 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
info.array.raid_disks = raid_disks;
st->ss->getinfo_super(st, &info, devmap + raid_disks * devnum);
- if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL)
- bestinfo->journal_clean = 1;
+ if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL &&
+ info.events > max_journal_events)
+ max_journal_events = info.events;
if (!avail) {
raid_disks = info.array.raid_disks;
avail = xcalloc(raid_disks, 1);
@@ -765,6 +767,8 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
replcnt++;
st->ss->free_super(st);
}
+ if (max_journal_events >= max_events - 1)
+ bestinfo->journal_clean = 1;
if (!avail)
return 0;
--
2.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mdadm: set journal_clean after scanning all disks
2017-08-29 16:53 [PATCH v2] mdadm: set journal_clean after scanning all disks Song Liu
@ 2017-08-29 20:45 ` NeilBrown
2017-09-01 15:12 ` Jes Sorensen
1 sibling, 0 replies; 3+ messages in thread
From: NeilBrown @ 2017-08-29 20:45 UTC (permalink / raw)
To: linux-raid; +Cc: Song Liu, shli, kernel-team, dan.j.williams, hch, jes.sorensen
[-- Attachment #1: Type: text/plain, Size: 2151 bytes --]
On Tue, Aug 29 2017, Song Liu wrote:
> Summary:
> In Incremental.c:count_active(), max_events is tracked to show to
> which devices are up to date. If a device has events==max_events+1,
> getinfo_super() is called to reload the superblock from this
> device. getinfo_super1() blindly set journal_clean to 0, which is
> wrong.
>
> This patch fixes this by tracking max_journal_events for all the
> disks. After scanning all disks, journal_clean is set if
> max_journal_events >= max_events-1.
Thanks. That makes sense now.
Reviewed-by: NeilBrown <neilb@suse.com>
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> ---
> Incremental.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/Incremental.c b/Incremental.c
> index 6cf2174..91301eb 100644
> --- a/Incremental.c
> +++ b/Incremental.c
> @@ -684,6 +684,7 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
> int cnt = 0;
> int replcnt = 0;
> __u64 max_events = 0;
> + __u64 max_journal_events = 0;
> char *avail = NULL;
> int *best = NULL;
> char *devmap = NULL;
> @@ -714,8 +715,9 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
>
> info.array.raid_disks = raid_disks;
> st->ss->getinfo_super(st, &info, devmap + raid_disks * devnum);
> - if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL)
> - bestinfo->journal_clean = 1;
> + if (info.disk.raid_disk == MD_DISK_ROLE_JOURNAL &&
> + info.events > max_journal_events)
> + max_journal_events = info.events;
> if (!avail) {
> raid_disks = info.array.raid_disks;
> avail = xcalloc(raid_disks, 1);
> @@ -765,6 +767,8 @@ static int count_active(struct supertype *st, struct mdinfo *sra,
> replcnt++;
> st->ss->free_super(st);
> }
> + if (max_journal_events >= max_events - 1)
> + bestinfo->journal_clean = 1;
>
> if (!avail)
> return 0;
> --
> 2.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mdadm: set journal_clean after scanning all disks
2017-08-29 16:53 [PATCH v2] mdadm: set journal_clean after scanning all disks Song Liu
2017-08-29 20:45 ` NeilBrown
@ 2017-09-01 15:12 ` Jes Sorensen
1 sibling, 0 replies; 3+ messages in thread
From: Jes Sorensen @ 2017-09-01 15:12 UTC (permalink / raw)
To: Song Liu, linux-raid; +Cc: shli, neilb, kernel-team, dan.j.williams, hch
On 08/29/2017 12:53 PM, Song Liu wrote:
> Summary:
> In Incremental.c:count_active(), max_events is tracked to show to
> which devices are up to date. If a device has events==max_events+1,
> getinfo_super() is called to reload the superblock from this
> device. getinfo_super1() blindly set journal_clean to 0, which is
> wrong.
>
> This patch fixes this by tracking max_journal_events for all the
> disks. After scanning all disks, journal_clean is set if
> max_journal_events >= max_events-1.
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
Applied!
Thanks,
Jes
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-01 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 16:53 [PATCH v2] mdadm: set journal_clean after scanning all disks Song Liu
2017-08-29 20:45 ` NeilBrown
2017-09-01 15:12 ` Jes Sorensen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.