dm: discard support requires all targets in a table support discards
authorMike Snitzer <snitzer@redhat.com>
Tue, 14 Nov 2017 20:40:52 +0000 (15:40 -0500)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Feb 2018 18:32:17 +0000 (18:32 +0000)
commitd42ad94c9cd1a902a1b00022af4bd580e1895ff7
treee24b947784f4f928c35619fac12e31c2f4f18940
parent753cbba3bd5ce44baf645ab4289d99e22ef13d44
dm: discard support requires all targets in a table support discards

commit 8a74d29d541cd86569139c6f3f44b2d210458071 upstream.

A DM device with a mix of discard capabilities (due to some underlying
devices not having discard support) _should_ just return -EOPNOTSUPP for
the region of the device that doesn't support discards (even if only by
way of the underlying driver formally not supporting discards).  BUT,
that does ask the underlying driver to handle something that it never
advertised support for.  In doing so we're exposing users to the
potential for a underlying disk driver hanging if/when a discard is
issued a the device that is incapable and never claimed to support
discards.

Fix this by requiring that each DM target in a DM table provide discard
support as a prereq for a DM device to advertise support for discards.

This may cause some configurations that were happily supporting discards
(even in the face of a mix of discard support) to stop supporting
discards -- but the risk of users hitting driver hangs, and forced
reboots, outweighs supporting those fringe mixed discard
configurations.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/md/dm-table.c