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

Function dfs_page_insert

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

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

Source from the content-addressed store, hash-verified

1214 * @return Always returns 0 indicating success
1215 */
1216static 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

Callers 1

dfs_aspace_load_pageFunction · 0.85

Calls 5

dfs_aspace_lockFunction · 0.85
rt_list_insert_beforeFunction · 0.85
_dfs_page_insertFunction · 0.85
dfs_page_inactiveFunction · 0.85
dfs_aspace_unlockFunction · 0.85

Tested by

no test coverage detected