Skip to content

Commit 5e4298b

Browse files
Bart Van Asscheaxboe
authored andcommitted
brd: Fix discard request processing
Avoid that discard requests with size => PAGE_SIZE fail with -EIO. Refuse discard requests if the discard size is not a multiple of the page size. Fixes: 2dbe549 ("brd: Refuse improperly aligned discard requests") Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Jan Kara <jack@suse.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Robert Elliot <elliott@hp.com> Cc: stable <stable@vger.kernel.org> # v4.4+ Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent d436641 commit 5e4298b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/block/brd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio)
341341

342342
if (unlikely(bio->bi_rw & REQ_DISCARD)) {
343343
if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) ||
344-
bio->bi_iter.bi_size & PAGE_MASK)
344+
bio->bi_iter.bi_size & ~PAGE_MASK)
345345
goto io_error;
346346
discard_from_brd(brd, sector, bio->bi_iter.bi_size);
347347
goto out;

0 commit comments

Comments
 (0)