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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 AEB2EC07E9D for ; Tue, 20 Jul 2021 01:29:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 375356113C for ; Tue, 20 Jul 2021 01:29:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 375356113C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C5D578D0002; Mon, 19 Jul 2021 21:29:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C34958D0001; Mon, 19 Jul 2021 21:29:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD4EC8D0002; Mon, 19 Jul 2021 21:29:02 -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 8B60A8D0001 for ; Mon, 19 Jul 2021 21:29:02 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1CAD78248047 for ; Tue, 20 Jul 2021 01:29:01 +0000 (UTC) X-FDA: 78381232482.27.FAE081E Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf02.hostedemail.com (Postfix) with ESMTP id C5C397001A23 for ; Tue, 20 Jul 2021 01:29:00 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 410F161004; Tue, 20 Jul 2021 01:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626744535; bh=45got/es61xzhcsJqmAAohKb8WL0wk+ATYQu22DHInM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VDc8rfvvE0h4hOM+M7QpIwBxdgLrl/llbVOuXZZxf4/KTWlYloBlSUEl6wxiy02Ze r5DqFHgNEeQx4aNl9tOK8yAywHG48gVzFn5qAEoib6J6M2VqJ0BijzwTDpHUbHLhOa RvGbd8sd4C8unWKSmVUw+f00ug9zIblwRanulDZcyAiJ6ahRtZHJ/jSbM+faTUaKoV 8zb2OxSRI/05CytVoZfhMPsvv7fHrGvYeUOA4VXfmB0V3wliaQa59J/XGcbXPNU6yJ 8jzvgyggwgWss754qPBERzz8ACiRO7EqU4GfofHe6BJaNL95pMGv9vp0Qmn2aje43Q R/i63DAh51pqw== Date: Mon, 19 Jul 2021 18:28:54 -0700 From: "Darrick J. Wong" To: "Matthew Wilcox (Oracle)" Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org Subject: Re: [PATCH v15 01/17] block: Add bio_add_folio() Message-ID: <20210720012854.GN22357@magnolia> References: <20210719184001.1750630-1-willy@infradead.org> <20210719184001.1750630-2-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210719184001.1750630-2-willy@infradead.org> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C5C397001A23 X-Stat-Signature: 14ghwzhpn9uxnyeai46pbaoh3e3ofhxs Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VDc8rfvv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of djwong@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=djwong@kernel.org X-HE-Tag: 1626744540-334451 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 Mon, Jul 19, 2021 at 07:39:45PM +0100, Matthew Wilcox (Oracle) wrote: > This is a thin wrapper around bio_add_page(). The main advantage here > is the documentation that the submitter can expect to see folios in the > completion handler, and that stupidly large folios are not supported. > It's not currently possible to allocate stupidly large folios, but if > it ever becomes possible, this function will fail gracefully instead of > doing I/O to the wrong bytes. > > Signed-off-by: Matthew Wilcox (Oracle) Looks fine to me, Reviewed-by: Darrick J. Wong --D > --- > block/bio.c | 21 +++++++++++++++++++++ > include/linux/bio.h | 3 ++- > 2 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/block/bio.c b/block/bio.c > index 1fab762e079b..c64e35548fb2 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -933,6 +933,27 @@ int bio_add_page(struct bio *bio, struct page *page, > } > EXPORT_SYMBOL(bio_add_page); > > +/** > + * bio_add_folio - Attempt to add part of a folio to a bio. > + * @bio: Bio to add to. > + * @folio: Folio to add. > + * @len: How many bytes from the folio to add. > + * @off: First byte in this folio to add. > + * > + * Always uses the head page of the folio in the bio. If a submitter only > + * uses bio_add_folio(), it can count on never seeing tail pages in the > + * completion routine. BIOs do not support folios that are 4GiB or larger. > + * > + * Return: The number of bytes from this folio added to the bio. > + */ > +size_t bio_add_folio(struct bio *bio, struct folio *folio, size_t len, > + size_t off) > +{ > + if (len > UINT_MAX || off > UINT_MAX) > + return 0; > + return bio_add_page(bio, &folio->page, len, off); > +} > + > void bio_release_pages(struct bio *bio, bool mark_dirty) > { > struct bvec_iter_all iter_all; > diff --git a/include/linux/bio.h b/include/linux/bio.h > index 2203b686e1f0..ade93e2de6a1 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -462,7 +462,8 @@ extern void bio_uninit(struct bio *); > extern void bio_reset(struct bio *); > void bio_chain(struct bio *, struct bio *); > > -extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); > +int bio_add_page(struct bio *, struct page *, unsigned len, unsigned off); > +size_t bio_add_folio(struct bio *, struct folio *, size_t len, size_t off); > extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, > unsigned int, unsigned int); > int bio_add_zone_append_page(struct bio *bio, struct page *page, > -- > 2.30.2 >