diff options
author | Mike Snitzer <snitzer@redhat.com> | 2016-05-05 11:54:21 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-05-05 15:03:26 -0400 |
commit | bbd848e0fade51ae51dab86a0683069cef89953f (patch) | |
tree | 1f3a5d8107fe664a19ebddf4f656b0f50fe267b5 /block/blk-lib.c | |
parent | a21f2a3ec62abe2e06500d6550659a0ff5624fbb (diff) |
block: reinstate early return of -EOPNOTSUPP from blkdev_issue_discard
Commit 38f25255330 ("block: add __blkdev_issue_discard") incorrectly
disallowed the early return of -EOPNOTSUPP if the device doesn't support
discard (or secure discard). This early return of -EOPNOTSUPP has
always been part of blkdev_issue_discard() interface so there isn't a
good reason to break that behaviour -- especially when it can be easily
reinstated.
The nuance of allowing early return of -EOPNOTSUPP vs disallowing late
return of -EOPNOTSUPP is: if the overall device never advertised support
for discards and one is issued to the device it is beneficial to inform
the caller that discards are not supported via -EOPNOTSUPP. But if a
device advertises discard support it means that at least a subset of the
device does have discard support -- but it could be that discards issued
to some regions of a stacked device will not be supported. In that case
the late return of -EOPNOTSUPP must be disallowed.
Fixes: 38f25255330 ("block: add __blkdev_issue_discard")
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-lib.c')
-rw-r--r-- | block/blk-lib.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/block/blk-lib.c b/block/blk-lib.c index ccbce2b2ea05..23d7f301a196 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c | |||
@@ -109,11 +109,14 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, | |||
109 | blk_start_plug(&plug); | 109 | blk_start_plug(&plug); |
110 | ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, type, | 110 | ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, type, |
111 | &bio); | 111 | &bio); |
112 | if (!ret && bio) | 112 | if (!ret && bio) { |
113 | ret = submit_bio_wait(type, bio); | 113 | ret = submit_bio_wait(type, bio); |
114 | if (ret == -EOPNOTSUPP) | ||
115 | ret = 0; | ||
116 | } | ||
114 | blk_finish_plug(&plug); | 117 | blk_finish_plug(&plug); |
115 | 118 | ||
116 | return ret != -EOPNOTSUPP ? ret : 0; | 119 | return ret; |
117 | } | 120 | } |
118 | EXPORT_SYMBOL(blkdev_issue_discard); | 121 | EXPORT_SYMBOL(blkdev_issue_discard); |
119 | 122 | ||