Commit 4ae3f847 authored by Dan Williams's avatar Dan Williams Committed by Linus Torvalds

md: raid5: fix clearing of biofill operations

ops_complete_biofill() runs outside of spin_lock(&sh->lock) and clears the
'pending' and 'ack' bits.  Since the test_and_ack_op() macro only checks
against 'complete' it can get an inconsistent snapshot of pending work.

Move the clearing of these bits to handle_stripe5(), under the lock.
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Tested-by: default avatarJoel Bertrand <joel.bertrand@systella.fr>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Cc: Stable <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 85bfb4da
...@@ -376,7 +376,12 @@ static unsigned long get_stripe_work(struct stripe_head *sh) ...@@ -376,7 +376,12 @@ static unsigned long get_stripe_work(struct stripe_head *sh)
ack++; ack++;
sh->ops.count -= ack; sh->ops.count -= ack;
BUG_ON(sh->ops.count < 0); if (unlikely(sh->ops.count < 0)) {
printk(KERN_ERR "pending: %#lx ops.pending: %#lx ops.ack: %#lx "
"ops.complete: %#lx\n", pending, sh->ops.pending,
sh->ops.ack, sh->ops.complete);
BUG();
}
return pending; return pending;
} }
...@@ -550,8 +555,7 @@ static void ops_complete_biofill(void *stripe_head_ref) ...@@ -550,8 +555,7 @@ static void ops_complete_biofill(void *stripe_head_ref)
} }
} }
} }
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.ack); set_bit(STRIPE_OP_BIOFILL, &sh->ops.complete);
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.pending);
return_io(return_bi); return_io(return_bi);
...@@ -2893,6 +2897,13 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page) ...@@ -2893,6 +2897,13 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
s.expanded = test_bit(STRIPE_EXPAND_READY, &sh->state); s.expanded = test_bit(STRIPE_EXPAND_READY, &sh->state);
/* Now to look around and see what can be done */ /* Now to look around and see what can be done */
/* clean-up completed biofill operations */
if (test_bit(STRIPE_OP_BIOFILL, &sh->ops.complete)) {
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.pending);
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.ack);
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.complete);
}
rcu_read_lock(); rcu_read_lock();
for (i=disks; i--; ) { for (i=disks; i--; ) {
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment