md/raid5: preserve STRIPE_ON_UNPLUG_LIST in break_stripe_batch_list
authorDennis Yang <dennisyang@qnap.com>
Wed, 6 Sep 2017 03:02:35 +0000 (11:02 +0800)
committerRaspbian kernel package updater <root@raspbian.org>
Sun, 8 Oct 2017 01:09:32 +0000 (01:09 +0000)
commitfe0e6855cda258d26346a78f6b17e8e34326d467
treefc92d88698ed5a58ac4c27ddbd6846c4b54383b3
parentb060bc6ecb8bc7068b55c2e562ea5b1cd4b9ca1e
md/raid5: preserve STRIPE_ON_UNPLUG_LIST in break_stripe_batch_list

commit 184a09eb9a2fe425e49c9538f1604b05ed33cfef upstream.

In release_stripe_plug(), if a stripe_head has its STRIPE_ON_UNPLUG_LIST
set, it indicates that this stripe_head is already in the raid5_plug_cb
list and release_stripe() would be called instead to drop a reference
count. Otherwise, the STRIPE_ON_UNPLUG_LIST bit would be set for this
stripe_head and it will get queued into the raid5_plug_cb list.

Since break_stripe_batch_list() did not preserve STRIPE_ON_UNPLUG_LIST,
A stripe could be re-added to plug list while it is still on that list
in the following situation. If stripe_head A is added to another
stripe_head B's batch list, in this case A will have its
batch_head != NULL and be added into the plug list. After that,
stripe_head B gets handled and called break_stripe_batch_list() to
reset all the batched stripe_head(including A which is still on
the plug list)'s state and reset their batch_head to NULL.
Before the plug list gets processed, if there is another write request
comes in and get stripe_head A, A will have its batch_head == NULL
(cleared by calling break_stripe_batch_list() on B) and be added to
plug list once again.

Signed-off-by: Dennis Yang <dennisyang@qnap.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/raid5.c