From: NeilBrown The ->nr_pending counted should always be decremented with rdev_dec_pending, as this need to do things when the count hits zero. There were a few places where it was being decremented directly. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton --- 25-akpm/drivers/md/multipath.c | 2 +- 25-akpm/drivers/md/raid1.c | 4 ++-- 25-akpm/drivers/md/raid10.c | 4 ++-- 25-akpm/drivers/md/raid5.c | 2 +- 25-akpm/drivers/md/raid6main.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff -puN drivers/md/multipath.c~md-make-sure-md-always-uses-rdev_dec_pending-properly drivers/md/multipath.c --- 25/drivers/md/multipath.c~md-make-sure-md-always-uses-rdev_dec_pending-properly Thu Oct 21 15:07:47 2004 +++ 25-akpm/drivers/md/multipath.c Thu Oct 21 15:07:47 2004 @@ -150,7 +150,7 @@ static void unplug_slaves(mddev_t *mddev r_queue->unplug_fn(r_queue); spin_lock_irqsave(&conf->device_lock, flags); - atomic_dec(&rdev->nr_pending); + rdev_dec_pending(rdev, mddev); } } spin_unlock_irqrestore(&conf->device_lock, flags); diff -puN drivers/md/raid10.c~md-make-sure-md-always-uses-rdev_dec_pending-properly drivers/md/raid10.c --- 25/drivers/md/raid10.c~md-make-sure-md-always-uses-rdev_dec_pending-properly Thu Oct 21 15:07:47 2004 +++ 25-akpm/drivers/md/raid10.c Thu Oct 21 15:07:47 2004 @@ -594,7 +594,7 @@ static void unplug_slaves(mddev_t *mddev r_queue->unplug_fn(r_queue); spin_lock_irqsave(&conf->device_lock, flags); - atomic_dec(&rdev->nr_pending); + rdev_dec_pending(rdev, mddev); } } spin_unlock_irqrestore(&conf->device_lock, flags); @@ -1493,7 +1493,7 @@ static int sync_request(mddev_t *mddev, for (i=0; icopies; i++) { int d = r10_bio->devs[i].devnum; if (r10_bio->devs[i].bio->bi_end_io) - atomic_dec(&conf->mirrors[d].rdev->nr_pending); + rdev_dec_pending(conf->mirrors[d].rdev, mddev); } put_buf(r10_bio); goto giveup; diff -puN drivers/md/raid1.c~md-make-sure-md-always-uses-rdev_dec_pending-properly drivers/md/raid1.c --- 25/drivers/md/raid1.c~md-make-sure-md-always-uses-rdev_dec_pending-properly Thu Oct 21 15:07:47 2004 +++ 25-akpm/drivers/md/raid1.c Thu Oct 21 15:07:47 2004 @@ -440,7 +440,7 @@ static void unplug_slaves(mddev_t *mddev r_queue->unplug_fn(r_queue); spin_lock_irqsave(&conf->device_lock, flags); - atomic_dec(&rdev->nr_pending); + rdev_dec_pending(rdev, mddev); } } spin_unlock_irqrestore(&conf->device_lock, flags); @@ -1086,7 +1086,7 @@ static int sync_request(mddev_t *mddev, int rv = max_sector - sector_nr; md_done_sync(mddev, rv, 1); put_buf(r1_bio); - atomic_dec(&conf->mirrors[disk].rdev->nr_pending); + rdev_dec_pending(conf->mirrors[disk].rdev, mddev); return rv; } diff -puN drivers/md/raid5.c~md-make-sure-md-always-uses-rdev_dec_pending-properly drivers/md/raid5.c --- 25/drivers/md/raid5.c~md-make-sure-md-always-uses-rdev_dec_pending-properly Thu Oct 21 15:07:47 2004 +++ 25-akpm/drivers/md/raid5.c Thu Oct 21 15:07:47 2004 @@ -1317,7 +1317,7 @@ static void unplug_slaves(mddev_t *mddev r_queue->unplug_fn(r_queue); spin_lock_irqsave(&conf->device_lock, flags); - atomic_dec(&rdev->nr_pending); + rdev_dec_pending(rdev, mddev); } } spin_unlock_irqrestore(&conf->device_lock, flags); diff -puN drivers/md/raid6main.c~md-make-sure-md-always-uses-rdev_dec_pending-properly drivers/md/raid6main.c --- 25/drivers/md/raid6main.c~md-make-sure-md-always-uses-rdev_dec_pending-properly Thu Oct 21 15:07:47 2004 +++ 25-akpm/drivers/md/raid6main.c Thu Oct 21 15:07:47 2004 @@ -1479,7 +1479,7 @@ static void unplug_slaves(mddev_t *mddev r_queue->unplug_fn(r_queue); spin_lock_irqsave(&conf->device_lock, flags); - atomic_dec(&rdev->nr_pending); + rdev_dec_pending(rdev, mddev); } } spin_unlock_irqrestore(&conf->device_lock, flags); _