Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * aops.h - Defines for NTFS kernel address space operations and page cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *	    handling.  Part of the Linux-NTFS project.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (c) 2001-2004 Anton Altaparmakov
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Copyright (c) 2002 Richard Russon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef _LINUX_NTFS_AOPS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define _LINUX_NTFS_AOPS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/highmem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "inode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * ntfs_unmap_page - release a page that was mapped using ntfs_map_page()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  * @page:	the page to release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * Unpin, unmap and release a page that was obtained from ntfs_map_page().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static inline void ntfs_unmap_page(struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	kunmap(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  * ntfs_map_page - map a page into accessible memory, reading it if necessary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)  * @mapping:	address space for which to obtain the page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)  * @index:	index into the page cache for @mapping of the page to map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)  * Read a page from the page cache of the address space @mapping at position
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)  * @index, where @index is in units of PAGE_SIZE, and not in bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)  * If the page is not in memory it is loaded from disk first using the readpage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)  * method defined in the address space operations of @mapping and the page is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)  * added to the page cache of @mapping in the process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)  * If the page belongs to an mst protected attribute and it is marked as such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)  * in its ntfs inode (NInoMstProtected()) the mst fixups are applied but no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)  * error checking is performed.  This means the caller has to verify whether
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)  * the ntfs record(s) contained in the page are valid or not using one of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)  * ntfs_is_XXXX_record{,p}() macros, where XXXX is the record type you are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)  * expecting to see.  (For details of the macros, see fs/ntfs/layout.h.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)  * If the page is in high memory it is mapped into memory directly addressible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)  * by the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)  * Finally the page count is incremented, thus pinning the page into place.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)  * The above means that page_address(page) can be used on all pages obtained
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)  * with ntfs_map_page() to get the kernel virtual address of the page.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)  * When finished with the page, the caller has to call ntfs_unmap_page() to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)  * unpin, unmap and release the page.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)  * Note this does not grant exclusive access. If such is desired, the caller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)  * must provide it independently of the ntfs_{un}map_page() calls by using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)  * a {rw_}semaphore or other means of serialization. A spin lock cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)  * used as ntfs_map_page() can block.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)  * The unlocked and uptodate page is returned on success or an encoded error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)  * on failure. Caller has to test for error using the IS_ERR() macro on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)  * return value. If that evaluates to 'true', the negative error code can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)  * obtained using PTR_ERR() on the return value of ntfs_map_page().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static inline struct page *ntfs_map_page(struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 		unsigned long index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	struct page *page = read_mapping_page(mapping, index, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	if (!IS_ERR(page)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 		kmap(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 		if (!PageError(page))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 			return page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 		ntfs_unmap_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 		return ERR_PTR(-EIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 	return page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #ifdef NTFS_RW
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) extern void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #endif /* NTFS_RW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #endif /* _LINUX_NTFS_AOPS_H */