]> git.baikalelectronics.ru Git - kernel.git/commit
md/raid5: Ensure batch_last is released before sleeping for quiesce
authorLogan Gunthorpe <logang@deltatee.com>
Wed, 27 Jul 2022 21:06:00 +0000 (15:06 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 3 Aug 2022 03:08:53 +0000 (21:08 -0600)
commit2d97ecbf3ab44b6aa4f513c3929b1652c9b24f19
tree30c3b19a52812a921535503af1fce64226ed16ff
parent7dd7b28bdc8c0477adeaaaf401b4aad830231321
md/raid5: Ensure batch_last is released before sleeping for quiesce

A race condition exists where if raid5_quiesce() is called in the
middle of a request that has set batch_last, it will deadlock.

batch_last will hold a reference to a stripe when raid5_quiesce() is
called. This will cause the next raid5_get_active_stripe() call to
sleep waiting for the quiesce to finish, but the raid5_quiesce() thread
will wait for active_stripes to go to zero which will never happen
because request thread is waiting for the quiesce to stop.

Fix this by creating a special __raid5_get_active_stripe() function
which takes the request context and clears the last_batch before
sleeping.

While we're at it, change the arguments of raid5_get_active_stripe()
to bools.

Fixes: ddcfd4285c69 ("md/raid5: Keep a reference to last stripe_head for batch")
Reported-by: David Sloan <David.Sloan@eideticom.com>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/raid5.c
drivers/md/raid5.h