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 8CBBB2DB79C for ; Thu, 23 Jul 2026 14:30:57 +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=1784817059; cv=none; b=fxHpsPk2Uk79aIoRnmUP0o1gQtm/7bErN1XRpxkx8GMxNYpf8mtJf5QcFRWnyd1E2srv3thjjIMassYAgajEggOOxb+CYHPiS/79iN/y/YTay72uQRc7jU26vWSmD1mqoXaP+8SneoRuFsji/hSJsMa4C+5Pqq+e8IK9zuoJLQQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784817059; c=relaxed/simple; bh=6H0E+/8Ev4ICbFgjc7gRDPMftupZC/TiOYxk7EbQKgo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RaE7MLLKhW/0+yhDpFzToQAeEXm5VjkwKQqpfbg/M8s4fktC0L9l2q+by5OX8ALE2i7RFp4XcHExfagqbZ6b9gQ9z+u9dpFcEaIMPAFLg1TRcUqiOcb9nPclgkvAPDdsvdg28CsaK0AGZIDkb5kDsUXsFl5DugwyJ2cMmiTQ2FM= 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=uDCMJk5i; 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="uDCMJk5i" 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=jQPhhI85VU/RfstxHcf4iE//LF5DLMgP3hQKUkFlgwE=; b=uDCMJk5i9yVb1qLrSaKWZt43nv hVgugzBdxmBU0aIHJ2ZPV5AEmmji9peshWGaRsn80mHXD5lo2Ucn1ENa9uE24Anb8Ws6QexlEmQI2 gxXRZQdk9rJdT/7jhFwyFDfI0Rd6NAzIh61jIdRTkNi5U4CKqkamgoJUZSKqmwjiPAi6kAZTLsM4L b9vHL/cDIN7G6YLHZamSpfNJTex+cQl61ZDyVNO9n5ARCVhCM9j0jMLQpCpHwr8Y4zQuYa8QNBxmn 5y9diPp3XTQcHwRnT3t4oQWLp0yeDJXSfzIeT8wdYKDS7Zh2I2X7MPcU6sQqvgJ29W23GHQaP9izN Yo6faBDQ==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wmuRZ-00000000jiB-2pSo; Thu, 23 Jul 2026 14:30:37 +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 Subject: [PATCH v4 12/14] hugetlb: Set mapping folio order Date: Thu, 23 Jul 2026 15:30:29 +0100 Message-ID: <20260723143034.175661-13-willy@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260723143034.175661-1-willy@infradead.org> References: <20260723143034.175661-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 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