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 AD264C4338F for ; Fri, 23 Jul 2021 02:40:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3CB0E60EBF for ; Fri, 23 Jul 2021 02:40:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3CB0E60EBF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id CDD876B005D; Thu, 22 Jul 2021 22:40:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8CDC6B006C; Thu, 22 Jul 2021 22:40:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA28B6B0070; Thu, 22 Jul 2021 22:40:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id 9E57A6B005D for ; Thu, 22 Jul 2021 22:40:41 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3B2371DAF6 for ; Fri, 23 Jul 2021 02:40:41 +0000 (UTC) X-FDA: 78392299482.14.5201073 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 462A0E003079 for ; Fri, 23 Jul 2021 02:40:40 +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=bvpCKyJPKQ+52VGiNWJJ88JT5lIx01OMRbRWDKPTqTM=; b=NXA5uHy4/Ittca66HSknUtfumF zTtO6XSGT1YO7UP6247R2NDdNion/+J6gNl8kGxNG4lMhKyn2bXw+IQAIGi+dBeKVZp4H/lxltCQk ZBBiqOBKlOkf2u8fyRsznnFfC2QTdjn0E6UNW1BiMN+9A8oEBXcoXcUsHnKMqg6mIhulHlS+dymml 0lzzyUxAUC6WQt+DeIDwuMGSxYMY72hMHbxt6Rdnn3Z+7QWsc7ChWKZYdzmrN5+/A7C9tJ1jKqrSu q9PSi9ccXXrFy9+8g2YuWvxMltN4viVvE3phGqWQ3NNu+mQAX8zzJzCqNF8uzvc/B9nt6VPAzA0r0 T20CUYGQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6l6x-00Av3q-13; Fri, 23 Jul 2021 02:40:30 +0000 Date: Fri, 23 Jul 2021 03:40:27 +0100 From: Matthew Wilcox To: Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org Subject: Re: [PATCH v15 02/17] block: Add bio_for_each_folio_all() Message-ID: References: <20210719184001.1750630-1-willy@infradead.org> <20210719184001.1750630-3-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 462A0E003079 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NXA5uHy4; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Stat-Signature: mwb7zoiiykeipcr1ntbdig8ydqg7ffmt X-HE-Tag: 1627008040-238303 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 Tue, Jul 20, 2021 at 08:48:07AM +0200, Christoph Hellwig wrote: > On Mon, Jul 19, 2021 at 07:39:46PM +0100, Matthew Wilcox (Oracle) wrote: > > #define bio_for_each_bvec_all(bvl, bio, i) \ > > for (i = 0, bvl = bio_first_bvec_all(bio); \ > > - i < (bio)->bi_vcnt; i++, bvl++) \ > > + i < (bio)->bi_vcnt; i++, bvl++) > > Pleae split out this unrelated fixup. > > > +static inline > > +void bio_first_folio(struct folio_iter *fi, struct bio *bio, int i) > > Please fix the strange formatting. static inline void bio_first_folio(struct folio_iter *fi, struct bio *bio, int i) > > +{ > > + struct bio_vec *bvec = bio_first_bvec_all(bio) + i; > > + > > + fi->folio = page_folio(bvec->bv_page); > > + fi->offset = bvec->bv_offset + > > + PAGE_SIZE * (bvec->bv_page - &fi->folio->page); > > Can we have a little helper for the offset in folio calculation, like: > > static inline size_t offset_of_page_in_folio(struct page *page) > { > return (bvec->bv_page - &page_folio(page)->page) * PAGE; > } > > as that makes the callers a lot easier to read. I've spent most of today thinking about this one. I actually don't want to make this easy to read. This is code that, in an ideal world, would not exist. A bio_vec should not contain a struct page; it should probably be: struct bio_vec { phys_addr_t bv_start; unsigned int bv_len; }; and then the helper to get from a bio_vec to a folio_iter looks like: fi->folio = pfn_folio(bvec->bv_start >> PAGE_SHIFT); fi->offset = offset_in_folio(fi->folio, bvec->bv_start); If instead we decide to keep bvecs the way they are, we can at least turn the bv_page into bv_folio, and then we won't need this code either.