block: fix infinite loop if the device loses discard capability
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 3 Jul 2018 17:34:22 +0000 (13:34 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Dec 2018 12:39:07 +0000 (13:39 +0100)
commit07eae146f5b76da9d5bb41bc8825fe486bf0f05a
tree5ded6573294808b930594b5ffdb52df6c4238154
parent1e9290ca9d6fa96b69c4d6125f87dc77793179e1
block: fix infinite loop if the device loses discard capability

[ Upstream commit b88aef36b87c9787a4db724923ec4f57dfd513f3 ]

If __blkdev_issue_discard is in progress and a device mapper device is
reloaded with a table that doesn't support discard,
q->limits.max_discard_sectors is set to zero. This results in infinite
loop in __blkdev_issue_discard.

This patch checks if max_discard_sectors is zero and aborts with
-EOPNOTSUPP.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Tested-by: Zdenek Kabelac <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-lib.c