From patchwork Tue Dec 15 15:38:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 7855401 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0F6FFBEEE1 for ; Tue, 15 Dec 2015 15:39:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E23F0202C8 for ; Tue, 15 Dec 2015 15:39:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AEF32203C2 for ; Tue, 15 Dec 2015 15:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965189AbbLOPjA (ORCPT ); Tue, 15 Dec 2015 10:39:00 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:38185 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933590AbbLOPi6 (ORCPT ); Tue, 15 Dec 2015 10:38:58 -0500 Received: by mail-wm0-f48.google.com with SMTP id p66so31501970wmp.1 for ; Tue, 15 Dec 2015 07:38:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-type:content-transfer-encoding; bh=qLaD1IWvTldzbxasNU1E862fqafZYyrLbg6OLBijNW0=; b=rccdsmpUiRafUs5ybjcA1lbj7I+oCLCfBBpAhRc5xE5f0U6QGZ3gBBpFlg2ws99Osi OpMJYvN3ILQCxiff7cS/vH/dnvA2UImr9rj0SlAjoy2KpKpwWaNKMBbGliyf3IP68NjL aAIlvg6B/a+s4vM32wzejigSi713sjyjcZGyA4CfJZVGmt5mmarSonZjUhSF3rdfSENh MC8ZA0ogY0HQDkhzbb0N+XLQ8IjLoMCaV/7fd9c/TphxIPA8a9nqvLkm3JKIsTfM0QrG i/uUl0TbzmGVYlwKbGZrmU+SOZMDV81NWOnnNb03RKyG7EPBntAm4E7DQMVnwfLx2wa+ fEJA== X-Received: by 10.28.229.15 with SMTP id c15mr5713813wmh.76.1450193935771; Tue, 15 Dec 2015 07:38:55 -0800 (PST) Received: from tom-T450 (56.34.213.162.lcy-01.canonistack.canonical.com. [162.213.34.56]) by smtp.gmail.com with ESMTPSA id i84sm3328507wmc.20.2015.12.15.07.38.54 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 15 Dec 2015 07:38:55 -0800 (PST) Date: Tue, 15 Dec 2015 23:38:41 +0800 From: Ming Lei To: Eryu Guan Cc: Linux SCSI List , "Martin K. Petersen" Subject: Re: kernel BUG at block/bio.c:1787! while initializing scsi_debug on ppc64 host Message-ID: <20151215233841.522d4bf0@tom-T450> In-Reply-To: <20151215130631.GD19209@eguan.usersys.redhat.com> References: <20151211115340.GB19209@eguan.usersys.redhat.com> <20151215112057.GC19209@eguan.usersys.redhat.com> <20151215130631.GD19209@eguan.usersys.redhat.com> Organization: Ming X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 15 Dec 2015 21:06:31 +0800 Eryu Guan wrote: > On Tue, Dec 15, 2015 at 08:06:47PM +0800, Ming Lei wrote: > > On Tue, Dec 15, 2015 at 7:20 PM, Eryu Guan wrote: > > > On Fri, Dec 11, 2015 at 07:53:40PM +0800, Eryu Guan wrote: > > >> Hi, > > >> > > >> I saw this kernel BUG_ON on 4.4-rc4 kernel, and this can be reproduced > > >> easily on ppc64 host by: > > > > > > This is still reproducible with 4.4-rc5 kernel. > > > > Could you capture the debug log after appyling the attached patch and > > the reproduction? > > Thanks for looking into this! dmesg shows: > > [ 686.217682] bio_split: sectors 0, bio_sectors 128, bi_rw 0 I guess the following patch should fix the issue, and ca369d51b3 uses OPTIMAL TRANSFER LENGTH to set limits->max_sectors, which may be less than one page size. I don't understand the idea behind this change, Martin, could you explain it a bit? diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3d22fc3..d66d362 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2889,10 +2889,11 @@ static int sd_revalidate_disk(struct gendisk *disk) */ if (sdkp->opt_xfer_blocks && sdkp->opt_xfer_blocks <= dev_max && sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS) - rw_max = q->limits.io_opt = + q->limits.io_opt = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); - else - rw_max = BLK_DEF_MAX_SECTORS; + + rw_max = min_t(unsigned, BLK_DEF_MAX_SECTORS, + q->limits.max_dev_sectors); /* Combine with controller limits */ q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));