* @brief Remove a page from the address space's page cache * * This function safely removes a page from both the space and dirty lists of the address space. * It decrements the reference count and releases the page if it's the last reference. * * @param[in] page Pointer to the page structure to be removed * * @return 0 if the page was successfully removed, -1 if the page is still referenced
| 1256 | * @return 0 if the page was successfully removed, -1 if the page is still referenced |
| 1257 | */ |
| 1258 | static int dfs_page_remove(struct dfs_page *page) |
| 1259 | { |
| 1260 | int ret = -1; |
| 1261 | struct dfs_aspace *aspace = page->aspace; |
| 1262 | |
| 1263 | dfs_aspace_lock(aspace); |
| 1264 | |
| 1265 | if (rt_atomic_load(&(page->ref_count)) == 1) |
| 1266 | { |
| 1267 | if (page->space_node.next != RT_NULL) |
| 1268 | { |
| 1269 | rt_list_remove(&page->space_node); |
| 1270 | page->space_node.next = RT_NULL; |
| 1271 | aspace->pages_count--; |
| 1272 | _dfs_page_remove(aspace, page); |
| 1273 | } |
| 1274 | if (page->dirty_node.next != RT_NULL) |
| 1275 | { |
| 1276 | rt_list_remove(&page->dirty_node); |
| 1277 | page->dirty_node.next = RT_NULL; |
| 1278 | } |
| 1279 | |
| 1280 | rt_atomic_sub(&(__pcache.pages_count), 1); |
| 1281 | |
| 1282 | dfs_page_release(page); |
| 1283 | ret = 0; |
| 1284 | } |
| 1285 | |
| 1286 | dfs_aspace_unlock(aspace); |
| 1287 | |
| 1288 | return ret; |
| 1289 | } |
| 1290 | |
| 1291 | /** |
| 1292 | * @brief Move a page to active list |
no test coverage detected