Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2180742imu; Wed, 21 Nov 2018 07:50:21 -0800 (PST) X-Google-Smtp-Source: AJdET5cg66U79D4K6UYerzH3DLHPZ29rsJxYn9ib7xkJEIolQ08no6lWEIKUOxFOP/WwEUBMcfAd X-Received: by 2002:a62:2095:: with SMTP id m21-v6mr7387098pfj.32.1542815421247; Wed, 21 Nov 2018 07:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542815421; cv=none; d=google.com; s=arc-20160816; b=ctyl3dWV6CiN2d+jI/pKMv9qmvpZxzRkYlhRkRuTf1ZsH5rQkPG1/lnAm2JxopAhiy qe4EF3DYW7enhLohFp0Rc0D75MMiGSofpfePD9mBuSLMSzDmXA2CwGDBU/mHKhNW9QEX gcmDPV2EibXmJxqq+5tk3r7GUK0u07HVtSmYj0c0m0ZMFuBV6FW73TT1VS23ID1Vvgm+ lePqhxEodcP9nwlw4zakE1WrGOYIDXreUkR0cZpMCJeIaiXLmIkLdZbiRxhiL4Jex2aI YlQFyd29AffBRVFdVI1pgUx2y3AEGuCR6psRrGQViA9KwAfDT4wEXkpMABVFZJMa5ecO 48ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ixvZrnB1DqdyOxiS0FmI+IZ47rzOjscWCFkL2vbXwtY=; b=Lt58TfvwhiYScyXMvrhZmT39WrqPCyu3GbOzAthQWNtHO4ksw5rw2rfSaDtgjazdaM NY/fOL8QlP3v9kkkh/YfEzRljRUloZr/BA1eOr2Ex3dFkD9z/PCzHH7UeCrlGLw6FL0W GwD9rjtj1/7Gw3CzAcalnGREj0N4naHb48Kym59wMB4KoixdGcNGsJAREzHt3pmMfzP4 uP3xUVAtrb3jX5SDRx8KhPvmnaLhVYPDkKe5RBkiVjHi6rYu3Cs7Fu/i8iuO9kXQS6mD k3ipzA5aAJj4DiuFT6K0/oV5JVKuTpPYHuhXj1oox7b3aprZ+iDn8dwa4CuIe5Lk4+za F4Tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si50830549pll.361.2018.11.21.07.49.55; Wed, 21 Nov 2018 07:50:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731524AbeKVCYJ (ORCPT + 99 others); Wed, 21 Nov 2018 21:24:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34656 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728289AbeKVCYI (ORCPT ); Wed, 21 Nov 2018 21:24:08 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFDBCC0BF2A2; Wed, 21 Nov 2018 15:49:09 +0000 (UTC) Received: from ming.t460p (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67EC360BF6; Wed, 21 Nov 2018 15:48:18 +0000 (UTC) Date: Wed, 21 Nov 2018 23:48:13 +0800 From: Ming Lei To: Christoph Hellwig Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: Re: [PATCH V11 15/19] block: enable multipage bvecs Message-ID: <20181121154812.GD19111@ming.t460p> References: <20181121032327.8434-1-ming.lei@redhat.com> <20181121032327.8434-16-ming.lei@redhat.com> <20181121145502.GA3241@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181121145502.GA3241@lst.de> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 21 Nov 2018 15:49:10 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 21, 2018 at 03:55:02PM +0100, Christoph Hellwig wrote: > On Wed, Nov 21, 2018 at 11:23:23AM +0800, Ming Lei wrote: > > if (bio->bi_vcnt > 0) { > > - struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; > > + struct bio_vec bv; > > + struct bio_vec *seg = &bio->bi_io_vec[bio->bi_vcnt - 1]; > > > > - if (page == bv->bv_page && off == bv->bv_offset + bv->bv_len) { > > - bv->bv_len += len; > > + bvec_last_segment(seg, &bv); > > + > > + if (page == bv.bv_page && off == bv.bv_offset + bv.bv_len) { > > I think this we can simplify the try to merge into bio case a bit, > and also document it better with something like this: > > diff --git a/block/bio.c b/block/bio.c > index 854676edc438..cc913281a723 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -822,54 +822,40 @@ EXPORT_SYMBOL(bio_add_pc_page); > * @page: page to add > * @len: length of the data to add > * @off: offset of the data in @page > + * @same_page: if %true only merge if the new data is in the same physical > + * page as the last segment of the bio. > * > - * Try to add the data at @page + @off to the last page of @bio. This is a > + * Try to add the data at @page + @off to the last bvec of @bio. This is a > * a useful optimisation for file systems with a block size smaller than the > * page size. > * > * Return %true on success or %false on failure. > */ > bool __bio_try_merge_page(struct bio *bio, struct page *page, > - unsigned int len, unsigned int off) > + unsigned int len, unsigned int off, bool same_page) > { > if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED))) > return false; > > if (bio->bi_vcnt > 0) { > - struct bio_vec bv; > - struct bio_vec *seg = &bio->bi_io_vec[bio->bi_vcnt - 1]; > - > - bvec_last_segment(seg, &bv); > - > - if (page == bv.bv_page && off == bv.bv_offset + bv.bv_len) { > - seg->bv_len += len; > - bio->bi_iter.bi_size += len; > - return true; > - } > + struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; > + phys_addr_t vec_addr = page_to_phys(bv->bv_page); > + phys_addr_t page_addr = page_to_phys(page); > + > + if (vec_addr + bv->bv_offset + bv->bv_len != page_addr + off) > + return false; > + if (same_page && > + (vec_addr & PAGE_SIZE) != (page_addr & PAGE_SIZE)) > + return false; I guess the correct check should be: end_addr = vec_addr + bv->bv_offset + bv->bv_len; if (same_page && (end_addr & PAGE_MASK) != (page_addr & PAGE_MASK)) return false; And this approach is good, will take it in V12. Thanks, Ming