Changeset 23 for trunk/kernel/mm/mapper.h
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/mapper.h
r18 r23 39 39 /******************************************************************************************* 40 40 * The mapper implements the kernel cache for a given file or directory. 41 * There is one mapper per file . It is implemented as a three levels radix tree,41 * There is one mapper per file/dir. It is implemented as a three levels radix tree, 42 42 * entirely stored in the same cluster as the inode representing the file/dir. 43 43 * - The fast retrieval key is the page index in the file. … … 49 49 * - The mapper is protected by a blocking "rwlock", to support several simultaneous 50 50 * readers, and only one writer. This lock implement a busy waiting policy. 51 * - The two functions mapper_sync_page() and mapper_updt_page() define the generic API52 * used to move pages to or from the relevant file system on IOC device.53 * - the mapper_move fragments() function is used to move data to or from adistributed54 * user buffer .51 * - The two functions vfs_move_page_to_mapper() and vfs_move_page_from_mapper() define 52 * the generic API used to move pages to or from the relevant file system on IOC device. 53 * - the mapper_move() function is used to move data to or from a, possibly distributed 54 * user buffer in user space. 55 55 * - The mapper_get_page() function that return a page descriptor pointer from a page 56 56 * index in file is in charge of handling the miss on the mapper cache. 57 57 * - In the present implementation the cache size increases on demand, and the 58 * allocated memory is only released when the mapper is destroyed.58 * allocated memory is only released when the mapper/inode is destroyed. 59 59 ******************************************************************************************/ 60 60 … … 66 66 typedef struct mapper_s 67 67 { 68 struct vfs_inode_s * inode; /*! owner file inode*/68 struct vfs_inode_s * inode; /*! owner inode */ 69 69 grdxt_t radix; /*! pages cache implemented as a radix tree */ 70 70 rwlock_t lock; /*! several readers / only one writer */ … … 89 89 uint32_t size; /*! number of bytes in fragment */ 90 90 cxy_t buf_cxy; /*! user buffer cluster identifier */ 91 uint8_t* buf_ptr; /*! local pointer on first byte in user buffer */91 void * buf_ptr; /*! local pointer on first byte in user buffer */ 92 92 } 93 93 fragment_t; … … 114 114 115 115 /******************************************************************************************* 116 * This function moves all fragments covering a distributed user buffer between 117 * a mapper (associated to a local inode), and the user buffer. 118 * [See the fragment definition in the mapper.h file] 119 * It must be executed by a thread running in the cluster containing the mapper. 120 * The lock protecting the mapper must have been taken in WRITE_MODE or READ_MODE 121 * by the caller thread, depending on the transfer direction. 116 * This function move data between a kernel mapper and an user buffer. 117 * It must be called by a thread running in the cluster containing the mapper. 118 * It split the data in fragments : one fragment is a set of contiguous bytes 119 * stored in the same mapper page. 120 * It uses "hal_uspace" accesses to move fragments to/from the user buffer. 122 121 * In case of write, the dirty bit is set for all pages written in the mapper. 123 122 * The offset in the file descriptor is not modified by this function. 124 * Implementation note:125 * For each fragment, this function makes ONE hal_remote_memcpy() when the fragment is126 * fully contained in one single page of the mapper. It makes TWO hal_remote_memcpy()127 * if the fragment spread on two contiguous pages in the mapper.128 123 ******************************************************************************************* 129 * @ mapper : local pointer on the local mapper. 130 * @ to_buffer : mapper to buffer if true / buffer to mapper if false. 131 * @ nb_frags : number of fragments covering the user buffer (one per page). 132 * @ frags_xp : extended pointer on array of fragments. 133 FAT * returns O if success / returns EINVAL if error. 124 * @ mapper : extended pointer on local mapper. 125 * @ to_buffer : move data from mapper to buffer if true. 126 * @ file_offset : first byte to move in file. 127 * @ buffer : buffer address in user space. 128 * @ size : number of bytes to move. 129 * returns O if success / returns EINVAL if error. 134 130 ******************************************************************************************/ 135 error_t mapper_move _fragments( mapper_t * mapper,136 137 uint32_t nb_frags,138 xptr_t frags_xp );139 131 error_t mapper_move( mapper_t * mapper, 132 bool_t to_buffer, 133 uint32_t file_offset, 134 void * buffer, 135 uint32_t size ); 140 136 141 137 /******************************************************************************************* … … 146 142 ******************************************************************************************* 147 143 * @ mapper : local pointer on the mapper. 148 * @ index : page index in file149 144 * @ page : pointer on page to remove. 150 145 * @ return 0 if success / return EIO if a dirty page cannot be copied to FS. 151 146 ******************************************************************************************/ 152 147 error_t mapper_release_page( mapper_t * mapper, 153 uint32_t index,154 148 struct page_s * page ); 155 149 … … 167 161 uint32_t index ); 168 162 169 /******************************************************************************************* 170 * This function makes an I/O operation to move one page from FS to mapper. 171 * Depending on the file system type, it calls the proper, FS specific function. 172 * It must be executed by a thread running in the cluster containing the mapper. 173 ******************************************************************************************* 174 * @ mapper : local pointer on the mapper. 175 * @ index : page index in file. 176 * @ page : local pointer on the page descriptor in mapper. 177 * @ returns 0 if success / return EINVAL if it cannot access the device. 178 ******************************************************************************************/ 179 error_t mapper_updt_page( mapper_t * mapper, 180 uint32_t index, 181 struct page_s * page ); 182 183 /******************************************************************************************* 184 * This function makes an I/0 operation to move one page from mapper to FS. 185 * Depending on the file system type, it calls the proper, FS specific function. 186 * It must be executed by a thread running in the cluster containing the mapper. 187 * It does nothing if the page is not dirty. If the page is dirty, it takes 188 * the page lock before launching the IO operation, clear the page dirty bit, 189 * and remove the page from the PPM dirty list. It does nothing if the page is not dirty. 190 ******************************************************************************************* 191 * @ mapper : local pointer on the mapper. 192 * @ index : page index in file. 193 * @ page : local pointer on the page descriptor in mapper. 194 * @ returns 0 if success / return EINVAL if it cannot access the device. 195 ******************************************************************************************/ 196 error_t mapper_sync_page( mapper_t * mapper, 197 uint32_t index, 198 struct page_s * page ); 163 199 164 200 165 #endif /* _MAPPER_H_ */
Note: See TracChangeset
for help on using the changeset viewer.