MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / dfs_page_remove

Function dfs_page_remove

components/dfs/dfs_v2/src/dfs_pcache.c:1258–1289  ·  view source on GitHub ↗

* @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

Source from the content-addressed store, hash-verified

1256 * @return 0 if the page was successfully removed, -1 if the page is still referenced
1257 */
1258static 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

Callers 2

dfs_aspace_gcFunction · 0.85
dfs_aspace_cleanFunction · 0.85

Calls 5

dfs_aspace_lockFunction · 0.85
rt_list_removeFunction · 0.85
_dfs_page_removeFunction · 0.85
dfs_page_releaseFunction · 0.85
dfs_aspace_unlockFunction · 0.85

Tested by

no test coverage detected