Skip to content
  • Mike Snitzer's avatar
    block: reinstate early return of -EOPNOTSUPP from blkdev_issue_discard · bbd848e0
    Mike Snitzer authored
    Commit 38f25255 ("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: 38f25255
    
     ("block: add __blkdev_issue_discard")
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    Signed-off-by: default avatarJens Axboe <axboe@fb.com>
    bbd848e0