Skip to contentSkip to conversation

md: limit mdstat resync progress to max_sectors

PATCH In review Nate Dailey 3 participants 4 messages Nov 30, 2017 – Dec 1, 2017 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md: limit mdstat resync progress to max_sectors

There is a small window near the end of md_do_sync where mddev->curr_resync can be equal to MaxSector.

If status_resync is called during this window, the resulting /proc/mdstat output contains a HUGE number of = signs due to the very large curr_resync:

Personalities : [raid1]
md123 : active raid1 sdd3[2] sdb3[0]
204736 blocks super 1.0 [2/1] [U_] [=====================================================================
... (82 MB more) ...
================>] recovery =429496729.3% (9223372036854775807/204736) finish=0.2min speed=12796K/sec
bitmap: 0/1 pages [0KB], 65536KB chunk

Modify status_resync to ensure the resync variable doesn't exceed the array's max_sectors.

---
 drivers/md/md.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/md.c +3 -1
index 41c050b59ec4..4e4dee0ec2de 100644
@@ -7605,7 +7605,9 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev)
 		if (test_bit(MD_RECOVERY_DONE, &mddev->recovery))
 			/* Still cleaning up */
 			resync = max_sectors;
-	} else
+	} else if (resync > max_sectors)
+		resync = max_sectors;
+	else
 		resync -= atomic_read(&mddev->recovery_active);
 
 	if (resync == 0) {
Signature · 1 line
2.14.1
Acked-by on v1 1/1
#1 lore raw

Actually, it is recovery :).

Quoted 2 lines · Nate Dailey

There is a small window near the end of md_do_sync where mddev->curr_resync can be equal to MaxSector.

I am curious about the purpose of set it to MaxSector, maybe the setting is not necessary.

Thanks,
Guoqing

Quoted 35 lines

If status_resync is called during this window, the resulting /proc/mdstat output contains a HUGE number of = signs due to the very large curr_resync:

Personalities : [raid1]
md123 : active raid1 sdd3[2] sdb3[0]
204736 blocks super 1.0 [2/1] [U_] [=====================================================================

    ... (82 MB more) ...
    ================>]  recovery =429496729.3% (9223372036854775807/204736)
    finish=0.2min speed=12796K/sec

bitmap: 0/1 pages [0KB], 65536KB chunk

Modify status_resync to ensure the resync variable doesn't exceed the array's max_sectors.

---
  drivers/md/md.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/md.c +3 -1
index 41c050b59ec4..4e4dee0ec2de 100644
@@ -7605,7 +7605,9 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev)
  		if (test_bit(MD_RECOVERY_DONE, &mddev->recovery))
  			/* Still cleaning up */
  			resync = max_sectors;
-	} else
+	} else if (resync > max_sectors)
+		resync = max_sectors;
+	else
  		resync -= atomic_read(&mddev->recovery_active);
 
  	if (resync == 0) {
#2 lore raw

Yes, I also wondered if setting curr_resync to MaxSector could be changed... but not understanding why it's done, it seemed safer to just catch this in status_resync.

Nate

Quoted 57 lines · Guoqing Jiang

Actually, it is recovery :).

Quoted 2 lines · Nate Dailey

There is a small window near the end of md_do_sync where mddev->curr_resync can be equal to MaxSector.

I am curious about the purpose of set it to MaxSector, maybe the setting is not
necessary.

Thanks,
Guoqing

drivers/md/md.c static int status_resync(struct seq_file *seq, struct

Quoted 25 lines

If status_resync is called during this window, the resulting /proc/mdstat output contains a HUGE number of = signs due to the very large curr_resync:

Personalities : [raid1]
md123 : active raid1 sdd3[2] sdb3[0]
204736 blocks super 1.0 [2/1] [U_] [===================================================================== ... (82 MB more) ...
================>] recovery =429496729.3% (9223372036854775807/204736) finish=0.2min speed=12796K/sec
bitmap: 0/1 pages [0KB], 65536KB chunk

Modify status_resync to ensure the resync variable doesn't exceed the array's max_sectors.

---
drivers/md/md.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/md.c +0 -0
index 41c050b59ec4..4e4dee0ec2de 100644
@@ -7605,7 +7605,9 @@ static int status_resync(struct seq_file *seq, struct 

mddev *mddev)

drivers/md/md.c static int status_resync(struct seq_file *seq, struct mddev *mddev) · line 7613

Quoted 10 lines
drivers/md/md.c +3 -1
 if (test_bit(MD_RECOVERY_DONE, &mddev->recovery))
 /* Still cleaning up */
 resync = max_sectors;
- } else
+ } else if (resync > max_sectors)
+ resync = max_sectors;
+ else
 resync -= atomic_read(&mddev->recovery_active);
 
 if (resync == 0) {

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html <http://vger.kernel.org/majordomo-info.html>

#3 lore raw
Quoted 3 lines · Nate Dailey

Yes, I also wondered if setting curr_resync to MaxSector could be changed... but not understanding why it's done, it seemed safer to just catch this in status_resync.

we use it to set rdev->recovery_offset, but that doesn't mean we must set it to MaxSector though. I applied the patch as-is, it's not a big issue.

Thanks,
Shaohua

Quoted 70 lines

Nate

Quoted 51 lines · Guoqing Jiang

Actually, it is recovery :).

Quoted 2 lines · Nate Dailey

There is a small window near the end of md_do_sync where mddev->curr_resync can be equal to MaxSector.

I am curious about the purpose of set it to MaxSector, maybe the setting is not
necessary.

Thanks,
Guoqing

drivers/md/md.c static int status_resync(struct seq_file *seq,

Quoted 25 lines

If status_resync is called during this window, the resulting /proc/mdstat output contains a HUGE number of = signs due to the very large curr_resync:

Personalities : [raid1]
md123 : active raid1 sdd3[2] sdb3[0]
204736 blocks super 1.0 [2/1] [U_] [===================================================================== ... (82 MB more) ...
================>] recovery =429496729.3% (9223372036854775807/204736) finish=0.2min speed=12796K/sec
bitmap: 0/1 pages [0KB], 65536KB chunk

Modify status_resync to ensure the resync variable doesn't exceed the array's max_sectors.

---
drivers/md/md.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/md.c +0 -0
index 41c050b59ec4..4e4dee0ec2de 100644
@@ -7605,7 +7605,9 @@ static int status_resync(struct seq_file *seq,

struct mddev *mddev)

Quoted 9 lines
drivers/md/md.c +3 -1
 if (test_bit(MD_RECOVERY_DONE, &mddev->recovery))
 /* Still cleaning up */
 resync = max_sectors;
- } else
+ } else if (resync > max_sectors)
+ resync = max_sectors;
+ else
 resync -= atomic_read(&mddev->recovery_active);
 
Quoted 7 lines

drivers/md/md.c static int status_resync(struct seq_file *seq, struct mddev *mddev) · line 7613

Quoted 1 line
drivers/md/md.c +0 -0
 if (resync == 0) {

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
<http://vger.kernel.org/majordomo-info.html>

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html