* [PATCH v2] super1.c: avoid useless sync when bitmap switches from clustered to none
@ 2021-02-03 0:22 Zhao Heming
2021-03-02 8:35 ` resend: [PATCH v2 mdadm] " heming.zhao
2021-03-03 14:30 ` [PATCH v2] " Jes Sorensen
0 siblings, 2 replies; 4+ messages in thread
From: Zhao Heming @ 2021-02-03 0:22 UTC (permalink / raw)
To: linux-raid, jes; +Cc: Zhao Heming, xni, lidong.zhong
With kernel commit 480523feae58 ("md: only call set_in_sync() when it
is expected to succeed."), mddev->in_sync in clustered array is always
zero. It makes metadata resync_offset to always zero.
When assembling a clusterd array with "-U no-bitmap" option, kernel
md layer "mddev->resync_offset == 0" and "mddev->bitmap == NULL" will
trigger raid1 do sync on every bitmap chunk. the sync action is useless,
we should avoid it.
Related kernel flow:
```
md_do_sync
mddev->pers->sync_request
raid1_sync_request
md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1)
__bitmap_start_sync(bitmap, offset,&blocks1, degraded)
if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */
*blocks = 1024;
return 1; /* always resync if no bitmap */
}
```
Reprodusible steps:
```
node1 # mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sd{a,b}
node1 # mdadm -Ss
(in another shell, executing & watching: watch -n 1 'cat /proc/mdstat')
node1 # mdadm -A -U no-bitmap /dev/md0 /dev/sd{a,b}
```
Signed-off-by: Zhao Heming <heming.zhao@suse.com>
---
v2: only set MaxSector on bitmap clean device
---
super1.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/super1.c b/super1.c
index 19fe6f5..9470025 100644
--- a/super1.c
+++ b/super1.c
@@ -1318,6 +1318,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
memcpy(bms->uuid, sb->set_uuid, 16);
} else if (strcmp(update, "no-bitmap") == 0) {
sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
+ if (bms->version == BITMAP_MAJOR_CLUSTERED && !IsBitmapDirty(devname))
+ sb->resync_offset = MaxSector;
} else if (strcmp(update, "bbl") == 0) {
/* only possible if there is room after the bitmap, or if
* there is no bitmap
--
2.30.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* resend: [PATCH v2 mdadm] super1.c: avoid useless sync when bitmap switches from clustered to none
2021-02-03 0:22 [PATCH v2] super1.c: avoid useless sync when bitmap switches from clustered to none Zhao Heming
@ 2021-03-02 8:35 ` heming.zhao
2021-03-02 8:39 ` heming.zhao
2021-03-03 14:30 ` [PATCH v2] " Jes Sorensen
1 sibling, 1 reply; 4+ messages in thread
From: heming.zhao @ 2021-03-02 8:35 UTC (permalink / raw)
To: linux-raid, jes; +Cc: Zhao Heming, xni, lidong.zhong
With kernel commit 480523feae58 ("md: only call set_in_sync() when it
is expected to succeed."), mddev->in_sync in clustered array is always
zero. It makes metadata resync_offset to always zero.
When assembling a clusterd array with "-U no-bitmap" option, kernel
md layer "mddev->resync_offset == 0" and "mddev->bitmap == NULL" will
trigger raid1 do sync on every bitmap chunk. the sync action is useless,
it wastes user a lot of time, we should avoid it.
Related kernel flow:
```
md_do_sync
mddev->pers->sync_request
raid1_sync_request
md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1)
__bitmap_start_sync(bitmap, offset,&blocks1, degraded)
if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */
*blocks = 1024;
return 1; /* always resync if no bitmap */
}
```
Reprodusible steps:
```
node1 # mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sd{a,b}
node1 # mdadm -Ss
(in another shell, executing & watching: watch -n 1 'cat /proc/mdstat')
node1 # mdadm -A -U no-bitmap /dev/md0 /dev/sd{a,b}
```
Signed-off-by: Zhao Heming <heming.zhao@suse.com>
---
v2: only set MaxSector on bitmap clean device
---
super1.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/super1.c b/super1.c
index 19fe6f5..9470025 100644
--- a/super1.c
+++ b/super1.c
@@ -1318,6 +1318,8 @@ static int update_super1(struct supertype *st, struct mdinfo *info,
memcpy(bms->uuid, sb->set_uuid, 16);
} else if (strcmp(update, "no-bitmap") == 0) {
sb->feature_map &= ~__cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
+ if (bms->version == BITMAP_MAJOR_CLUSTERED && !IsBitmapDirty(devname))
+ sb->resync_offset = MaxSector;
} else if (strcmp(update, "bbl") == 0) {
/* only possible if there is room after the bitmap, or if
* there is no bitmap
--
2.30.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: resend: [PATCH v2 mdadm] super1.c: avoid useless sync when bitmap switches from clustered to none
2021-03-02 8:35 ` resend: [PATCH v2 mdadm] " heming.zhao
@ 2021-03-02 8:39 ` heming.zhao
0 siblings, 0 replies; 4+ messages in thread
From: heming.zhao @ 2021-03-02 8:39 UTC (permalink / raw)
To: linux-raid, jes; +Cc: xni, lidong.zhong
On 3/2/21 4:35 PM, heming.zhao@suse.com wrote:
> With kernel commit 480523feae58 ("md: only call set_in_sync() when it
> is expected to succeed."), mddev->in_sync in clustered array is always
> zero. It makes metadata resync_offset to always zero.
> When assembling a clusterd array with "-U no-bitmap" option, kernel
> md layer "mddev->resync_offset == 0" and "mddev->bitmap == NULL" will
> trigger raid1 do sync on every bitmap chunk. the sync action is useless,
> ... ...
> ---
> v2: only set MaxSector on bitmap clean device
>
> ---
> super1.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/super1.c b/super1.c
Hello all,
more info:
This patch had been verified & run in SUSE customer env for some time.
Thanks,
Heming
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] super1.c: avoid useless sync when bitmap switches from clustered to none
2021-02-03 0:22 [PATCH v2] super1.c: avoid useless sync when bitmap switches from clustered to none Zhao Heming
2021-03-02 8:35 ` resend: [PATCH v2 mdadm] " heming.zhao
@ 2021-03-03 14:30 ` Jes Sorensen
1 sibling, 0 replies; 4+ messages in thread
From: Jes Sorensen @ 2021-03-03 14:30 UTC (permalink / raw)
To: Zhao Heming, linux-raid; +Cc: xni, lidong.zhong
On 2/2/21 7:22 PM, Zhao Heming wrote:
> With kernel commit 480523feae58 ("md: only call set_in_sync() when it
> is expected to succeed."), mddev->in_sync in clustered array is always
> zero. It makes metadata resync_offset to always zero.
> When assembling a clusterd array with "-U no-bitmap" option, kernel
> md layer "mddev->resync_offset == 0" and "mddev->bitmap == NULL" will
> trigger raid1 do sync on every bitmap chunk. the sync action is useless,
> we should avoid it.
>
> Related kernel flow:
> ```
> md_do_sync
> mddev->pers->sync_request
> raid1_sync_request
> md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1)
> __bitmap_start_sync(bitmap, offset,&blocks1, degraded)
> if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */
> *blocks = 1024;
> return 1; /* always resync if no bitmap */
> }
> ```
>
> Reprodusible steps:
> ```
> node1 # mdadm -C /dev/md0 -b clustered -e 1.2 -n 2 -l mirror /dev/sd{a,b}
> node1 # mdadm -Ss
> (in another shell, executing & watching: watch -n 1 'cat /proc/mdstat')
> node1 # mdadm -A -U no-bitmap /dev/md0 /dev/sd{a,b}
> ```
>
> Signed-off-by: Zhao Heming <heming.zhao@suse.com>
> ---
> v2: only set MaxSector on bitmap clean device
Applied!
Thanks,
Jes
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-04 0:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 0:22 [PATCH v2] super1.c: avoid useless sync when bitmap switches from clustered to none Zhao Heming
2021-03-02 8:35 ` resend: [PATCH v2 mdadm] " heming.zhao
2021-03-02 8:39 ` heming.zhao
2021-03-03 14:30 ` [PATCH v2] " Jes Sorensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).