diff mbox

brd: Fix discard request processing

Message ID 567033EE.7010708@sandisk.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bart Van Assche Dec. 15, 2015, 3:38 p.m. UTC
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: 2dbe54957636 ("brd: Refuse improperly aligned discard requests")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: 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+
---
 drivers/block/brd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Kara Dec. 15, 2015, 6:11 p.m. UTC | #1
On Tue 15-12-15 16:38:22, Bart Van Assche wrote:
> 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.

Argh, good catch. Thanks for fixing this. You can add:

Reviewed-by: Jan Kara <jack@suse.com>

								Honza

> 
> Fixes: 2dbe54957636 ("brd: Refuse improperly aligned discard requests")
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: 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+
> ---
>  drivers/block/brd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/brd.c b/drivers/block/brd.c
> index a5880f4..1914c63 100644
> --- a/drivers/block/brd.c
> +++ b/drivers/block/brd.c
> @@ -338,7 +338,7 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio)
>  
>  	if (unlikely(bio->bi_rw & REQ_DISCARD)) {
>  		if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) ||
> -		    bio->bi_iter.bi_size & PAGE_MASK)
> +		    bio->bi_iter.bi_size & ~PAGE_MASK)
>  			goto io_error;
>  		discard_from_brd(brd, sector, bio->bi_iter.bi_size);
>  		goto out;
> -- 
> 2.1.4
>
Bart Van Assche March 15, 2016, 8:52 p.m. UTC | #2
On 12/15/2015 10:11 AM, Jan Kara wrote:
> On Tue 15-12-15 16:38:22, Bart Van Assche wrote:
>> 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.
>
> Argh, good catch. Thanks for fixing this. You can add:
>
> Reviewed-by: Jan Kara <jack@suse.com>

Hello Jens,

Apparently this patch is not yet in your for-next branch. Is this 
perhaps an oversight?

Thanks,

Bart.

--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jens Axboe March 15, 2016, 8:58 p.m. UTC | #3
On 03/15/2016 01:52 PM, Bart Van Assche wrote:
> On 12/15/2015 10:11 AM, Jan Kara wrote:
>> On Tue 15-12-15 16:38:22, Bart Van Assche wrote:
>>> 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.
>>
>> Argh, good catch. Thanks for fixing this. You can add:
>>
>> Reviewed-by: Jan Kara <jack@suse.com>
>
> Hello Jens,
>
> Apparently this patch is not yet in your for-next branch. Is this
> perhaps an oversight?

Yeah, that should go in, I will apply it. Thanks for the ping!
diff mbox

Patch

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