![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /** 0003 * aops.h - Defines for NTFS kernel address space operations and page cache 0004 * handling. Part of the Linux-NTFS project. 0005 * 0006 * Copyright (c) 2001-2004 Anton Altaparmakov 0007 * Copyright (c) 2002 Richard Russon 0008 */ 0009 0010 #ifndef _LINUX_NTFS_AOPS_H 0011 #define _LINUX_NTFS_AOPS_H 0012 0013 #include <linux/mm.h> 0014 #include <linux/highmem.h> 0015 #include <linux/pagemap.h> 0016 #include <linux/fs.h> 0017 0018 #include "inode.h" 0019 0020 /** 0021 * ntfs_unmap_page - release a page that was mapped using ntfs_map_page() 0022 * @page: the page to release 0023 * 0024 * Unpin, unmap and release a page that was obtained from ntfs_map_page(). 0025 */ 0026 static inline void ntfs_unmap_page(struct page *page) 0027 { 0028 kunmap(page); 0029 put_page(page); 0030 } 0031 0032 /** 0033 * ntfs_map_page - map a page into accessible memory, reading it if necessary 0034 * @mapping: address space for which to obtain the page 0035 * @index: index into the page cache for @mapping of the page to map 0036 * 0037 * Read a page from the page cache of the address space @mapping at position 0038 * @index, where @index is in units of PAGE_SIZE, and not in bytes. 0039 * 0040 * If the page is not in memory it is loaded from disk first using the 0041 * read_folio method defined in the address space operations of @mapping 0042 * and the page is added to the page cache of @mapping in the process. 0043 * 0044 * If the page belongs to an mst protected attribute and it is marked as such 0045 * in its ntfs inode (NInoMstProtected()) the mst fixups are applied but no 0046 * error checking is performed. This means the caller has to verify whether 0047 * the ntfs record(s) contained in the page are valid or not using one of the 0048 * ntfs_is_XXXX_record{,p}() macros, where XXXX is the record type you are 0049 * expecting to see. (For details of the macros, see fs/ntfs/layout.h.) 0050 * 0051 * If the page is in high memory it is mapped into memory directly addressible 0052 * by the kernel. 0053 * 0054 * Finally the page count is incremented, thus pinning the page into place. 0055 * 0056 * The above means that page_address(page) can be used on all pages obtained 0057 * with ntfs_map_page() to get the kernel virtual address of the page. 0058 * 0059 * When finished with the page, the caller has to call ntfs_unmap_page() to 0060 * unpin, unmap and release the page. 0061 * 0062 * Note this does not grant exclusive access. If such is desired, the caller 0063 * must provide it independently of the ntfs_{un}map_page() calls by using 0064 * a {rw_}semaphore or other means of serialization. A spin lock cannot be 0065 * used as ntfs_map_page() can block. 0066 * 0067 * The unlocked and uptodate page is returned on success or an encoded error 0068 * on failure. Caller has to test for error using the IS_ERR() macro on the 0069 * return value. If that evaluates to 'true', the negative error code can be 0070 * obtained using PTR_ERR() on the return value of ntfs_map_page(). 0071 */ 0072 static inline struct page *ntfs_map_page(struct address_space *mapping, 0073 unsigned long index) 0074 { 0075 struct page *page = read_mapping_page(mapping, index, NULL); 0076 0077 if (!IS_ERR(page)) 0078 kmap(page); 0079 return page; 0080 } 0081 0082 #ifdef NTFS_RW 0083 0084 extern void mark_ntfs_record_dirty(struct page *page, const unsigned int ofs); 0085 0086 #endif /* NTFS_RW */ 0087 0088 #endif /* _LINUX_NTFS_AOPS_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |