Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4900839pxb; Tue, 2 Nov 2021 18:30:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLbIdg6wS+5WdHcBf+64hzQKhI0Su+rEbMhkyJF/DNz1LfI1HrUT1HIKATfsYSSOJr8odZ X-Received: by 2002:a17:907:3f95:: with SMTP id hr21mr727208ejc.427.1635903023197; Tue, 02 Nov 2021 18:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635903023; cv=none; d=google.com; s=arc-20160816; b=qSUis/L02BLZCiN57U7dzok2tlioC5Ql9+t6STTAV/n5LtzJgG6ZwLz7/JLYg1SYDX NMFxbNo0f3Ze1Q3JmBtbCeH3PPw8E2uqL+ME0lUY0iUZJZWEiHJG5Ix+nOh2a78VbNT2 b0s6G3hYm34ZZdCSBBoSkgKVUP3dSXDFPAK4oYVSaxeuGQmyEfOhre680/oBKXIwjcPG p1EXTHox8+CUUJa/Pm10CPT1i9XnXpVpn+vWbbowkgyfsxap+xPBvkPkrjpAO2Nh2dyO QeqSHrNvaaiA2g2ydMzCzpKqzX1g+WveJpilmqZxQwTD02reZYg+xltV74+Wscq/zLKw Ngpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=bEXDu2rA99lXf0D1O1cSvhm2KEVqvU+Jxst1svzhRL4=; b=cOvGsYI+SnsJLMFMz5jfOJZDafBKDlIZYRrcpkb7+J9eg0YOxo76garma1QcrC49Uo 7K2IENsF3bCyUHs4qyA7hG72tfmuo0JADKgCBFfsku5PbDJZjXSc37b1UNX6+yeBt2LO wVXGSmhoVDlkEMDWQWL5zy6TximSiRWaFhyTjIv0gW5owWK2VETD0h7NiWaHpkFMI4oD lFPCHQNQAaQfStbc+EqF0UDX03zAKmWoncN3pLDi4gL3OcvUhWP9rOkgmVsKxiTHYfQs /G7OfcPWOzIsS3v1AHsZeu2e5epMoQkhiBUQ6nW336cExedUdcOsG+zh6k+UbfDEepmo yA6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u13si1114696edp.551.2021.11.02.18.29.56; Tue, 02 Nov 2021 18:30:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233317AbhKCB2i convert rfc822-to-8bit (ORCPT + 99 others); Tue, 2 Nov 2021 21:28:38 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:30905 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbhKCB2g (ORCPT ); Tue, 2 Nov 2021 21:28:36 -0400 Received: from dggeme752-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HkTVy11MXzcZyC; Wed, 3 Nov 2021 09:21:14 +0800 (CST) Received: from dggeme751-chm.china.huawei.com (10.3.19.97) by dggeme752-chm.china.huawei.com (10.3.19.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.15; Wed, 3 Nov 2021 09:25:58 +0800 Received: from dggeme751-chm.china.huawei.com ([169.254.210.30]) by dggeme751-chm.china.huawei.com ([169.254.210.30]) with mapi id 15.01.2308.015; Wed, 3 Nov 2021 09:25:58 +0800 From: "wangjianjian (C)" To: "Matthew Wilcox (Oracle)" , "Darrick J. Wong" CC: "linux-xfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , Jens Axboe , Christoph Hellwig Subject: RE: [PATCH 02/21] block: Add bio_add_folio() Thread-Topic: [PATCH 02/21] block: Add bio_add_folio() Thread-Index: AQHXz2GCGZfotygsu0GMr7Q1z+eru6vxBCEA Date: Wed, 3 Nov 2021 01:25:57 +0000 Message-ID: References: <20211101203929.954622-1-willy@infradead.org> <20211101203929.954622-3-willy@infradead.org> In-Reply-To: <20211101203929.954622-3-willy@infradead.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.108.234.122] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org diff --git a/block/bio.c b/block/bio.c index 15ab0d6d1c06..0e911c4fb9f2 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1033,6 +1033,28 @@ 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. + * + * 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: Whether the addition was successful. + */ +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) > 0; } + Newline.