1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright (c) 2023, 2024, Klara Inc. 25 * Copyright (c) 2024, Rob Norris <robn@despairlabs.com> 26 */ 27 28 #ifndef _ZFS_MM_COMPAT_H 29 #define _ZFS_MM_COMPAT_H 30 31 #include <linux/mm.h> 32 #include <linux/pagemap.h> 33 34 /* 5.4 introduced page_size(). Older kernels can use a trivial macro instead */ 35 #ifndef HAVE_MM_PAGE_SIZE 36 #define page_size(p) ((unsigned long)(PAGE_SIZE << compound_order(p))) 37 #endif 38 39 /* 6.11 removed page_mapping(). A simple wrapper around folio_mapping() works */ 40 #ifndef HAVE_MM_PAGE_MAPPING 41 #define page_mapping(p) folio_mapping(page_folio(p)) 42 #endif 43 44 /* 45 * 6.12 removed PG_error, SetPageError and ClearPageError, with no direct 46 * replacement, because page writeback errors are recorded elsewhere. Since we 47 * only use the page cache to assist with mmap(), never directly backing it 48 * with IO, it shouldn't be possible for this condition to occur on our pages 49 * anyway, even if this is the right way to report it. So it should be safe 50 * to remove, but for avoidance of doubt, we make it a no-op on 6.12 and leave 51 * it for everything else. 52 */ 53 #ifndef HAVE_MM_PAGE_FLAG_ERROR 54 #define SetPageError(p) do {} while (0) 55 #define ClearPageError(p) do {} while (0) 56 #endif 57 58 #endif /* _ZFS_MM_COMPAT_H */ 59