Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752513AbdC0QHe (ORCPT ); Mon, 27 Mar 2017 12:07:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58994 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbdC0QH0 (ORCPT ); Mon, 27 Mar 2017 12:07:26 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A8A027F6D0 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=loberman@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A8A027F6D0 Date: Mon, 27 Mar 2017 12:06:51 -0400 (EDT) From: Laurence Oberman To: Fam Zheng Cc: linux-kernel@vger.kernel.org, "Martin K. Petersen" , linux-scsi@vger.kernel.org, "James E.J. Bottomley" Message-ID: <1570359368.7021305.1490630811310.JavaMail.zimbra@redhat.com> In-Reply-To: <20170327141831.20936-1-famz@redhat.com> References: <20170327141831.20936-1-famz@redhat.com> Subject: Re: [PATCH] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.10.121.38] Thread-Topic: Consider max_xfer_blocks if opt_xfer_blocks is unusable Thread-Index: gPb0klMPwBTeGp0AzAY+G5Q3hyuwsg== X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 27 Mar 2017 16:06:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1407 Lines: 40 ----- Original Message ----- > From: "Fam Zheng" > To: linux-kernel@vger.kernel.org > Cc: "Martin K. Petersen" , famz@redhat.com, linux-scsi@vger.kernel.org, "James E.J. > Bottomley" > Sent: Monday, March 27, 2017 10:18:31 AM > Subject: [PATCH] sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable > > If device reports a small max_xfer_blocks and a zero opt_xfer_blocks, we > end up using BLK_DEF_MAX_SECTORS, which is wrong and r/w of that size > may get error. > > Fixes: ca369d51b3e ("block/sd: Fix device-imposed transfer length limits") > Signed-off-by: Fam Zheng > --- > drivers/scsi/sd.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c > index fcfeddc..e2e21ab 100644 > --- a/drivers/scsi/sd.c > +++ b/drivers/scsi/sd.c > @@ -2957,6 +2957,7 @@ static int sd_revalidate_disk(struct gendisk *disk) > rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); > } else > rw_max = BLK_DEF_MAX_SECTORS; > + rw_max = min_not_zero(rw_max, dev_max); > > /* Combine with controller limits */ > q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); > -- > 2.9.3 > > Looks good to me and addresses the issue we faced. FInal confirmation this change is OK to come from Martin or James. Reviewed-by: Laurence Oberman