Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbcDRN4L (ORCPT ); Mon, 18 Apr 2016 09:56:11 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]:36561 "EHLO mail-ig0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750717AbcDRN4K (ORCPT ); Mon, 18 Apr 2016 09:56:10 -0400 MIME-Version: 1.0 In-Reply-To: References: <20160416015021.GA3694@infradead.org> From: Jinpu Wang Date: Mon, 18 Apr 2016 15:55:49 +0200 Message-ID: Subject: Re: [PATCHv2]brd: set max_discard_sectors properly To: Christoph Hellwig Cc: Jens Axboe , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1264 Lines: 31 On Mon, Apr 18, 2016 at 10:34 AM, Jinpu Wang wrote: > On Sat, Apr 16, 2016 at 3:50 AM, Christoph Hellwig wrote: >>> - blk_queue_max_discard_sectors(brd->brd_queue, UINT_MAX); >>> + blk_queue_max_discard_sectors(brd->brd_queue, UINT_MAX >> 9); >> >> Shouldn't we fix the issue by capping to UINT_MAX >> 9 inside >> blk_queue_max_discard_sectors? That way we'll prevent against having >> issues like this in any other driver as well. > > > Thanks Christoph, make sense to me, will rework it to this way. > > Regards, > Jack It turns out, the real fix is here: commit 5e4298be45e83ecdffaabb370eea9396889b07f1 Author: Bart Van Assche Date: Tue Dec 15 16:38:22 2015 +0100 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: 2dbe54957636 ("brd: Refuse improperly aligned discard requests") Signed-off-by: Bart Van Assche Reviewed-by: Jan Kara Cc: Christoph Hellwig Cc: Robert Elliot Cc: stable # v4.4+ Signed-off-by: Jens Axboe