Skip to contentSkip to conversation

md: skip redundant raid_disks update when value is unchanged

PATCH Applied Abd-Alrhman Masalkhi 2 participants 2 messages Apr 28 – May 20 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 md: skip redundant raid_disks update when value is unchanged

Calling update_raid_disks() with the same value as the current one can trigger unnecessary work. For example, RAID1 will reallocate resources such as the mempool for r1bio.

---
 drivers/md/md.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/md/md.c +4 -3
index ac71640ff3a8..21b8ad17685f 100644
@@ -4409,9 +4409,10 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
 	err = mddev_suspend_and_lock(mddev);
 	if (err)
 		return err;
-	if (mddev->pers)
-		err = update_raid_disks(mddev, n);
-	else if (mddev->reshape_position != MaxSector) {
+	if (mddev->pers) {
+		if (n != mddev->raid_disks)
+			err = update_raid_disks(mddev, n);
+	} else if (mddev->reshape_position != MaxSector) {
 		struct md_rdev *rdev;
 		int olddisks = mddev->raid_disks - mddev->delta_disks;
 
Signature · 1 line
2.43.0
Applied
#1 lore raw
Quoted 8 lines · Abd-Alrhman Masalkhi

Calling update_raid_disks() with the same value as the current one can trigger unnecessary work. For example, RAID1 will reallocate resources such as the mempool for r1bio.

---
  drivers/md/md.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)

Applied to md-7.2

Signature · 2 lines
Thansk,
Kuai