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 8F2224749D6 for ; Tue, 28 Jul 2026 20:44:42 +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=1785271483; cv=none; b=r6hCeQCZU/AzLhOkdMwlGL/gaYg2eVMDZUBBBU9gS89lCrgIa5lz1NiTfdmiicyjlkm2WBdmY0093y/W+gTjx5G3d8ucaX87pGXY9FCArfwufEEwqERplINsFDQqwvEbyUuOOJmyl8UBOucQ/KgIzRA/mG19gc5/kf12zTIEFCw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785271483; c=relaxed/simple; bh=PU+2ya6l+SX4NbpybW2YK1sXJu2A42Lg0IjluDlimno=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XkNYA5iZ8jzvCkuT/24SGO/8YC91j5aVb8fZVczK5t5WzLEdbXA32hYuKPzLjEGbzfJM+IueBzbfj4T1na6EyVJIaJkH9ZQmfWv3kici5AxAcs6qfFYGqdJ+YQMbVtYoJ/vQmg9LIHK9t97bYDT90n+8o3fZbxjhuETPjiJ0d38= 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=qrO7Cw2g; 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="qrO7Cw2g" 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=qrO7Cw2gr4ZZFsIBsPnTEiTcu5 3wCV3tGO853KDfW7Jx10rmW19nYo6kaHLyUImocIR72SI7r17BH/gKDnmmNL48HZY54bwZHdzJBlf IJIZsLlQkDBUm6i629fKBYIykLLrMVrAUjhVPVJha94zANNDCsAPZzO0ILlZgLsVol/yMDuVeEiQG BUtidWHLsyTmqvibuC2HuRqAUTlucwkY5gTW/YJfIxovbxr/3uJAFkqBCTPqGN8jR38J9V+1IINGa wohwNYpQ5ZUtVCKtg14ZqK2/BRKSbDz2wLAwQzR+ohTbx3ojr7mnPdK01Gn+QY67D8IjeRPIw+ggd 17Fckm4Q==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wooeq-0000000EFWz-1o5j; Tue, 28 Jul 2026 20:44:12 +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 v7 11/13] hugetlb: Set mapping folio order Date: Tue, 28 Jul 2026 21:44:03 +0100 Message-ID: <20260728204409.3396238-12-willy@infradead.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260728204409.3396238-1-willy@infradead.org> References: <20260728204409.3396238-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