Skip to contentSkip to conversation

md:Add break if find.

PATCH majianpeng 3 participants 3 messages Mar 13, 2012 – Mar 14, 2012 MD RAID

lore
Share & tools
lore

majianpeng

author
#0 lore raw

From 6e04c2374db7fc34ccbf9f37f85e735a349c816c Mon Sep 17 00:00:00 2001
From: majianpeng <[email protected]>
Date: Tue, 13 Mar 2012 13:26:25 +0800
Subject: [PATCH] md:Add break if find.

---
 drivers/md/raid5.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/md/raid5.c +3 -1
index 360f2b9..e05d9e5 100644
@@ -4369,8 +4369,10 @@ static inline sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int
 	 * recovery aborts.
 	 */
 	for (i = 0; i < conf->raid_disks; i++)
-		if (conf->disks[i].rdev == NULL)
+		if (conf->disks[i].rdev == NULL) {
 			still_degraded = 1;
+			break;
+		}
 
 	bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded);
 
Signature · 6 lines
1.7.5.4

 				
--------------
majianpeng
2012-03-13
#1 lore raw
Quoted 17 lines · On Tue, 13 Mar 2012 13:28:12 +0800 "majianpeng" <[email protected]> wrote:
Quoted 1 line

From 6e04c2374db7fc34ccbf9f37f85e735a349c816c Mon Sep 17 00:00:00 2001

From: majianpeng <[email protected]>
Date: Tue, 13 Mar 2012 13:26:25 +0800
Subject: [PATCH] md:Add break if find.

---
 drivers/md/raid5.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/md/raid5.c +0 -0
index 360f2b9..e05d9e5 100644
@@ -4369,8 +4369,10 @@ static inline sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int
 	 * recovery aborts.

drivers/md/raid5.c static inline sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int · line 4378

Quoted 10 lines
drivers/md/raid5.c +3 -1
 	 */
 	for (i = 0; i < conf->raid_disks; i++)
-		if (conf->disks[i].rdev == NULL)
+		if (conf->disks[i].rdev == NULL) {
 			still_degraded = 1;
+			break;
+		}
 
 	bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded);
 

Thanks - however I don't think I'll apply this one.

It is a micro optimisation which only improve an uncommon case a little, but it makes the source code long and the generated machine code longer (by 32 bytes on x86_64).
So I don't really think it is a win.

Thanks,
NeilBrown

#2 lore raw
In reply to majianpeng

Thansk,I know.

------------------
kedacomkernel
2012-03-14

-------------------------------------------------------------
发件人:NeilBrown
发送日期:2012-03-14 10:06:35
收件人:majianpeng
抄送:linux-raid
主题:Re: md:Add break if find.

Quoted 17 lines · On Tue, 13 Mar 2012 13:28:12 +0800 "majianpeng" <[email protected]> wrote:
Quoted 1 line

From 6e04c2374db7fc34ccbf9f37f85e735a349c816c Mon Sep 17 00:00:00 2001

From: majianpeng <[email protected]>
Date: Tue, 13 Mar 2012 13:26:25 +0800
Subject: [PATCH] md:Add break if find.

---
 drivers/md/raid5.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/md/raid5.c +0 -0
index 360f2b9..e05d9e5 100644
@@ -4369,8 +4369,10 @@ static inline sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int
 	 * recovery aborts.

drivers/md/raid5.c static inline sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int · line 4378

Quoted 10 lines
drivers/md/raid5.c +3 -1
 	 */
 	for (i = 0; i < conf->raid_disks; i++)
-		if (conf->disks[i].rdev == NULL)
+		if (conf->disks[i].rdev == NULL) {
 			still_degraded = 1;
+			break;
+		}
 
 	bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded);
 

Thanks - however I don't think I'll apply this one.

It is a micro optimisation which only improve an uncommon case a little, but it makes the source code long and the generated machine code longer (by 32 bytes on x86_64).
So I don't really think it is a win.

Thanks,
NeilBrown