Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp26306pxv; Wed, 14 Jul 2021 22:05:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweVMA2Fxn7Tc/6midssZgP4IJPZegYDwgUxv53MF1rRMNUAaONLCJxiWqpkxw5rbYWkEoo X-Received: by 2002:a92:ad04:: with SMTP id w4mr1254586ilh.221.1626325538330; Wed, 14 Jul 2021 22:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626325538; cv=none; d=google.com; s=arc-20160816; b=UNoAMacL/oVOzCV2Y4x835gNoCRpD6AOlWawPmyyd89T2NthciTsdw5sxqNj6HWI0E en3smr86qNikGNpPDcZ1kA1rFJqYVuADxJaIxUOn2P38aJHWSn3qtu2zzbaxvWkkAIna 09IQU1cZ5Iz2eg6hskGTVLKbMlyAcR5Z4jQ9eL0E4bUGSnLtdFx7Id/4E0cdxcOSKNqW wAWZGmxbFAjhEygdZpd2yZqi7g7Y32oWxf48JZxyqkknD+peZNSNSJCZ4iZJCUt8FizW GYDXs1mHJBE20sxsBzY6WQZ7nbOomTCGFJeF5T6kMLkZ5Yjn1t1fvwHG8PiEP1IDsGw7 oK7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MiJJVUeAUUm2avWMl+iruNtjhb6DvEHcG3LyC3D+Sk0=; b=dAm7SCgA9Zs0meSjMHqE2g6MYUYkMX4Emv+BezhCmuLcDFzYN9A4EPo9OjnrJ3AOLu SVZbTPtWYt+7wuMtBJmnPeKAjNcoQz9wGhTeBfIzGdoPfgdoCHd1TD2omoE7PEWnIl++ vv+GzX49WITwbiosZTGzjmRiVEYvM1zEG/ZN+Z445XK14cZEfnso+n4GjtNUS1R+8f07 YczgN+vMPMTXGsntDUjzxUeeQLCmcmc08HIj8X/HVj5X2VThWGDUCgcMF2WPDbuol+uO 6Gqj7vgrfH0nc1Vuq38jxy+kxon06iErYgVcFPRhBZOA0JJrUs2psRS1V5zRGztOEsHk V4gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="NVyzW/MQ"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v15si5508350jas.5.2021.07.14.22.05.25; Wed, 14 Jul 2021 22:05:38 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="NVyzW/MQ"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236815AbhGOEng (ORCPT + 99 others); Thu, 15 Jul 2021 00:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230310AbhGOEnf (ORCPT ); Thu, 15 Jul 2021 00:43:35 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46AB4C06175F; Wed, 14 Jul 2021 21:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=MiJJVUeAUUm2avWMl+iruNtjhb6DvEHcG3LyC3D+Sk0=; b=NVyzW/MQ0CjOGOpiSX8Wi7vfed ToKC8zpoWsOkjxghObCfKRRFZxQ48dyPYnb1mMAKlA6dLhEejWb3k0zr2/F0zp5XZ3XcDfNmKyRrL 3atBQ3VS7ZoNS+17NAF+Nuy7uDeZoD/eM0WYeOmqA45oF1X2nZoqhJgWzbTc3v54GgaWFo9UAngsm J89yxgFNN/3CloQtWZ7uK7JDtSsJdnkgvrTl/1Jnt0u/cWIItC8lCGuRS7kYSIYkZSurb3Vm/zsIZ axUQ50uQSfzod8/8RbWmwrPCW3Hl4Mi0Hq07KJ2tWSI5Xwcw45hnWnk9i1RC1lXSwB5Tvfl7q/cwG 5X+hnt5Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3t8o-002y7f-F1; Thu, 15 Jul 2021 04:38:51 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: [PATCH v14 077/138] mm/filemap: Add i_blocks_per_folio() Date: Thu, 15 Jul 2021 04:36:03 +0100 Message-Id: <20210715033704.692967-78-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reimplement i_blocks_per_page() as a wrapper around i_blocks_per_folio(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- include/linux/pagemap.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 006de2d84d06..412db88b8d0c 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1150,19 +1150,25 @@ static inline int page_mkwrite_check_truncate(struct page *page, } /** - * i_blocks_per_page - How many blocks fit in this page. + * i_blocks_per_folio - How many blocks fit in this folio. * @inode: The inode which contains the blocks. - * @page: The page (head page if the page is a THP). + * @folio: The folio. * - * If the block size is larger than the size of this page, return zero. + * If the block size is larger than the size of this folio, return zero. * - * Context: The caller should hold a refcount on the page to prevent it + * Context: The caller should hold a refcount on the folio to prevent it * from being split. - * Return: The number of filesystem blocks covered by this page. + * Return: The number of filesystem blocks covered by this folio. */ +static inline +unsigned int i_blocks_per_folio(struct inode *inode, struct folio *folio) +{ + return folio_size(folio) >> inode->i_blkbits; +} + static inline unsigned int i_blocks_per_page(struct inode *inode, struct page *page) { - return thp_size(page) >> inode->i_blkbits; + return i_blocks_per_folio(inode, page_folio(page)); } #endif /* _LINUX_PAGEMAP_H */ -- 2.30.2