aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2016-06-02 02:19:52 -0400
committerShaohua Li <shli@fb.com>2016-06-13 14:54:13 -0400
commit414e6b9a7032a6c2f5ddf018fdb199190b075170 (patch)
treec9876ef9b5a3b111ee93d0215bb27190f5cb6505 /drivers/md
parent8430e7e0af9a15063b90343e3beebc164c8e90f3 (diff)
md/raid1, raid10: don't recheck "Faulty" flag in read-balance.
Re-checking the faulty flag here brings no value. The comment about "risk" refers to the risk that the device could be in the process of being removed by ->hot_remove_disk(). However providing that the ->nr_pending count is incremented inside an rcu_read_locked() region, there is no risk of that happening. This is because the rdev pointer (in the personalities array) is set to NULL before synchronize_rcu(), and ->nr_pending is tested afterwards. If the rcu_read_locked region happens before the synchronize_rcu(), the test will see that nr_pending has been incremented. If it happens afterwards, the rdev pointer will be NULL so there is nothing to increment. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid1.c7
-rw-r--r--drivers/md/raid10.c8
2 files changed, 0 insertions, 15 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 358a08e656f6..f6c3bd4913eb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -689,13 +689,6 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
689 if (!rdev) 689 if (!rdev)
690 goto retry; 690 goto retry;
691 atomic_inc(&rdev->nr_pending); 691 atomic_inc(&rdev->nr_pending);
692 if (test_bit(Faulty, &rdev->flags)) {
693 /* cannot risk returning a device that failed
694 * before we inc'ed nr_pending
695 */
696 rdev_dec_pending(rdev, conf->mddev);
697 goto retry;
698 }
699 sectors = best_good_sectors; 692 sectors = best_good_sectors;
700 693
701 if (conf->mirrors[best_disk].next_seq_sect != this_sector) 694 if (conf->mirrors[best_disk].next_seq_sect != this_sector)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 3578d3aa9ee3..ae4dce1cbc42 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -707,7 +707,6 @@ static struct md_rdev *read_balance(struct r10conf *conf,
707 707
708 raid10_find_phys(conf, r10_bio); 708 raid10_find_phys(conf, r10_bio);
709 rcu_read_lock(); 709 rcu_read_lock();
710retry:
711 sectors = r10_bio->sectors; 710 sectors = r10_bio->sectors;
712 best_slot = -1; 711 best_slot = -1;
713 best_rdev = NULL; 712 best_rdev = NULL;
@@ -804,13 +803,6 @@ retry:
804 803
805 if (slot >= 0) { 804 if (slot >= 0) {
806 atomic_inc(&rdev->nr_pending); 805 atomic_inc(&rdev->nr_pending);
807 if (test_bit(Faulty, &rdev->flags)) {
808 /* Cannot risk returning a device that failed
809 * before we inc'ed nr_pending
810 */
811 rdev_dec_pending(rdev, conf->mddev);
812 goto retry;
813 }
814 r10_bio->read_slot = slot; 806 r10_bio->read_slot = slot;
815 } else 807 } else
816 rdev = NULL; 808 rdev = NULL;