blkdev: Do not return -EOPNOTSUPP if discard is supported
authorLukas Czerner <lczerner@redhat.com>
Sat, 7 May 2011 01:30:01 +0000 (19:30 -0600)
committerJens Axboe <jaxboe@fusionio.com>
Sat, 7 May 2011 01:30:01 +0000 (19:30 -0600)
commit8af1954d172a46a63e5e79dae523a6d74715e458
tree6142f111bb600c4bbf194209155e857fd5f83ca8
parent5baebe5c86acd6100536a466905880529f79cf1a
blkdev: Do not return -EOPNOTSUPP if discard is supported

Currently we return -EOPNOTSUPP in blkdev_issue_discard() if any of the
bio fails due to underlying device not supporting discard request.
However, if the device is for example dm device composed of devices
which some of them support discard and some of them does not, it is ok
for some bios to fail with EOPNOTSUPP, but it does not mean that discard
is not supported at all.

This commit removes the check for bios failed with EOPNOTSUPP and change
blkdev_issue_discard() to return operation not supported if and only if
the device does not actually supports it, not just part of the device as
some bios might indicate.

This change also fixes problem with BLKDISCARD ioctl() which now works
correctly on such dm devices.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
CC: Jens Axboe <jaxboe@fusionio.com>
CC: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
block/blk-lib.c