Need update superblock on time when deciding to do reshape
PATCH 1/1 Need update superblock on time when deciding to do reshape
Hi all
If the disks are not enough to have spaces for relocating the data_offset, it needs to run start_reshape and then run mdadm --grow --continue by systemd. But mdadm --grow --continue fails because it checkes that info->reshape_active is 0.
The info->reshape_active is set to 1 when the superblock feature_map have the flag MD_FEATURE_RESHAPE_ACTIVE. Superblock feature_map is set MD_FEATURE_RESHAPE_ACTIVE as mddev->reshape_position != MaxSector.
Function start_reshape calls raid5_start_reshape which changes mddev->reshape_position to 0. Then in md_check_recovery it updates the superblock to underlying devices. But there is a chance that the superblock haven't written to underlying devices, the mdadm reads the superblock data. So mdadm --grow --continue fails.
The steps to reproduce this:
mdadm -CR /dev/md0 -l5 -n3 /dev/loop[0-2] --bitmap=internal mdadm --wait /dev/md0
mdadm /dev/md0 -a /dev/loop3
mdadm --grow --raid-devices 4 /dev/md0
The loop device size is 500MB
[root@storageqe-09 ~]# cat /proc/mdstat Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 loop3[4] loop2[3] loop1[1] loop0[0]
1021952 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]
[>....................] reshape = 0.0% (1/510976) finish=0.0min speed=255488K/sec
bitmap: 1/1 pages [4KB], 65536KB chunkunused devices: <none>
So if we update the superblock on time, mdadm can read the right superblock data.
Signed-off-by <[email protected]>
--- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/md.c +1 -0
@@ -4350,6 +4350,7 @@ action_store(struct mddev *mddev, const char *page, size_t len)else {clear_bit (MD_RECOVERY_FROZEN , &mddev->recovery); err = mddev->pers->start_reshape (mddev); +md_update_sb (mddev,1 ); }mddev_unlock (mddev); }
Signature · 1 line
2.4.3
Quoted 24 lines · Xiao Ni
Hi all
If the disks are not enough to have spaces for relocating the
data_offset, it needs to runstart_reshapeand then run mdadm --grow --continue by systemd. But mdadm --grow --continue fails because it checkes thatinfo->reshape_activeis 0.The
info->reshape_activeis set to 1 when the superblockfeature_maphave the flagMD_FEATURE_RESHAPE_ACTIVE. Superblockfeature_mapis setMD_FEATURE_RESHAPE_ACTIVEasmddev->reshape_position!= MaxSector.Function
start_reshapecallsraid5_start_reshapewhich changesmddev->reshape_positionto 0. Then inmd_check_recoveryit updates the superblock to underlying devices. But there is a chance that the superblock haven't written to underlying devices, the mdadm reads the superblock data. So mdadm --grow --continue fails.The steps to reproduce this:
mdadm -CR/dev/md0-l5 -n3 /dev/loop[0-2] --bitmap=internal mdadm --wait/dev/md0
mdadm/dev/md0-a/dev/loop3
mdadm --grow --raid-devices 4/dev/md0
The loop device size is 500MB
Quoted 6 lines
[root@storageqe-09 ~]# cat
/proc/mdstatPersonalities : [raid6] [raid5] [raid4]
md0 : active raid5 loop3[4] loop2[3] loop1[1] loop0[0]1021952 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU] [>....................] reshape = 0.0% (1/510976) finish=0.0min speed=255488K/sec bitmap: 1/1 pages [4KB], 65536KB chunk
what's the bad effect of the --continue failure? I think reshape will still continue. Doing a update super there is ok, but I'm wondering if it's the good way. Could mdadm wait for MD_FEATURE_RESHAPE_ACTIVE then let systemd run? Because sounds like we are working around systemd bug, kernel itself will write superblock anyway soon, so we probably working around in userspace.
Quoted 15 lines
unused devices: <none>
So if we update the superblock on time, mdadm can read the right superblock data.
Signed-off-by <[email protected]>
--- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)drivers/md/md.c +0
-0
drivers/md/md.c action_store(struct mddev *mddev, const char *page, size_t len) · line 4353
Quoted 4 lines
drivers/md/md.c +1
-0@@ -4350,6 +4350,7 @@ action_store(struct mddev *mddev, const char *page, size_t len)else {clear_bit (MD_RECOVERY_FROZEN , &mddev->recovery); err = mddev->pers->start_reshape (mddev); +md_update_sb (mddev,1 );
write super even err != 0?
Thanks,
Shaohua
----- Original Message -----
Quoted 40 lines
From: "Shaohua Li" <[email protected]>
To: "Xiao Ni" <[email protected]>
Cc: [email protected], "Jes Sorensen" <[email protected]>
Sent: Saturday, May 21, 2016 1:59:46 AM
Subject: Re: [PATCH] Need update superblock on time when deciding to do reshapeQuoted 24 lines · Xiao Ni
Hi all
If the disks are not enough to have spaces for relocating the
data_offset, it needs to runstart_reshapeand then run mdadm --grow --continue by systemd. But mdadm --grow --continue fails because it checkes thatinfo->reshape_activeis 0.The
info->reshape_activeis set to 1 when the superblockfeature_maphave the flagMD_FEATURE_RESHAPE_ACTIVE. Superblockfeature_mapis setMD_FEATURE_RESHAPE_ACTIVEasmddev->reshape_position!= MaxSector.Function
start_reshapecallsraid5_start_reshapewhich changesmddev->reshape_positionto 0. Then inmd_check_recoveryit updates the superblock to underlying devices. But there is a chance that the superblock haven't written to underlying devices, the mdadm reads the superblock data. So mdadm --grow --continue fails.The steps to reproduce this:
mdadm -CR/dev/md0-l5 -n3 /dev/loop[0-2] --bitmap=internal mdadm --wait/dev/md0
mdadm/dev/md0-a/dev/loop3
mdadm --grow --raid-devices 4/dev/md0
The loop device size is 500MBQuoted 8 lines
[root@storageqe-09 ~]# cat
/proc/mdstatPersonalities : [raid6] [raid5] [raid4]
md0 : active raid5 loop3[4] loop2[3] loop1[1] loop0[0]1021952 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU] [>....................] reshape = 0.0% (1/510976) finish=0.0min speed=255488K/sec bitmap: 1/1 pages [4KB], 65536KB chunk
Quoted 7 lines
what's the bad effect of the --continue failure? I think reshape will still continue. Doing a update super there is ok, but I'm wondering if it's the good
way. Could mdadm wait forMD_FEATURE_RESHAPE_ACTIVEthen let systemd run? Because sounds like we are working around systemd bug, kernel itself will write
superblock anyway soon, so we probably working around in userspace.
There is no bad effect if --continue failure. It just miss one chance to go on reshaping. Yes, as you said we can fix this in userspace. I tried to start [email protected] 30 seconds later as [email protected] does. It can fix this too.
Sure it should be fixed this if mdadm try more times to check MD_FEATURE_RESHAPE_ACTIVE.
Quoted 12 lines
Quoted 12 lines
unused devices: <none>
So if we update the superblock on time, mdadm can read the right superblock data.
Signed-off-by <[email protected]>
--- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
drivers/md/md.c action_store(struct mddev *mddev, const char *page, · line 4354
Quoted 10 lines
drivers/md/md.c +1
-0@@ -4350,6 +4350,7 @@ action_store(struct mddev *mddev, const char *page, size_t len) else {clear_bit (MD_RECOVERY_FROZEN , &mddev->recovery); err = mddev->pers->start_reshape (mddev); +md_update_sb (mddev,1 );write super even err != 0?
Ah, sorry for this. It should update superblock only err is 0.
At first I want to fix this in userspace, but I ask myself why shouldn't update the superblock once start_reshape returns. There are some guys waiting for the update. The function action_store should update the superblock in time to tell the colleagues what happens now. Then I checked the places where md_update_sb is called. I found it is indeed called in some places where the md device changes. So I sent the patch here.
By the way, in size_store it update the superblock when err != 0. Is it right to check err there?
Best Regards
Xiao
Quoted 4 lines
Thanks,
Shaohua
Quoted 92 lines · Xiao Ni
----- Original Message -----
Quoted 40 lines
From: "Shaohua Li" <[email protected]>
To: "Xiao Ni" <[email protected]>
Cc: [email protected], "Jes Sorensen" <[email protected]>
Sent: Saturday, May 21, 2016 1:59:46 AM
Subject: Re: [PATCH] Need update superblock on time when deciding to do reshapeQuoted 24 lines · Xiao Ni
Hi all
If the disks are not enough to have spaces for relocating the
data_offset, it needs to runstart_reshapeand then run mdadm --grow --continue by systemd. But mdadm --grow --continue fails because it checkes thatinfo->reshape_activeis 0.The
info->reshape_activeis set to 1 when the superblockfeature_maphave the flagMD_FEATURE_RESHAPE_ACTIVE. Superblockfeature_mapis setMD_FEATURE_RESHAPE_ACTIVEasmddev->reshape_position!= MaxSector.Function
start_reshapecallsraid5_start_reshapewhich changesmddev->reshape_positionto 0. Then inmd_check_recoveryit updates the superblock to underlying devices. But there is a chance that the superblock haven't written to underlying devices, the mdadm reads the superblock data. So mdadm --grow --continue fails.The steps to reproduce this:
mdadm -CR/dev/md0-l5 -n3 /dev/loop[0-2] --bitmap=internal mdadm --wait/dev/md0
mdadm/dev/md0-a/dev/loop3
mdadm --grow --raid-devices 4/dev/md0
The loop device size is 500MBQuoted 8 lines
[root@storageqe-09 ~]# cat
/proc/mdstatPersonalities : [raid6] [raid5] [raid4]
md0 : active raid5 loop3[4] loop2[3] loop1[1] loop0[0]1021952 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU] [>....................] reshape = 0.0% (1/510976) finish=0.0min speed=255488K/sec bitmap: 1/1 pages [4KB], 65536KB chunkQuoted 7 lines
what's the bad effect of the --continue failure? I think reshape will still continue. Doing a update super there is ok, but I'm wondering if it's the good
way. Could mdadm wait forMD_FEATURE_RESHAPE_ACTIVEthen let systemd run? Because sounds like we are working around systemd bug, kernel itself will write
superblock anyway soon, so we probably working around in userspace.There is no bad effect if --continue failure. It just miss one chance to go on reshaping. Yes, as you said we can fix this in userspace. I tried to start [email protected] 30 seconds later as [email protected] does. It can fix this too.
Sure it should be fixed this if mdadm try more times to check
MD_FEATURE_RESHAPE_ACTIVE.Quoted 12 lines
Quoted 12 lines
unused devices: <none>
So if we update the superblock on time, mdadm can read the right superblock data.
Signed-off-by <[email protected]>
--- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
drivers/md/md.c action_store(struct mddev *mddev, const char *page, · line 4354
Quoted 10 lines
drivers/md/md.c +1
-0@@ -4350,6 +4350,7 @@ action_store(struct mddev *mddev, const char *page, size_t len) else {clear_bit (MD_RECOVERY_FROZEN , &mddev->recovery); err = mddev->pers->start_reshape (mddev); +md_update_sb (mddev,1 );write super even err != 0?
Ah, sorry for this. It should update superblock only err is 0.
At first I want to fix this in userspace, but I ask myself why shouldn't update the superblock once
start_reshapereturns. There are some guys waiting for the update. The functionaction_storeshould update the superblock in time to tell the colleagues what happens now. Then I checked the places wheremd_update_sbis called. I found it is indeed called in some places where the md device changes. So I sent the patch here.
Quoted 2 lines
By the way, in
size_storeit update the superblock when err != 0. Is it right to check err there?
I think we should. probably nobody noticed it before.
Thanks,
Shaohua
----- Original Message -----
Quoted 112 lines
From: "Shaohua Li" <[email protected]>
To: "Xiao Ni" <[email protected]>
Cc: [email protected], "Jes Sorensen" <[email protected]>
Sent: Tuesday, May 24, 2016 3:02:04 AM
Subject: Re: [PATCH] Need update superblock on time when deciding to do reshapeQuoted 105 lines · Xiao Ni
----- Original Message -----
Quoted 44 lines
From: "Shaohua Li" <[email protected]>
To: "Xiao Ni" <[email protected]>
Cc: [email protected], "Jes Sorensen" <[email protected]>
Sent: Saturday, May 21, 2016 1:59:46 AM
Subject: Re: [PATCH] Need update superblock on time when deciding to do reshapeQuoted 27 lines · Xiao Ni
Hi all
If the disks are not enough to have spaces for relocating the
data_offset,
it needs to runstart_reshapeand then run mdadm --grow --continue by systemd. But mdadm --grow --continue fails because it checkes thatinfo->reshape_activeis 0.The
info->reshape_activeis set to 1 when the superblockfeature_maphave the flagMD_FEATURE_RESHAPE_ACTIVE. Superblockfeature_mapis setMD_FEATURE_RESHAPE_ACTIVEasmddev->reshape_position!= MaxSector.Function
start_reshapecallsraid5_start_reshapewhich changesmddev->reshape_positionto 0. Then inmd_check_recoveryit updates the superblock to underlying devices. But there is a chance that the superblock
haven't written to underlying devices, the mdadm reads the superblock data.
So mdadm --grow --continue fails.The steps to reproduce this:
mdadm -CR/dev/md0-l5 -n3 /dev/loop[0-2] --bitmap=internal mdadm --wait/dev/md0
mdadm/dev/md0-a/dev/loop3
mdadm --grow --raid-devices 4/dev/md0
The loop device size is 500MBQuoted 8 lines
[root@storageqe-09 ~]# cat
/proc/mdstatPersonalities : [raid6] [raid5] [raid4]
md0 : active raid5 loop3[4] loop2[3] loop1[1] loop0[0]1021952 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU] [>....................] reshape = 0.0% (1/510976) finish=0.0min speed=255488K/sec bitmap: 1/1 pages [4KB], 65536KB chunkQuoted 8 lines
what's the bad effect of the --continue failure? I think reshape will still
continue. Doing a update super there is ok, but I'm wondering if it's the good
way. Could mdadm wait forMD_FEATURE_RESHAPE_ACTIVEthen let systemd run? Because sounds like we are working around systemd bug, kernel itself will write
superblock anyway soon, so we probably working around in userspace.There is no bad effect if --continue failure. It just miss one chance to go on reshaping. Yes, as you said we can fix this in userspace. I tried to start [email protected] 30 seconds later as [email protected]
does. It can fix this too.Sure it should be fixed this if mdadm try more times to check
MD_FEATURE_RESHAPE_ACTIVE.Quoted 13 lines
Quoted 13 lines
unused devices: <none>
So if we update the superblock on time, mdadm can read the right superblock
data.Signed-off-by <[email protected]>
--- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)Quoted 13 lines
drivers/md/md.c action_store(struct mddev *mddev, const char · line 4355
Quoted 11 lines
drivers/md/md.c +1
-0@@ -4350,6 +4350,7 @@ action_store(struct mddev *mddev, const char *page, size_t len) else {clear_bit (MD_RECOVERY_FROZEN , &mddev->recovery); err = mddev->pers->start_reshape (mddev); +md_update_sb (mddev,1 );write super even err != 0?
Ah, sorry for this. It should update superblock only err is 0.
At first I want to fix this in userspace, but I ask myself why shouldn't update
the superblock oncestart_reshapereturns. There are some guys waiting for the
update. The functionaction_storeshould update the superblock in time to tell
the colleagues what happens now. Then I checked the places wheremd_update_sb
is called. I found it is indeed called in some places where the md device changes. So I sent the patch here.
Quoted 6 lines
Quoted 3 lines
By the way, in
size_storeit update the superblock when err != 0. Is it right
to check err there?I think we should. probably nobody noticed it before.
So does it mean you applied the way fixing the problem in kernel space? If you apply the method I'll re-send the patch.
Best Regards
Xiao
Quoted 119 lines · Xiao Ni
----- Original Message -----
Quoted 116 lines
From: "Shaohua Li" <[email protected]>
To: "Xiao Ni" <[email protected]>
Cc: [email protected], "Jes Sorensen" <[email protected]>
Sent: Tuesday, May 24, 2016 3:02:04 AM
Subject: Re: [PATCH] Need update superblock on time when deciding to do reshapeQuoted 108 lines · Xiao Ni
----- Original Message -----
Quoted 44 lines
From: "Shaohua Li" <[email protected]>
To: "Xiao Ni" <[email protected]>
Cc: [email protected], "Jes Sorensen" <[email protected]>
Sent: Saturday, May 21, 2016 1:59:46 AM
Subject: Re: [PATCH] Need update superblock on time when deciding to do reshapeQuoted 27 lines · Xiao Ni
Hi all
If the disks are not enough to have spaces for relocating the
data_offset,
it needs to runstart_reshapeand then run mdadm --grow --continue by systemd. But mdadm --grow --continue fails because it checkes thatinfo->reshape_activeis 0.The
info->reshape_activeis set to 1 when the superblockfeature_maphave the flagMD_FEATURE_RESHAPE_ACTIVE. Superblockfeature_mapis setMD_FEATURE_RESHAPE_ACTIVEasmddev->reshape_position!= MaxSector.Function
start_reshapecallsraid5_start_reshapewhich changesmddev->reshape_positionto 0. Then inmd_check_recoveryit updates the superblock to underlying devices. But there is a chance that the superblock
haven't written to underlying devices, the mdadm reads the superblock data.
So mdadm --grow --continue fails.The steps to reproduce this:
mdadm -CR/dev/md0-l5 -n3 /dev/loop[0-2] --bitmap=internal mdadm --wait/dev/md0
mdadm/dev/md0-a/dev/loop3
mdadm --grow --raid-devices 4/dev/md0
The loop device size is 500MBQuoted 8 lines
[root@storageqe-09 ~]# cat
/proc/mdstatPersonalities : [raid6] [raid5] [raid4]
md0 : active raid5 loop3[4] loop2[3] loop1[1] loop0[0]1021952 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU] [>....................] reshape = 0.0% (1/510976) finish=0.0min speed=255488K/sec bitmap: 1/1 pages [4KB], 65536KB chunkQuoted 8 lines
what's the bad effect of the --continue failure? I think reshape will still
continue. Doing a update super there is ok, but I'm wondering if it's the good
way. Could mdadm wait forMD_FEATURE_RESHAPE_ACTIVEthen let systemd run? Because sounds like we are working around systemd bug, kernel itself will write
superblock anyway soon, so we probably working around in userspace.There is no bad effect if --continue failure. It just miss one chance to go on reshaping. Yes, as you said we can fix this in userspace. I tried to start [email protected] 30 seconds later as [email protected]
does. It can fix this too.Sure it should be fixed this if mdadm try more times to check
MD_FEATURE_RESHAPE_ACTIVE.Quoted 13 lines
Quoted 13 lines
unused devices: <none>
So if we update the superblock on time, mdadm can read the right superblock
data.Signed-off-by <[email protected]>
--- drivers/md/md.c | 1 + 1 file changed, 1 insertion(+)Quoted 13 lines
drivers/md/md.c action_store(struct mddev *mddev, const char · line 4355
Quoted 11 lines
drivers/md/md.c +1
-0@@ -4350,6 +4350,7 @@ action_store(struct mddev *mddev, const char *page, size_t len) else {clear_bit (MD_RECOVERY_FROZEN , &mddev->recovery); err = mddev->pers->start_reshape (mddev); +md_update_sb (mddev,1 );write super even err != 0?
Ah, sorry for this. It should update superblock only err is 0.
At first I want to fix this in userspace, but I ask myself why shouldn't update
the superblock oncestart_reshapereturns. There are some guys waiting for the
update. The functionaction_storeshould update the superblock in time to tell
the colleagues what happens now. Then I checked the places wheremd_update_sb
is called. I found it is indeed called in some places where the md device changes. So I sent the patch here.By the way, in
size_storeit update the superblock when err != 0. Is it right
to check err there?
Quoted 5 lines
Quoted 2 lines
I think we should. probably nobody noticed it before.
So does it mean you applied the way fixing the problem in kernel space? If you apply the method I'll re-send the patch.
No, I didn't. I thought you agree with fixing it in userspace. For the err != 0 checking, I mean we probably should do it for size_store if somebody wants to fix it.