Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93DDB36998C for ; Fri, 31 Jul 2026 20:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785528494; cv=none; b=A2Ui+0KGk2SSbsI3rEurvxiZdoWfIUurGBZecmGDNr9CuOzFXjAtoqcEuTntGXM+uJGdxqBhmI854wjhLVV0Kl5Bc9zTyxj/dUQWyTYxxFAjUHZwPat51BrXY9HH9BFGFlsQ8LuSkVg9i0xYr/DHyW0obmtgj5m53VMEnYLb1m0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785528494; c=relaxed/simple; bh=PU+2ya6l+SX4NbpybW2YK1sXJu2A42Lg0IjluDlimno=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LzdxvSk1X9IRup6IiMMDtGGQGYFG6BuKjgXOwI9CFdf7pBuRYyEk2phYm9xF0qIQjh2enwBrpD+tIkh2UOy0MKHI1c/2EphUNfVTsO2AJ8VDqLoMeUMk9XIrcWNcs3Q1gu357vaOrRpPPvYRk7kaVDzFCbFhh5w6G0RuejdLRoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=YyB/J0H6; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YyB/J0H6" 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=yDDIWR17RnluwUMSI/lBv++7pmkRYI5juHNtiKs+PSc=; b=YyB/J0H65u9XYmkYOyzAESRHg+ +Kg+ZN6VrIPKA1Z6J56rax2PJjDmiUgMiMQD71OnosMZ8u9lpY2MM//LXJm8Ac9Rpkd98mwwujGQ3 bhfsDkSIJdR243iS1mqNaAQrR42e1uSGTyARQAbaJbaovn4coUi2AM/Na6VzlInl9xkBPaHPAX3h5 xIfjdMlZyw561PJt6hfihL0Dd6Z7t406lgnK5rbt0V5QXePzH4Salyi5c3LsGORU/+KnHI/1eSlL9 X1zoZqBwQlfxk8h2tLZHe8vCWOAix4Q4uVrqGjYOBNNpsgSkb2j18t7QpqNQU3FpUe77a+EVSKCjH AWTP7XYg==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wptWX-00000002Pnt-2p1M; Fri, 31 Jul 2026 20:08:05 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Jane Chu , linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Muchun Song , Oscar Salvador , David Hildenbrand , Miaohe Lin , Naoya Horiguchi , Jan Kara , linux-fsdevel@vger.kernel.org, Christian Brauner , Jiaqi Yan , Gregory Price Subject: [PATCH v8 13/15] hugetlb: Set mapping folio order Date: Fri, 31 Jul 2026 21:07:58 +0100 Message-ID: <20260731200802.574821-14-willy@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260731200802.574821-1-willy@infradead.org> References: <20260731200802.574821-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hugetlbfs currently uses an fs-specific way to determine the size of the folios in its page cache. Thanks to the support of block sizes larger than page sizes, we now support this as part of the page cache. It's somewhat more efficient as we have this information directly in the mapping rather than going from inode->i_sb->s_fs_info. We can convert the rest of the hugetlb code to use this at our leisure; this is needed now so that we can use filemap_get_pages() unmodified. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Gregory Price --- fs/hugetlbfs/inode.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index dbca3f713bbf..8d15413a67ee 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -883,6 +883,16 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb, return inode; } +static void hugetlbfs_init_regular_inode(struct inode *inode) +{ + struct hstate *hstate = hstate_inode(inode); + unsigned int order = huge_page_order(hstate); + + inode->i_op = &hugetlbfs_inode_operations; + inode->i_fop = &hugetlbfs_file_operations; + mapping_set_folio_order_range(inode->i_mapping, order, order); +} + /* * Hugetlbfs is not reclaimable; therefore its i_mmap_rwsem will never * be taken from reclaim -- unlike regular filesystems. This needs an @@ -926,8 +936,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, init_special_inode(inode, mode, dev); break; case S_IFREG: - inode->i_op = &hugetlbfs_inode_operations; - inode->i_fop = &hugetlbfs_file_operations; + hugetlbfs_init_regular_inode(inode); break; case S_IFDIR: inode->i_op = &hugetlbfs_dir_inode_operations; -- 2.47.3