This test on ->writes_pending cannot be safe as the counter can be incremented at any moment and cannot be locked against. Change it to test conf->active_stripes. This allows read requests to interfere so it might make removal of the journal device harder, but it is safer. Signed-off-by: NeilBrown <neilb@xxxxxxxx> --- drivers/md/raid5.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index c96fca2c6a98..4de03479cdce 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -7279,10 +7279,14 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev) * we can't wait pending write here, as this is called in * raid5d, wait will deadlock. */ - if (atomic_read(&mddev->writes_pending)) + lock_all_device_hash_locks_irq(conf); + if (atomic_read(&conf->active_stripes)) { + unlock_all_device_hash_locks_irq(conf); return -EBUSY; + } log = conf->log; conf->log = NULL; + unlock_all_device_hash_locks_irq(conf); synchronize_rcu(); r5l_exit_log(log); return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html