Skip to content

Commit 4ae3f84

Browse files
djbwLinus Torvalds
authored andcommitted
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: Dan Williams <dan.j.williams@intel.com> Tested-by: Joel Bertrand <joel.bertrand@systella.fr> Signed-off-by: Neil Brown <neilb@suse.de> Cc: Stable <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 85bfb4d commit 4ae3f84

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎drivers/md/raid5.c‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,12 @@ static unsigned long get_stripe_work(struct stripe_head *sh)
376376
ack++;
377377

378378
sh->ops.count -= ack;
379-
BUG_ON(sh->ops.count < 0);
379+
if (unlikely(sh->ops.count < 0)) {
380+
printk(KERN_ERR "pending: %#lx ops.pending: %#lx ops.ack: %#lx "
381+
"ops.complete: %#lx\n", pending, sh->ops.pending,
382+
sh->ops.ack, sh->ops.complete);
383+
BUG();
384+
}
380385

381386
return pending;
382387
}
@@ -550,8 +555,7 @@ static void ops_complete_biofill(void *stripe_head_ref)
550555
}
551556
}
552557
}
553-
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.ack);
554-
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.pending);
558+
set_bit(STRIPE_OP_BIOFILL, &sh->ops.complete);
555559

556560
return_io(return_bi);
557561

@@ -2893,6 +2897,13 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
28932897
s.expanded = test_bit(STRIPE_EXPAND_READY, &sh->state);
28942898
/* Now to look around and see what can be done */
28952899

2900+
/* clean-up completed biofill operations */
2901+
if (test_bit(STRIPE_OP_BIOFILL, &sh->ops.complete)) {
2902+
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.pending);
2903+
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.ack);
2904+
clear_bit(STRIPE_OP_BIOFILL, &sh->ops.complete);
2905+
}
2906+
28962907
rcu_read_lock();
28972908
for (i=disks; i--; ) {
28982909
mdk_rdev_t *rdev;

0 commit comments

Comments
 (0)