Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp556073imu; Mon, 26 Nov 2018 14:57:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/VcBFjEJfs8gIDOElFyuF9Ts4mIvO/I5rJrZKfzcnp9J0EZ7aDaB2XYlispaTtUBjvCGyBl X-Received: by 2002:a63:4187:: with SMTP id o129mr24973380pga.370.1543273068711; Mon, 26 Nov 2018 14:57:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543273068; cv=none; d=google.com; s=arc-20160816; b=FwTysRGy59Le54fxfFnzm5cVsIaat2QLjR1hmZweeo3r/mTCE2P/rqO8kYMEYvSgnC wZ4Tw2Ddspi761EHJXSY4Pdbq9U4vl3gJGDgh7dafIGCq3ISSxfhrTZbsodhztJKDeTO T3oBhKtb9/h5eDjP9YhVErCWP7tC0BURcEs20D5SahBtgDKdMW9H1Cdq2P4GG5qQWE2O LLOktfIRVoGZsjiI7lTNNLNbPkbtMjtvsznyKyRto+B+pp/qWjIlFnsQlBw88CCiFXyQ wF4orRWwdBo8lRKk/jxfCexc7r7UXFj2xh6wgjIVPHbqiDrSUnKsfDU1Jf5hFfz0FIeF ZENg== 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:dkim-signature; bh=zbfCjqBHpAJ7K3XFvE3QIuIxE9xXYdGtzAQcePbc+b8=; b=UdwY5d0cdld+uhfxWd6jbi/b9FwW64yaIZSDgsBqhm1AI59A3we/iw8zLNCFWA2EUe CKK04V7qzBleeT3iOcCeRVOmwR5PgwUl8A+NPgbHwI574e8AINfbbBoAXX3Z+S+gccwu 5EgA2iy3/ULLbIKg98k5fG7S4sfZ148UHeVduIi9Bm29CzjTJ+IIhjUYWMzN68fK5IBx +InASi4nANt8rw5w/sLQciJGYJiVpAyE7C+ngvrTWhkVZhoELsnBB3lM5WSdeoWgXRQu 6NSb2Xww/EvwEN05AA7dy2rb9kHMBx52At2iYmyGh4O/yXlO2rAISsH6D5OXUxIW0Nmv AcIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=kjJ40KIA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si1781212pfj.183.2018.11.26.14.57.33; Mon, 26 Nov 2018 14:57:48 -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; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=kjJ40KIA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727491AbeK0Jwg (ORCPT + 99 others); Tue, 27 Nov 2018 04:52:36 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37530 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727188AbeK0Jwf (ORCPT ); Tue, 27 Nov 2018 04:52:35 -0500 Received: by mail-pg1-f196.google.com with SMTP id 80so6872908pge.4 for ; Mon, 26 Nov 2018 14:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zbfCjqBHpAJ7K3XFvE3QIuIxE9xXYdGtzAQcePbc+b8=; b=kjJ40KIAs6CJd9vbyC4OxMuKuzLv9P0M+3fs8oA7yLXGSKDh9ooEer+N6sG/TIv02K u5f09fdt3N2VxD0oiXbct2aJOCQCUdDZPAoy4mJ5K8rZ+Z+ybQvCDf72o3Svo4Ov4lkl WoBy9MTIywvgJdsGjaYVHZNPdYKFRsEawnMsU5k+DFWZVESRwLd0zkkqgHmDHlxE4CF2 Oo2IwAukkVu6SjMPpM4Q22u/sjYGmgK1iGNEDewb0q2UriqLOgaq1YUTIJLvFgU3fMI4 yJtzFyrEvxnIqJlrsK63mLpslLax00bqYdnyHI4OUwNLu2LTRT7CLJ/Xp0QkBznPBsD0 GrxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zbfCjqBHpAJ7K3XFvE3QIuIxE9xXYdGtzAQcePbc+b8=; b=hWxcmLbXr5CF/JuhNUkeN+vuGyXZM5IlrENMICr0xf/VPh4TqjB3zz++5S2csidP8o bFZAFqQ23WcZCP0MdEGZLlrQfw1RzZR9ZPe/CVHjcAmiWm9ZHgZvCYPe6Wl3dhyzh5ZX eVFrOv3t8OdU7HHVMWBLaE0X1wSayOMJCyiHTTtoVUaOzPdkDR4EDZU6w5lQoZI4RneS g67KYSld+5yl67bYefXCPUqNVNPQ5Oj6avFXFxgdWdoIfAf5e+9ZDLW+frYXFfqvfW38 bi11cFGQ07bPsy8ThYWYN5naUwYX18lqdQ50HtyownRbgi1m2ohEFxsK/Jezlepl355L Mcxw== X-Gm-Message-State: AA+aEWZvzFeVi61dPXDjl2Taln0yQwZFzdAqYA3DsonUQ5AUFiXjsbkN N9y83iGpRY7NLFy2mDK9KgTLfQ== X-Received: by 2002:a63:5e43:: with SMTP id s64mr26918522pgb.101.1543273012498; Mon, 26 Nov 2018 14:56:52 -0800 (PST) Received: from vader ([2601:602:8b00:55d3:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id n22sm2153399pfh.166.2018.11.26.14.56.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Nov 2018 14:56:51 -0800 (PST) Date: Mon, 26 Nov 2018 14:56:49 -0800 From: Omar Sandoval To: Ming Lei 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 , Christoph Hellwig , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: Re: [PATCH V12 16/20] block: enable multipage bvecs Message-ID: <20181126225649.GP30411@vader> References: <20181126021720.19471-1-ming.lei@redhat.com> <20181126021720.19471-17-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181126021720.19471-17-ming.lei@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 10:17:16AM +0800, Ming Lei wrote: > This patch pulls the trigger for multi-page bvecs. Reviewed-by: Omar Sandoval > Signed-off-by: Ming Lei > --- > block/bio.c | 22 +++++++++++++++------- > fs/iomap.c | 4 ++-- > fs/xfs/xfs_aops.c | 4 ++-- > include/linux/bio.h | 2 +- > 4 files changed, 20 insertions(+), 12 deletions(-) > > diff --git a/block/bio.c b/block/bio.c > index 75fde30af51f..8bf9338d4783 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -753,6 +753,8 @@ 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 bvec of @bio. This is a > * a useful optimisation for file systems with a block size smaller than the > @@ -761,19 +763,25 @@ EXPORT_SYMBOL(bio_add_pc_page); > * 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 = &bio->bi_io_vec[bio->bi_vcnt - 1]; > + phys_addr_t vec_end_addr = page_to_phys(bv->bv_page) + > + bv->bv_offset + bv->bv_len; > + phys_addr_t page_addr = page_to_phys(page); > > - if (page == bv->bv_page && off == bv->bv_offset + bv->bv_len) { > - bv->bv_len += len; > - bio->bi_iter.bi_size += len; > - return true; > - } > + if (vec_end_addr != page_addr + off) > + return false; > + if (same_page && ((vec_end_addr - 1) & PAGE_MASK) != page_addr) > + return false; > + > + bv->bv_len += len; > + bio->bi_iter.bi_size += len; > + return true; > } > return false; > } > @@ -819,7 +827,7 @@ EXPORT_SYMBOL_GPL(__bio_add_page); > int bio_add_page(struct bio *bio, struct page *page, > unsigned int len, unsigned int offset) > { > - if (!__bio_try_merge_page(bio, page, len, offset)) { > + if (!__bio_try_merge_page(bio, page, len, offset, false)) { > if (bio_full(bio)) > return 0; > __bio_add_page(bio, page, len, offset); > diff --git a/fs/iomap.c b/fs/iomap.c > index 1f648d098a3b..ec5527b0fba4 100644 > --- a/fs/iomap.c > +++ b/fs/iomap.c > @@ -313,7 +313,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, > */ > sector = iomap_sector(iomap, pos); > if (ctx->bio && bio_end_sector(ctx->bio) == sector) { > - if (__bio_try_merge_page(ctx->bio, page, plen, poff)) > + if (__bio_try_merge_page(ctx->bio, page, plen, poff, true)) > goto done; > is_contig = true; > } > @@ -344,7 +344,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, > ctx->bio->bi_end_io = iomap_read_end_io; > } > > - __bio_add_page(ctx->bio, page, plen, poff); > + bio_add_page(ctx->bio, page, plen, poff); > done: > /* > * Move the caller beyond our range so that it keeps making progress. > diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c > index 1f1829e506e8..b9fd44168f61 100644 > --- a/fs/xfs/xfs_aops.c > +++ b/fs/xfs/xfs_aops.c > @@ -616,12 +616,12 @@ xfs_add_to_ioend( > bdev, sector); > } > > - if (!__bio_try_merge_page(wpc->ioend->io_bio, page, len, poff)) { > + if (!__bio_try_merge_page(wpc->ioend->io_bio, page, len, poff, true)) { > if (iop) > atomic_inc(&iop->write_count); > if (bio_full(wpc->ioend->io_bio)) > xfs_chain_bio(wpc->ioend, wbc, bdev, sector); > - __bio_add_page(wpc->ioend->io_bio, page, len, poff); > + bio_add_page(wpc->ioend->io_bio, page, len, poff); > } > > wpc->ioend->io_size += len; > diff --git a/include/linux/bio.h b/include/linux/bio.h > index c35997dd02c2..5505f74aef8b 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -441,7 +441,7 @@ extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); > extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, > unsigned int, unsigned int); > 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); > void __bio_add_page(struct bio *bio, struct page *page, > unsigned int len, unsigned int off); > int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter); > -- > 2.9.5 >