mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
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>
This commit is contained in:
parent
5baebe5c86
commit
8af1954d17
1 changed files with 2 additions and 7 deletions
|
@ -19,11 +19,8 @@ static void bio_batch_end_io(struct bio *bio, int err)
|
|||
{
|
||||
struct bio_batch *bb = bio->bi_private;
|
||||
|
||||
if (err) {
|
||||
if (err == -EOPNOTSUPP)
|
||||
set_bit(BIO_EOPNOTSUPP, &bb->flags);
|
||||
if (err && (err != -EOPNOTSUPP))
|
||||
clear_bit(BIO_UPTODATE, &bb->flags);
|
||||
}
|
||||
if (atomic_dec_and_test(&bb->done))
|
||||
complete(bb->wait);
|
||||
bio_put(bio);
|
||||
|
@ -107,9 +104,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
|
|||
if (!atomic_dec_and_test(&bb.done))
|
||||
wait_for_completion(&wait);
|
||||
|
||||
if (test_bit(BIO_EOPNOTSUPP, &bb.flags))
|
||||
ret = -EOPNOTSUPP;
|
||||
else if (!test_bit(BIO_UPTODATE, &bb.flags))
|
||||
if (!test_bit(BIO_UPTODATE, &bb.flags))
|
||||
ret = -EIO;
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue