* @brief Insert a page into the address space's page cache * * This function inserts a page into the active list of the address space's page cache. * It maintains the page count and performs eviction if the cache exceeds its capacity. * * @param[in] page Pointer to the page structure to be inserted * * @return Always returns 0 indicating success */
| 1214 | * @return Always returns 0 indicating success |
| 1215 | */ |
| 1216 | static int dfs_page_insert(struct dfs_page *page) |
| 1217 | { |
| 1218 | struct dfs_aspace *aspace = page->aspace; |
| 1219 | |
| 1220 | dfs_aspace_lock(aspace); |
| 1221 | |
| 1222 | rt_list_insert_before(&aspace->list_inactive, &page->space_node); |
| 1223 | aspace->pages_count ++; |
| 1224 | |
| 1225 | if (_dfs_page_insert(aspace, page)) |
| 1226 | { |
| 1227 | RT_ASSERT(0); |
| 1228 | } |
| 1229 | |
| 1230 | if (aspace->pages_count > RT_PAGECACHE_ASPACE_COUNT) |
| 1231 | { |
| 1232 | rt_list_t *next = aspace->list_active.next; |
| 1233 | |
| 1234 | if (next != &aspace->list_inactive) |
| 1235 | { |
| 1236 | struct dfs_page *tmp = rt_list_entry(next, struct dfs_page, space_node); |
| 1237 | dfs_page_inactive(tmp); |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | rt_atomic_add(&(__pcache.pages_count), 1); |
| 1242 | |
| 1243 | dfs_aspace_unlock(aspace); |
| 1244 | |
| 1245 | return 0; |
| 1246 | } |
| 1247 | |
| 1248 | /** |
| 1249 | * @brief Remove a page from the address space's page cache |
no test coverage detected