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 1EF28C63798 for ; Thu, 22 Jul 2021 16:28:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A42B160FD7 for ; Thu, 22 Jul 2021 16:28:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A42B160FD7 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 46A386B0036; Thu, 22 Jul 2021 12:28:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41ABB6B005D; Thu, 22 Jul 2021 12:28:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 309F06B006C; Thu, 22 Jul 2021 12:28:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 147666B0036 for ; Thu, 22 Jul 2021 12:28:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id AF6FC8249980 for ; Thu, 22 Jul 2021 16:28:02 +0000 (UTC) X-FDA: 78390755604.26.6A495BA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id C4BA0801AB14 for ; Thu, 22 Jul 2021 16:28:01 +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=8MEr16L96bOGxKrBhIZgt0+SVG6JvQfAHW+MYTYylcg=; b=TvzNICZHhKg2kYETwRHyWEfnsD 0Q5CTsjrbOdcDGY5Aj2GY+TFn74s9evoKF+nWwUzYL6y7BtpAO5Rk6ahQ/O9yibmq6/7rCHtKWUE3 Ae4bGBfntW5q38OZhHG9qq75GtELL5yvYheJHNl1kGhuLZy/ugbt7znISS/btweBZoq09iHzz8PGW 0NJ59+DUKVi6ZPG2wqarhgJDbEHhfl2VvnB0QSpwp92k2CVqpQEkKxcjO1e6hZRLSh8XgbHoK3IWx a7G1cNScVd3ocXuWqkOH62nFRKfOIkxLZIr/g1HKUzcV+/y+RZJ997NN6BcY1y42oTgqIGFAZWizg G4OyOANQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6bXr-00AR4t-C2; Thu, 22 Jul 2021 16:27:42 +0000 Date: Thu, 22 Jul 2021 17:27:35 +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 01/17] block: Add bio_add_folio() Message-ID: 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: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TvzNICZH; spf=none (imf06.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-Rspamd-Server: rspam02 X-Stat-Signature: qdp7im37y767o5u3u8ub71ixzj7xqjor X-Rspamd-Queue-Id: C4BA0801AB14 X-HE-Tag: 1626971281-39457 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 07:42:00AM +0100, Christoph Hellwig wrote: > On Mon, Jul 19, 2021 at 07:39:45PM +0100, Matthew Wilcox (Oracle) wrote: > > +/** > > + * 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); > > +} > > I'd use the opportunity to switch to a true/false return instead of > the length. This has been on my todo list for bio_add_page for a while, > so it might make sense to start out the new API the right way. Looking at it with fresh eyes, I decided to rewrite the docs too. ie this: /** * bio_add_folio - Attempt to add part of a folio to a bio. - * @bio: Bio to add to. + * @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. + * Filesystems that use folios can call this function instead of calling + * bio_add_page() for each page in the folio. If @off is bigger than + * PAGE_SIZE, this function can create a bio_vec that starts in a page + * after the bv_page. BIOs do not support folios that are 4GiB or larger. * - * Return: The number of bytes from this folio added to the bio. + * Return: Whether the addition was successful. */ -size_t bio_add_folio(struct bio *bio, struct folio *folio, size_t len, +bool 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); + return bio_add_page(bio, &folio->page, len, off) > 0; } (i decided to go with > 0 so it's impervious to when you change bio_add_page())