aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2011-05-06 21:30:01 -0400
committerJens Axboe <jaxboe@fusionio.com>2011-05-06 21:30:01 -0400
commit8af1954d172a46a63e5e79dae523a6d74715e458 (patch)
tree6142f111bb600c4bbf194209155e857fd5f83ca8 /block
parent5baebe5c86acd6100536a466905880529f79cf1a (diff)
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>
Diffstat (limited to 'block')
-rw-r--r--block/blk-lib.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/block/blk-lib.c b/block/blk-lib.c
index d7a98d3ed4aa..78e627e2581d 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -19,11 +19,8 @@ static void bio_batch_end_io(struct bio *bio, int err)
19{ 19{
20 struct bio_batch *bb = bio->bi_private; 20 struct bio_batch *bb = bio->bi_private;
21 21
22 if (err) { 22 if (err && (err != -EOPNOTSUPP))
23 if (err == -EOPNOTSUPP)
24 set_bit(BIO_EOPNOTSUPP, &bb->flags);
25 clear_bit(BIO_UPTODATE, &bb->flags); 23 clear_bit(BIO_UPTODATE, &bb->flags);
26 }
27 if (atomic_dec_and_test(&bb->done)) 24 if (atomic_dec_and_test(&bb->done))
28 complete(bb->wait); 25 complete(bb->wait);
29 bio_put(bio); 26 bio_put(bio);
@@ -107,9 +104,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
107 if (!atomic_dec_and_test(&bb.done)) 104 if (!atomic_dec_and_test(&bb.done))
108 wait_for_completion(&wait); 105 wait_for_completion(&wait);
109 106
110 if (test_bit(BIO_EOPNOTSUPP, &bb.flags)) 107 if (!test_bit(BIO_UPTODATE, &bb.flags))
111 ret = -EOPNOTSUPP;
112 else if (!test_bit(BIO_UPTODATE, &bb.flags))
113 ret = -EIO; 108 ret = -EIO;
114 109
115 return ret; 110 return ret;