]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
md/raid5: don't test ->writes_pending in raid5_remove_disk
authorNeilBrown <neilb@suse.com>
Wed, 15 Mar 2017 03:05:14 +0000 (14:05 +1100)
committerShaohua Li <shli@fb.com>
Thu, 23 Mar 2017 02:18:05 +0000 (19:18 -0700)
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, which at least
can be locked against.  More changes are still needed.

A future patch will change ->writes_pending, and testing it here will
be very inconvenient.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5.c

index 00a34faabcdfbf702d32c07f12c477923c6c5e4a..0b1a4339a4378370ce198ca69fac21af4f868eb7 100644 (file)
@@ -7532,9 +7532,12 @@ 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.
+                * neilb: there is no locking about new writes here,
+                * so this cannot be safe.
                 */
-               if (atomic_read(&mddev->writes_pending))
+               if (atomic_read(&conf->active_stripes)) {
                        return -EBUSY;
+               }
                log_exit(conf);
                return 0;
        }