Skip to contentSkip to conversation

md:Rewrite the md_write_start().

PATCH In review majianpeng 3 participants 4 messages Jun 2, 2012 – Jun 4, 2012 MD RAID

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 2/2 md:Rewrite the md_write_start().

Remove the judgement "bio_data_dir(bi) != WRITE" in md_write_start().Put it before call md_write_start.

---
 drivers/md/md.c     |    4 +---
 drivers/md/md.h     |    2 +-
 drivers/md/raid1.c  |    4 ++--
 drivers/md/raid10.c |    3 ++-
 drivers/md/raid5.c  |    3 ++-
 5 files changed, 8 insertions(+), 8 deletions(-)
drivers/md/md.c +1 -3
index 1c2f904..e009f1d 100644
@@ -7198,11 +7198,9 @@ void md_done_sync(struct mddev *mddev, int blocks, int ok)
  * in superblock) before writing, schedule a superblock update
  * and wait for it to complete.
  */
-void md_write_start(struct mddev *mddev, struct bio *bi)
+void md_write_start(struct mddev *mddev)
 {
 	int did_change = 0;
-	if (bio_data_dir(bi) != WRITE)
-		return;
 
 	BUG_ON(mddev->ro == 1);
 	if (mddev->ro == 2) {
drivers/md/md.h +1 -1
index 7b4a3c3..906e3db 100644
@@ -593,7 +593,7 @@ extern struct md_thread *md_register_thread(
 extern void md_unregister_thread(struct md_thread **threadp);
 extern void md_wakeup_thread(struct md_thread *thread);
 extern void md_check_recovery(struct mddev *mddev);
-extern void md_write_start(struct mddev *mddev, struct bio *bi);
+extern void md_write_start(struct mddev *mddev);
 extern void md_write_end(struct mddev *mddev);
 extern void md_done_sync(struct mddev *mddev, int blocks, int ok);
 extern void md_error(struct mddev *mddev, struct md_rdev *rdev);
drivers/md/raid1.c +2 -2
index 835de71..4bfa77d 100644
@@ -893,8 +893,8 @@ static void make_request(struct mddev *mddev, struct bio * bio)
 	 * thread has put up a bar for new requests.
 	 * Continue immediately if no resync is active currently.
 	 */
-
-	md_write_start(mddev, bio); /* wait on superblock update early */
+	if (rw == WRITE)
+		md_write_start(mddev); /* wait on superblock update early */
 
 	if (bio_data_dir(bio) == WRITE &&
 	    bio->bi_sector + bio->bi_size/512 > mddev->suspend_lo &&
drivers/md/raid10.c +2 -1
index 987db37..b10cb99 100644
@@ -1098,7 +1098,8 @@ static void make_request(struct mddev *mddev, struct bio * bio)
 		return;
 	}
 
-	md_write_start(mddev, bio);
+	if (rw == WRITE)
+		md_write_start(mddev);
 
 	/*
 	 * Register the new request and wait if the reconstruction
drivers/md/raid5.c +2 -1
index 5653125..8e330f8 100644
@@ -3983,7 +3983,8 @@ static void make_request(struct mddev *mddev, struct bio * bi)
 	     chunk_aligned_read(mddev,bi))
 		return;
 
-	md_write_start(mddev, bi);
+	if (rw == WRITE)
+		md_write_start(mddev);
 
 	logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
 	last_sector = bi->bi_sector + (bi->bi_size>>9);
Signature · 6 lines
1.7.5.4



--------------
majianpeng
#1 lore raw
Quoted 11 lines · majianpeng

Remove the judgement "bio_data_dir(bi) != WRITE" in md_write_start().Put it before call md_write_start.

---
 drivers/md/md.c     |    4 +---
 drivers/md/md.h     |    2 +-
 drivers/md/raid1.c  |    4 ++--
 drivers/md/raid10.c |    3 ++-
 drivers/md/raid5.c  |    3 ++-

 5 files changed, 8 insertions(+), 8 deletions(-)

If the deletions had outnumbered the insertions then maybe, but I think just like kfree() allowing NULL pointers it's cleaner if the caller need not worry.

--
Dan
--
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

author
#2 lore raw
Quoted 13 lines · Dan Williams
Quoted 11 lines · majianpeng

Remove the judgement "bio_data_dir(bi) != WRITE" in md_write_start().Put it before call md_write_start.

---

?drivers/md/md.c ? ? | ? ?4 +---
?drivers/md/md.h ? ? | ? ?2 +-
?drivers/md/raid1.c ?| ? ?4 ++--
?drivers/md/raid10.c | ? ?3 ++-
?drivers/md/raid5.c ?| ? ?3 ++-

?5 files changed, 8 insertions(+), 8 deletions(-)

Quoted 6 lines

If the deletions had outnumbered the insertions then maybe, but I think just like kfree() allowing NULL pointers it's cleaner if the caller need not worry.

--
Dan

The patch had a anthor reason: first check,if read so not call function. Call function takes long time than check statment.

#3 lore raw
Quoted 14 lines · On Mon, 4 Jun 2012 09:03:57 +0800 majianpeng <[email protected]> wrote:
Quoted 13 lines · Dan Williams
Quoted 11 lines · majianpeng

Remove the judgement "bio_data_dir(bi) != WRITE" in md_write_start().Put it before call md_write_start.

---

?drivers/md/md.c ? ? | ? ?4 +---
?drivers/md/md.h ? ? | ? ?2 +-
?drivers/md/raid1.c ?| ? ?4 ++--
?drivers/md/raid10.c | ? ?3 ++-
?drivers/md/raid5.c ?| ? ?3 ++-

?5 files changed, 8 insertions(+), 8 deletions(-)

Quoted 9 lines
Quoted 6 lines

If the deletions had outnumbered the insertions then maybe, but I think just like kfree() allowing NULL pointers it's cleaner if the caller need not worry.

--
Dan

The patch had a anthor reason: first check,if read so not call function. Call function takes long time than check statment.

This is micro-optimisation that really isn't worth spending any time on.

NeilBrown