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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 7A1ADC636C8 for ; Thu, 15 Jul 2021 22:29:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 26302613C0 for ; Thu, 15 Jul 2021 22:29:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26302613C0 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 471888D00F4; Thu, 15 Jul 2021 18:29:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4210C8D00EC; Thu, 15 Jul 2021 18:29:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E9AD8D00F4; Thu, 15 Jul 2021 18:29:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 0C5008D00EC for ; Thu, 15 Jul 2021 18:29:15 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DEA2725F30 for ; Thu, 15 Jul 2021 22:29:13 +0000 (UTC) X-FDA: 78366264186.17.6DFE6A7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id 51775F00022B for ; Thu, 15 Jul 2021 22:29:13 +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=pNcRIzV0WfWPp30XWVZN7R6wll8SWE/xO2pHaU3Fz5Q=; b=lWA/47usW8dcIhsdbVQReIK3Et 0GpByjW+BnwwQh/GGIBKXu7vfa1UFXyt4ZUsvnXDDfyUaYkXh/1l3k4bKjut4He9RqR7BLGVMiM4K GiRPreg+YpBttafzA6SICrOqymN93mmXCwXW5G67AzGzTgrzlzGErq4THkT9o8mMPbI1/6f40GlsG +J9aFqgpFOASnEelIE/G5ICWvPQFw2nC1m8dUOLVyBhHA0GIvwXLdUVaV3BolYoBuxLsIiIUZHzVG i6xLypdklO0GQ0LIS1Q7AuBVtZ3ve8TgLE1NOtefqyZYws6Ifc2AfQCOI58pBTz456li9XEZrAmMB EJzZXvJA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m49pW-003w3v-Kt; Thu, 15 Jul 2021 22:27:49 +0000 Date: Thu, 15 Jul 2021 23:27:42 +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 090/138] block: Add bio_add_folio() Message-ID: References: <20210715033704.692967-1-willy@infradead.org> <20210715033704.692967-91-willy@infradead.org> <20210715205917.GC22357@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210715205917.GC22357@magnolia> Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="lWA/47us"; spf=none (imf11.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: 57x9p1rtchf5d3ctfkosyfm8zh9yymzz X-Rspamd-Queue-Id: 51775F00022B X-HE-Tag: 1626388153-871488 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 01:59:17PM -0700, Darrick J. Wong wrote: > On Thu, Jul 15, 2021 at 04:36:16AM +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) > > --- > > 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..1b500611d25c 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 larger than 2GiB. > > + * > > + * 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) > > Er... if bios don't support folios larger than 2GB, then why check @off > and @len against UINT_MAX, which is ~4GB? I suppose that's mostly a documentation problem. The limit is: struct bio_vec { struct page *bv_page; unsigned int bv_len; unsigned int bv_offset; }; so we can support folios which are 2GB in size (0x8000'0000) bytes, but if (theoretically, some day) we had a 4GB folio, we wouldn't be able to handle it in a single bio_vec. So there isn't anything between a 2GB folio and a 4GB folio; a 4GB folio isn't allowed and a 2GB one is. I don't think anything's wrong here, but maybe things could be worded better?