![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /* 0003 * index.h - Defines for NTFS kernel index handling. Part of the Linux-NTFS 0004 * project. 0005 * 0006 * Copyright (c) 2004 Anton Altaparmakov 0007 */ 0008 0009 #ifndef _LINUX_NTFS_INDEX_H 0010 #define _LINUX_NTFS_INDEX_H 0011 0012 #include <linux/fs.h> 0013 0014 #include "types.h" 0015 #include "layout.h" 0016 #include "inode.h" 0017 #include "attrib.h" 0018 #include "mft.h" 0019 #include "aops.h" 0020 0021 /** 0022 * @idx_ni: index inode containing the @entry described by this context 0023 * @entry: index entry (points into @ir or @ia) 0024 * @data: index entry data (points into @entry) 0025 * @data_len: length in bytes of @data 0026 * @is_in_root: 'true' if @entry is in @ir and 'false' if it is in @ia 0027 * @ir: index root if @is_in_root and NULL otherwise 0028 * @actx: attribute search context if @is_in_root and NULL otherwise 0029 * @base_ni: base inode if @is_in_root and NULL otherwise 0030 * @ia: index block if @is_in_root is 'false' and NULL otherwise 0031 * @page: page if @is_in_root is 'false' and NULL otherwise 0032 * 0033 * @idx_ni is the index inode this context belongs to. 0034 * 0035 * @entry is the index entry described by this context. @data and @data_len 0036 * are the index entry data and its length in bytes, respectively. @data 0037 * simply points into @entry. This is probably what the user is interested in. 0038 * 0039 * If @is_in_root is 'true', @entry is in the index root attribute @ir described 0040 * by the attribute search context @actx and the base inode @base_ni. @ia and 0041 * @page are NULL in this case. 0042 * 0043 * If @is_in_root is 'false', @entry is in the index allocation attribute and @ia 0044 * and @page point to the index allocation block and the mapped, locked page it 0045 * is in, respectively. @ir, @actx and @base_ni are NULL in this case. 0046 * 0047 * To obtain a context call ntfs_index_ctx_get(). 0048 * 0049 * We use this context to allow ntfs_index_lookup() to return the found index 0050 * @entry and its @data without having to allocate a buffer and copy the @entry 0051 * and/or its @data into it. 0052 * 0053 * When finished with the @entry and its @data, call ntfs_index_ctx_put() to 0054 * free the context and other associated resources. 0055 * 0056 * If the index entry was modified, call flush_dcache_index_entry_page() 0057 * immediately after the modification and either ntfs_index_entry_mark_dirty() 0058 * or ntfs_index_entry_write() before the call to ntfs_index_ctx_put() to 0059 * ensure that the changes are written to disk. 0060 */ 0061 typedef struct { 0062 ntfs_inode *idx_ni; 0063 INDEX_ENTRY *entry; 0064 void *data; 0065 u16 data_len; 0066 bool is_in_root; 0067 INDEX_ROOT *ir; 0068 ntfs_attr_search_ctx *actx; 0069 ntfs_inode *base_ni; 0070 INDEX_ALLOCATION *ia; 0071 struct page *page; 0072 } ntfs_index_context; 0073 0074 extern ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni); 0075 extern void ntfs_index_ctx_put(ntfs_index_context *ictx); 0076 0077 extern int ntfs_index_lookup(const void *key, const int key_len, 0078 ntfs_index_context *ictx); 0079 0080 #ifdef NTFS_RW 0081 0082 /** 0083 * ntfs_index_entry_flush_dcache_page - flush_dcache_page() for index entries 0084 * @ictx: ntfs index context describing the index entry 0085 * 0086 * Call flush_dcache_page() for the page in which an index entry resides. 0087 * 0088 * This must be called every time an index entry is modified, just after the 0089 * modification. 0090 * 0091 * If the index entry is in the index root attribute, simply flush the page 0092 * containing the mft record containing the index root attribute. 0093 * 0094 * If the index entry is in an index block belonging to the index allocation 0095 * attribute, simply flush the page cache page containing the index block. 0096 */ 0097 static inline void ntfs_index_entry_flush_dcache_page(ntfs_index_context *ictx) 0098 { 0099 if (ictx->is_in_root) 0100 flush_dcache_mft_record_page(ictx->actx->ntfs_ino); 0101 else 0102 flush_dcache_page(ictx->page); 0103 } 0104 0105 /** 0106 * ntfs_index_entry_mark_dirty - mark an index entry dirty 0107 * @ictx: ntfs index context describing the index entry 0108 * 0109 * Mark the index entry described by the index entry context @ictx dirty. 0110 * 0111 * If the index entry is in the index root attribute, simply mark the mft 0112 * record containing the index root attribute dirty. This ensures the mft 0113 * record, and hence the index root attribute, will be written out to disk 0114 * later. 0115 * 0116 * If the index entry is in an index block belonging to the index allocation 0117 * attribute, mark the buffers belonging to the index record as well as the 0118 * page cache page the index block is in dirty. This automatically marks the 0119 * VFS inode of the ntfs index inode to which the index entry belongs dirty, 0120 * too (I_DIRTY_PAGES) and this in turn ensures the page buffers, and hence the 0121 * dirty index block, will be written out to disk later. 0122 */ 0123 static inline void ntfs_index_entry_mark_dirty(ntfs_index_context *ictx) 0124 { 0125 if (ictx->is_in_root) 0126 mark_mft_record_dirty(ictx->actx->ntfs_ino); 0127 else 0128 mark_ntfs_record_dirty(ictx->page, 0129 (u8*)ictx->ia - (u8*)page_address(ictx->page)); 0130 } 0131 0132 #endif /* NTFS_RW */ 0133 0134 #endif /* _LINUX_NTFS_INDEX_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |