From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58EB2C636C8 for ; Thu, 15 Jul 2021 22:39:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E7B33613D2 for ; Thu, 15 Jul 2021 22:39:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7B33613D2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 32C028D00F4; Thu, 15 Jul 2021 18:39:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DC178D00EC; Thu, 15 Jul 2021 18:39:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17DC38D00F4; Thu, 15 Jul 2021 18:39:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id DFE618D00EC for ; Thu, 15 Jul 2021 18:39:06 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B88641813F3E9 for ; Thu, 15 Jul 2021 22:39:05 +0000 (UTC) X-FDA: 78366289050.19.A610DCB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 5C0A05010B31 for ; Thu, 15 Jul 2021 22:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=rqwv+/Mw6cZWzpgmEoo2CyIEE0qUzcO+Ut9DGb/HsXI=; b=tb9XoimIskcyhZCM4kV/yubjzv /UiD8uTSSKpunCgDKXzIvVXVvAaWjRNsOW+fZCXx1XAYpFcHj4OFdYKIVnkv7kvWGgwkiV7LtUn+f +iMTDL/9xJHCqY/H7KhKeLtsPUe7bTGFYHLlwUIy/03ErZYLZsBylRVx6xC9jETcA9//sBAu0pF5d lfOaxfQCQZmbvnpldkXqEpd4xt5V5FDfGHJzo8Mx6rg4CqKs6YYhDbQ0JXsDAWQ6ScVjSg3sbZyy4 7SejW3rNo4zSjtRm2t/4rWiuM2WHda1BgrJt9Nlo/Z6Rl7bwX70Z2WTZF8QdzjFs6csLmAxupwQTx s5ZSjpOA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m49zk-003wQ5-T3; Thu, 15 Jul 2021 22:38:31 +0000 Date: Thu, 15 Jul 2021 23:38:16 +0100 From: Matthew Wilcox To: "Darrick J. Wong" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v14 091/138] block: Add bio_for_each_folio_all() Message-ID: References: <20210715033704.692967-1-willy@infradead.org> <20210715033704.692967-92-willy@infradead.org> <20210715211254.GE22357@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210715211254.GE22357@magnolia> Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tb9XoimI; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Stat-Signature: s93o49fho1cyr495615mzad8ih7znah9 X-Rspamd-Queue-Id: 5C0A05010B31 X-Rspamd-Server: rspam01 X-HE-Tag: 1626388745-59874 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jul 15, 2021 at 02:12:54PM -0700, Darrick J. Wong wrote: > On Thu, Jul 15, 2021 at 04:36:17AM +0100, Matthew Wilcox (Oracle) wrote: > > +struct folio_iter { > > + struct folio *folio; > > + size_t offset; > > + size_t length; > > Hm... so after every bio_{first,next}_folio call, we can access the > folio, the offset, and the length (both in units of bytes) within the > folio? Correct. > > + size_t _seg_count; > > + int _i; > > And these are private variables that the iteration code should not > scribble over? Indeed! > > +/* > > + * Iterate over each folio in a bio. > > + */ > > +#define bio_for_each_folio_all(fi, bio) \ > > + for (bio_first_folio(&fi, bio, 0); fi.folio; bio_next_folio(&fi, bio)) > > ...so I guess a sample iteration loop would be something like: > > struct bio *bio = ; > struct folio_iter fi; > > bio_for_each_folio_all(fi, bio) { > if (folio_test_dirty(fi.folio)) > printk("folio idx 0x%lx is dirty, i hates dirty data!", > folio_index(fi.folio)); > panic(); > } > > I'll go look through the rest of the patches, but this so far looks > pretty straightforward to me. Something very much like that! +static void iomap_read_end_io(struct bio *bio) { + struct folio_iter fi; + bio_for_each_folio_all(fi, bio) + iomap_finish_folio_read(fi.folio, fi.offset, fi.length, error);