diff mbox

[6/6] brd: Accept non-aligned discard requests with size zero

Message ID 56729FD0.3070309@sandisk.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bart Van Assche Dec. 17, 2015, 11:43 a.m. UTC
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Dmitry Monakhov <dmonakhov@openvz.org>
---
 drivers/block/brd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 7e0a54e..a757c7b 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -339,8 +339,9 @@  static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio)
 	blk_queue_split(q, &bio, q->bio_split);
 
 	if (unlikely(bio->bi_rw & REQ_DISCARD)) {
-		if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) ||
-		    bio->bi_iter.bi_size & ~PAGE_MASK)
+		if (bio->bi_iter.bi_size &&
+		    (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) ||
+		     bio->bi_iter.bi_size & ~PAGE_MASK))
 			goto io_error;
 		discard_from_brd(brd, sector, bio->bi_iter.bi_size);
 		goto out;