Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2004978rwl; Thu, 30 Mar 2023 04:52:48 -0700 (PDT) X-Google-Smtp-Source: AKy350b7sykxr06oBksqo3VwPImM8cjPfm8SNTlevFtlXPKBfbd0fIUvB23IeXWRtuXalEoRGlqW X-Received: by 2002:a17:90b:e01:b0:237:40a5:77cb with SMTP id ge1-20020a17090b0e0100b0023740a577cbmr2113736pjb.1.1680177168212; Thu, 30 Mar 2023 04:52:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680177168; cv=none; d=google.com; s=arc-20160816; b=P73tRBNDllOQxd/s6APwCLCUgkV0xvEZ2W8uQ8l2YISxVzXuFWDcN5rNBf/D5XNJYl JXnmr1OIoUi6dcEVwJAOo6criIIXTpJnH2SsWhQW8TMPlP2vLyas5nAEka1bQOn3hz2O iHIclE5dLFQCdoGnp99wySbD9FoKUV6pn05FmKyQ0newCPHsnh9JRd83Sj/xOVEaOSCO prVvoMFRmy/xx/WMafP4NBugs+D9ltwoutPnqcJcODt0bdpN6iJM1ALs1z8DvB2H38bL hLffEagJnAxUXokBMHAQgayj3fsOS7a3RIvbq31xUzf0aoNAfGYbs3i7JVChUaavFUPN Sy4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MgT8q2jy++WQMRLIsrm1uJ/zXUAPqptvzJtFdyenaOc=; b=sD6XUWXfWa1clEE2Udu2Vb5ggpM62MN/HjrzKgcBBKTX6i2F4QuoG1ajFah+ZEt487 bHywZAp2CesdkTn8pskFGWt+lng0jQv/5rJDyaU38Gv4zO3g4MyiIrBAqpOEpX5s+Dh1 3v3ewIKTvFWjgyC9IzCy8SD0Mr/T2C2Ttubj4b3S8HEBsBANoPCniG9u0YWlaL/oideF 7bVHfvTl4GOlHCwKMsyaP8DJgL+YYHTInb8FTE6tbNYNI1oJTdc8tIaw/YTuDvi1UVV+ jYeiKu1HioaEoW+xOvylDdb1FrS6iVn9B3T7l+lvgqDmoGAM8ZpRpQ7BR3rENeX0L9Cp FQYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BstHzPWK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a17090a950a00b0023d422d08c6si3814726pjo.27.2023.03.30.04.52.36; Thu, 30 Mar 2023 04:52:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BstHzPWK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231673AbjC3Lua (ORCPT + 99 others); Thu, 30 Mar 2023 07:50:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbjC3LuX (ORCPT ); Thu, 30 Mar 2023 07:50:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95D579E for ; Thu, 30 Mar 2023 04:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680176978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MgT8q2jy++WQMRLIsrm1uJ/zXUAPqptvzJtFdyenaOc=; b=BstHzPWK7beiPSJmnGtls4pvA0NdEVlJnV1XnTUGxPuSSBdWat1RxFxS9ZR3e36PX8iL8b xcR5IKqgxaupPRv9OaZe+rzwNAXyRcjr7szD/CrFOh/yUChzWpbiyJh4QjWxbybsTqbXvI sqfAI7rIsHaMcIIZxPcxl0AlWjiX7JE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-XelzLDmsP4WGt43mfZhqJw-1; Thu, 30 Mar 2023 07:49:35 -0400 X-MC-Unique: XelzLDmsP4WGt43mfZhqJw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E1A543C025C4; Thu, 30 Mar 2023 11:49:34 +0000 (UTC) Received: from ovpn-8-19.pek2.redhat.com (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAB0B2166B33; Thu, 30 Mar 2023 11:49:29 +0000 (UTC) Date: Thu, 30 Mar 2023 19:49:23 +0800 From: Ming Lei To: Kent Overstreet Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, willy@infradead.org, axboe@kernel.dk, Phillip Lougher , ming.lei@redhat.com Subject: Re: [PATCH 1/2] block: Rework bio_for_each_segment_all() Message-ID: References: <20230327174402.1655365-1-kent.overstreet@linux.dev> <20230327174402.1655365-2-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230327174402.1655365-2-kent.overstreet@linux.dev> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 27, 2023 at 01:44:01PM -0400, Kent Overstreet wrote: > This patch reworks bio_for_each_segment_all() to be more inline with how > the other bio iterators work: > > - bio_iter_all_peek() now returns a synthesized bio_vec; we don't stash > one in the iterator and pass a pointer to it - bad. This way makes it > clearer what's a constructed value vs. a reference to something > pre-existing, and it also will help with cleaning up and > consolidating code with bio_for_each_folio_all(). > > - We now provide bio_for_each_segment_all_continue(), for squashfs: > this makes their code clearer. > > Signed-off-by: Kent Overstreet > Cc: Jens Axboe > Cc: linux-block@vger.kernel.org > Cc: Ming Lei > Cc: Phillip Lougher > --- > block/bio.c | 38 ++++++++++++------------ > block/blk-map.c | 38 ++++++++++++------------ > block/bounce.c | 12 ++++---- > drivers/md/bcache/btree.c | 8 ++--- > drivers/md/dm-crypt.c | 10 +++---- > drivers/md/raid1.c | 4 +-- > fs/btrfs/disk-io.c | 10 +++---- > fs/btrfs/extent_io.c | 52 ++++++++++++++++----------------- > fs/btrfs/inode.c | 8 ++--- > fs/btrfs/raid56.c | 18 ++++++------ > fs/crypto/bio.c | 8 ++--- > fs/erofs/zdata.c | 4 +-- > fs/ext4/page-io.c | 8 ++--- > fs/ext4/readpage.c | 4 +-- > fs/f2fs/data.c | 20 ++++++------- > fs/gfs2/lops.c | 10 +++---- > fs/gfs2/meta_io.c | 8 ++--- > fs/mpage.c | 4 +-- > fs/squashfs/block.c | 48 ++++++++++++++++-------------- > fs/squashfs/lz4_wrapper.c | 17 ++++++----- > fs/squashfs/lzo_wrapper.c | 17 ++++++----- > fs/verity/verify.c | 4 +-- > include/linux/bio.h | 31 +++++++++++++++----- > include/linux/bvec.h | 61 ++++++++++++++++++++++----------------- > 24 files changed, 239 insertions(+), 203 deletions(-) > > diff --git a/block/bio.c b/block/bio.c > index ab59a491a8..8d3abe249e 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -1170,13 +1170,13 @@ bool bio_add_folio(struct bio *bio, struct folio *folio, size_t len, > > void __bio_release_pages(struct bio *bio, bool mark_dirty) > { > - struct bvec_iter_all iter_all; > - struct bio_vec *bvec; > + struct bvec_iter_all iter; > + struct bio_vec bvec; > > - bio_for_each_segment_all(bvec, bio, iter_all) { > - if (mark_dirty && !PageCompound(bvec->bv_page)) > - set_page_dirty_lock(bvec->bv_page); > - put_page(bvec->bv_page); > + bio_for_each_segment_all(bvec, bio, iter) { > + if (mark_dirty && !PageCompound(bvec.bv_page)) > + set_page_dirty_lock(bvec.bv_page); > + put_page(bvec.bv_page); > } bio_for_each_segment_all is supposed to be used by bio which owns the bvec table, so it is just fine to return bvec pointer by bio_for_each_segment_all to save extra bvec copy. And the change becomes not efficient any more. Thanks, Ming