]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
md: Prevent IO hold during accessing to faulty raid5 array
authorAlexey Obitotskiy <aleksey.obitotskiy@intel.com>
Wed, 3 Aug 2016 08:02:56 +0000 (10:02 +0200)
committerShaohua Li <shli@fb.com>
Sat, 6 Aug 2016 05:03:10 +0000 (22:03 -0700)
After array enters in faulty state (e.g. number of failed drives
becomes more then accepted for raid5 level) it sets error flags
(one of this flags is MD_CHANGE_PENDING). For internal metadata
arrays MD_CHANGE_PENDING cleared into md_update_sb, but not for
external metadata arrays. MD_CHANGE_PENDING flag set prevents to
finish all new or non-finished IOs to array and hold them in
pending state. In some cases this can leads to deadlock situation.

For example, we have faulty array (2 of 4 drives failed) and
udev handle array state changes and blkid started (or other
userspace application that used array to read/write) but unable
to finish reads due to IO hold. At the same time we unable to get
exclusive access to array (to stop array in our case) because
another external application still use this array.

Fix makes possible to return IO with errors immediately.
So external application can finish working with array and
give exclusive access to other applications to perform
required management actions with array.

Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5.c

index e379b89fd8b18a904cc9fa2e08d6649683e6aeee..4f8f5242ea3b1805c15dc9b10edbbcab80cebd42 100644 (file)
@@ -4640,7 +4640,9 @@ static void handle_stripe(struct stripe_head *sh)
        }
 
        if (!bio_list_empty(&s.return_bi)) {
-               if (test_bit(MD_CHANGE_PENDING, &conf->mddev->flags)) {
+               if (test_bit(MD_CHANGE_PENDING, &conf->mddev->flags) &&
+                               (s.failed <= conf->max_degraded ||
+                                       conf->mddev->external == 0)) {
                        spin_lock_irq(&conf->device_lock);
                        bio_list_merge(&conf->return_bi, &s.return_bi);
                        spin_unlock_irq(&conf->device_lock);