Skip to contentSkip to conversation

md/raid456:Remove the judgement atomic_read(&rdev->read_errors).

PATCH In review majianpeng 2 participants 2 messages May 23, 2012 MD RAID

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 1/1 md/raid456:Remove the judgement atomic_read(&rdev->read_errors).

It isn't necessary to judge.Because the atomic_read and atomic_set is excuce same cpu. So read_errors is zero or not, directly set it zero.

---
 drivers/md/raid5.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/md/raid5.c +1 -2
index f351422..1fe2def 100644
@@ -1690,8 +1690,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
 			clear_bit(R5_ReadError, &sh->dev[i].flags);
 			clear_bit(R5_ReWrite, &sh->dev[i].flags);
 		}
-		if (atomic_read(&rdev->read_errors))
-			atomic_set(&rdev->read_errors, 0);
+		atomic_set(&rdev->read_errors, 0);
 	} else {
 		const char *bdn = bdevname(rdev->bdev, b);
 		int retry = 0;
Signature · 5 lines
1.7.5.4
 				
--------------
majianpeng
2012-05-23
#1 lore raw
Quoted 2 lines · On Wed, 23 May 2012 20:38:16 +0800 "majianpeng" <[email protected]> wrote:

It isn't necessary to judge.Because the atomic_read and atomic_set is excuce same cpu. So read_errors is zero or not, directly set it zero.

'read' imposes less bus contention than 'write'. And read_errors will most often be 0. So if we can avoid lots of unnecessary writes we should.

i.e. code is correct as it is.

Thanks,
NeilBrown

Quoted 19 lines
---
 drivers/md/raid5.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/md/raid5.c +1 -2
index f351422..1fe2def 100644
@@ -1690,8 +1690,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
 			clear_bit(R5_ReadError, &sh->dev[i].flags);
 			clear_bit(R5_ReWrite, &sh->dev[i].flags);
 		}
-		if (atomic_read(&rdev->read_errors))
-			atomic_set(&rdev->read_errors, 0);
+		atomic_set(&rdev->read_errors, 0);
 	} else {
 		const char *bdn = bdevname(rdev->bdev, b);
 		int retry = 0;