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 3BD943CBE6D for ; Tue, 14 Jul 2026 18:08:52 +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=1784052537; cv=none; b=ZZWCAt5t2u0r+73r4xt1+xjNZ3rMxURjHJ2XBxcicsiqQkqoQBBhnjgMWQU01md1v/ZrSBNT2S/FN6ZdJI/lA9NcaBxZknprqe+CbSzi4xgS8XiyC8fl91lTQZyaIgDmgbBF7glU0TKJER2gwW05QVZhHGmx+YtAVFq6VD2npTM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784052537; c=relaxed/simple; bh=npP2W+CEy54JfAl3hdF4zGPh5LwnDiwxAk2FxviRVog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KIFndRTqk0tQbV2sc0vdsh2KpOjqQXWKns5aGOPORQuzTs+WNmb7jBfC+5ZnnnstDg+mJiVLUqquaQN4bEV3HlFANX8QaGnGBcafQOhxZaJamjKLUFiy2dV30qtXdmK2497m6bqnetoYLUwzRRBAtjh0e7/5GF78juasKy3jEeE= 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=Q1XKHCF1; 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="Q1XKHCF1" 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=ItkheW7o8MDheAOq0+eksdc6lZRrHRH2+xlsXaM+TEw=; b=Q1XKHCF1NcQCCkYe1FUurI0saw 2SY3+LBk6CNUrVThHugCN0aWZ8+bJac9E2jiS51/VAAqH154z30KXYNLaXOLw9mfumCF493Houpod nBmNOTk8lAzdOZJLKvStkn8xo/0sJI/SZpHTz/7O/m6Wplf6rn+sUuI5d1xx/4mVJ0Y4o9HseDI5K S5wOc+nTnStvZ8/OYQF6/BFIIgo/UT4dddeB9kmmYNb0qIyScuZ9Y5HyEAzr9holiKCtVUJ2B2nXu jkEuPBaH/QzoNbcNXjPjp0XAhkbriAiwIa+jv8nPiMKqSwzsLAEz+Hmfec0qE4jAWy9m4b7mxVibT CP7cLKwg==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wjhYh-0000000Fege-1noY; Tue, 14 Jul 2026 18:08:43 +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 Subject: [PATCH v3 7/9] hugetlb: Set mapping folio order Date: Tue, 14 Jul 2026 19:08:37 +0100 Message-ID: <20260714180840.3731244-8-willy@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260714180840.3731244-1-willy@infradead.org> References: <20260714180840.3731244-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) --- 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 f1d4e511d9b1..725bb945a440 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