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=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 04747C4338F for ; Fri, 30 Jul 2021 08:25:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8DC8460EB2 for ; Fri, 30 Jul 2021 08:25:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8DC8460EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id DE6D66B0036; Fri, 30 Jul 2021 04:25:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D967C6B005D; Fri, 30 Jul 2021 04:25:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C84566B006C; Fri, 30 Jul 2021 04:25:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id AC8876B0036 for ; Fri, 30 Jul 2021 04:25:29 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 45934182AF1FF for ; Fri, 30 Jul 2021 08:25:29 +0000 (UTC) X-FDA: 78418569978.02.F30156D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id C9B3BD005E46 for ; Fri, 30 Jul 2021 08:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627633528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FtGnm8xmLjSMkjUsJ50BAg0rK1TkGGuEgcUSvcoAdjc=; b=V6MIoTraS1S1bekbEkJxsKlcTTVWMlflxP0S61EQib2H+d61dFnC28Pj8xyym6M7JX6h45 Dw3XecVLU/SE5ZkMcipbSHuhfa3eCDYj5nUkwB6SJh1Q+TtQvbI/3/hFGK7aOvoJ//PP3T wJQ5IFkfWQmjLVtyeHDQ1X9zt58wEFI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-3-HzwnD3o8MJaLgfvxUP-Y0A-1; Fri, 30 Jul 2021 04:25:23 -0400 X-MC-Unique: HzwnD3o8MJaLgfvxUP-Y0A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1929100E420; Fri, 30 Jul 2021 08:25:22 +0000 (UTC) Received: from T590 (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07D8C5D6A1; Fri, 30 Jul 2021 08:25:15 +0000 (UTC) Date: Fri, 30 Jul 2021 16:25:17 +0800 From: Ming Lei 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: 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C9B3BD005E46 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V6MIoTra; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf15.hostedemail.com: domain of ming.lei@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=ming.lei@redhat.com X-Stat-Signature: ripdyxcnaei5mkfgbkgqxwadr1zypn19 X-HE-Tag: 1627633528-337187 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) > --- > 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; The added page shouldn't cross 4G boundary, so just wondering why not check 'if (len > UINT_MAX - off)'? Thanks, Ming