[Patch v1 2/4] md/raid5: simplify handle_strype_dirtying()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



md/raid5: simplify handle_strype_dirtying()

Calculating rcw/rmw inside handle_stripe_dirtying() depends on 
nearly doubled code. Consolidate parts of it.

Signed-off-by: Markus Stockhausen <stockhausen@xxxxxxxxxxx>

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 817d125..6a7e638 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3548,7 +3548,7 @@ static void handle_stripe_dirtying(struct r5conf *conf,
 				   struct stripe_head_state *s,
 				   int disks)
 {
-	int rmw = 0, rcw = 0, i;
+	int rmw = 0, rcw = 0, i, cost;
 	sector_t recovery_cp = conf->mddev->recovery_cp;
 
 	/* Check whether resync is now happening or should start.
@@ -3569,27 +3569,17 @@ static void handle_stripe_dirtying(struct r5conf *conf,
 			 conf->rmw_level, (unsigned long long)recovery_cp,
 			 (unsigned long long)sh->sector);
 	} else for (i = disks; i--; ) {
-		/* would I have to read this buffer for read_modify_write */
 		struct r5dev *dev = &sh->dev[i];
-		if ((dev->towrite || i == sh->pd_idx || i == sh->qd_idx) &&
-		    !test_bit(R5_LOCKED, &dev->flags) &&
+		if (!test_bit(R5_LOCKED, &dev->flags) &&
 		    !(test_bit(R5_UPTODATE, &dev->flags) ||
 		      test_bit(R5_Wantcompute, &dev->flags))) {
-			if (test_bit(R5_Insync, &dev->flags))
-				rmw++;
-			else
-				rmw += 2*disks;  /* cannot read it */
-		}
-		/* Would I have to read this buffer for reconstruct_write */
-		if (!test_bit(R5_OVERWRITE, &dev->flags) &&
-		    i != sh->pd_idx && i != sh->qd_idx &&
-		    !test_bit(R5_LOCKED, &dev->flags) &&
-		    !(test_bit(R5_UPTODATE, &dev->flags) ||
-		    test_bit(R5_Wantcompute, &dev->flags))) {
-			if (test_bit(R5_Insync, &dev->flags))
-				rcw++;
-			else
-				rcw += 2*disks;
+			/* IO cost for RMW/RCW depends on block readability */
+			cost = (test_bit(R5_Insync, &dev->flags)) ? 1 : 2*MAX_DISKS;
+			if (dev->towrite || i == sh->pd_idx || i == sh->qd_idx)
+				rmw += cost;
+			if (!test_bit(R5_OVERWRITE, &dev->flags) &&
+			    i != sh->pd_idx && i != sh->qd_idx)
+				rcw += cost;
 		}
 	}
 	pr_debug("for sector %llu, rmw=%d rcw=%d\n",


****************************************************************************
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und
vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
Weitergabe dieser Mail ist nicht gestattet.

�ber das Internet versandte E-Mails können unter fremden Namen erstellt oder
manipuliert werden. Deshalb ist diese als E-Mail verschickte Nachricht keine
rechtsverbindliche Willenserklärung.

Collogia
Unternehmensberatung AG
Ubierring 11
D-50678 Köln

Vorstand:
Kadir Akin
Dr. Michael Höhnerbach

Vorsitzender des Aufsichtsrates:
Hans Kristian Langva

Registergericht: Amtsgericht Köln
Registernummer: HRB 52 497

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

e-mails sent over the internet may have been written under a wrong name or
been manipulated. That is why this message sent as an e-mail is not a
legally binding declaration of intention.

Collogia
Unternehmensberatung AG
Ubierring 11
D-50678 Köln

executive board:
Kadir Akin
Dr. Michael Höhnerbach

President of the supervisory board:
Hans Kristian Langva

Registry office: district court Cologne
Register number: HRB 52 497

****************************************************************************

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux