From patchwork Wed Jan 6 09:46:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 7965551 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 799AF9F1CC for ; Wed, 6 Jan 2016 09:47:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6E3A2013D for ; Wed, 6 Jan 2016 09:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E06220125 for ; Wed, 6 Jan 2016 09:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752394AbcAFJrK (ORCPT ); Wed, 6 Jan 2016 04:47:10 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:33078 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752729AbcAFJrD (ORCPT ); Wed, 6 Jan 2016 04:47:03 -0500 Received: by mail-pf0-f172.google.com with SMTP id q63so200346544pfb.0 for ; Wed, 06 Jan 2016 01:47:03 -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=5xLYYwIo/NE+oXkjJcJVbwKn6hV0piBde0Vx5TEuOKY=; b=jbxrlifNY36OfTD9C7JIRn9wBSJjsbXSgnLjZH7+ONoX9kTJ/C8z+T/AXyC/+E9rwN cLduPWj2epDyXaTARDurBkG3VVCcqdQWjopfeS3eoMYfIX5UrHc38SUXLX8i7Y3qxpo+ n8Tryl9JcWVDIQnvvJC6nej/3SGpjnih8epTZMM+HbdyynqJ+KNBU3sB4fElPHx/s5iQ OrOa57fZMY3wRfVCztRcsIEwTOd5Q8RcJrLC/ojGaDuwx2lxFjPyhPq+dJOKc/zlLtgB EwWyZi7WOmjWgWUF2ov6HG6h/N+uq3knlYdj9lt5SgSJr4AmgtHykkNBeIebDVtINSo9 kb1w== X-Received: by 10.98.73.21 with SMTP id w21mr123302949pfa.136.1452073623156; Wed, 06 Jan 2016 01:47:03 -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 ud10sm139292250pab.27.2016.01.06.01.46.56 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 06 Jan 2016 01:47:02 -0800 (PST) Date: Wed, 6 Jan 2016 17:46:39 +0800 From: Ming Lei To: Keith Busch Cc: linux-nvme , linux-block@vger.kernel.org, Jens Axboe , Greg White , tom.leiming@gmail.com Subject: Re: [PATCH for-4.4] block: split bios to max possible length Message-ID: <20160106174639.65e0ced4@tom-T450> In-Reply-To: <20160106055133.GA4868@localhost.localdomain> References: <1451931895-17474-1-git-send-email-keith.busch@intel.com> <20160105150938.GA20832@localhost.localdomain> <20160106055133.GA4868@localhost.localdomain> Organization: Ming X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@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, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Wed, 6 Jan 2016 05:51:34 +0000 Keith Busch wrote: > On Wed, Jan 06, 2016 at 10:17:51AM +0800, Ming Lei wrote: > > But this patch was to split on stripe boundaries, which is an even worse > penalty if we get the split wrong. > > > + bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags); > > > > bio_for_each_segment(bv, bio, iter) { > > - if (sectors + (bv.bv_len >> 9) > blk_max_size_offset(q, bio->bi_iter.bi_sector)) > > + if (no_sg_merge) > > + goto new_segment; > > Bad idea for NVMe. We need to split on SG gaps, which you've skipped, > or you will BUG_ON in the NVMe driver. Given it is close to v4.4 release, I propose the following fix instead of the bvec splitting approach, which is not ready in current block stack. ----- block/blk-merge.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index e73846a..9ffe431 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -81,8 +81,16 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, struct bio *new = NULL; bio_for_each_segment(bv, bio, iter) { - if (sectors + (bv.bv_len >> 9) > blk_max_size_offset(q, bio->bi_iter.bi_sector)) + if (sectors + (bv.bv_len >> 9) > blk_max_size_offset(q, + bio->bi_iter.bi_sector)) { + /* + * avoid to split out zero length bio if size to + * chunk boundary is too small + */ + if (!sectors) + goto new_segment; goto split; + } /* * If the queue doesn't support SG gaps and adding this