]> www.infradead.org Git - users/hch/block.git/commit
block: move discard checks into the ioctl handler
authorChristoph Hellwig <hch@lst.de>
Fri, 3 May 2024 15:46:41 +0000 (17:46 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 3 May 2024 16:48:30 +0000 (18:48 +0200)
commit789684571c3c14856aeb6968fa92178916b6ec5c
tree318ec132bf06f26af55a4bcca00b1f723b91f241
parentedb18c6eae385a97e37b7eb227071085e5e873ad
block: move discard checks into the ioctl handler

Most bio operations get basic sanity checking in submit_bio and anything
more complicated than that is done in the callers.  Discards are a bit
different from that in that a lot of checking is done in
__blkdev_issue_discard, and the specific errnos for that are returned
to userspace.  Move the checks that require specific errnos to the ioctl
handler instead, and just leave the basic sanity checking in submit_bio
for the other handlers.  This introduces two changes in behavior:

 1) the logical block size alignment check of the start and len is lost
    for non-ioctl callers.
    This matches what is done for other operations including reads and
    writes.  We should probably verify this for all bios, but for now
    make discards match the normal flow.
 2) for non-ioctl callers all errors are reported on I/O completion now
    instead of synchronously.  Callers in general mostly ignore or log
    errors so this will actually simplify the code once cleaned up

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/blk-lib.c
block/ioctl.c