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

Function dfs_page_release

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

* @brief Release a page from page cache when reference count reaches zero * * This function decrements the reference count of a page and performs cleanup * when the count reaches zero. It handles: * - Unmapping all virtual mappings of the page * - Writing back dirty pages to storage * - Freeing physical memory and page structure * * @param[in,out] page Pointer to the page structure to be r

Source from the content-addressed store, hash-verified

1053 * @param[in,out] page Pointer to the page structure to be released
1054 */
1055static void dfs_page_release(struct dfs_page *page)
1056{
1057 struct dfs_aspace *aspace = page->aspace;
1058
1059 dfs_aspace_lock(aspace);
1060
1061 rt_atomic_sub(&(page->ref_count), 1);
1062
1063 if (rt_atomic_load(&(page->ref_count)) == 0)
1064 {
1065 dfs_page_unmap(page);
1066
1067 if (page->is_dirty == 1 && aspace->vnode)
1068 {
1069 if (aspace->vnode->size < page->fpos + page->size)
1070 {
1071 page->len = aspace->vnode->size - page->fpos;
1072 }
1073 else
1074 {
1075 page->len = page->size;
1076 }
1077 if (aspace->ops->write)
1078 {
1079 aspace->ops->write(page);
1080 }
1081 page->is_dirty = 0;
1082 }
1083 RT_ASSERT(page->is_dirty == 0);
1084
1085 rt_pages_free(page->page, 0);
1086 page->page = RT_NULL;
1087 rt_free(page);
1088 }
1089
1090 dfs_aspace_unlock(aspace);
1091}
1092
1093/**
1094 * @brief Compare file positions for page alignment

Callers 8

dfs_pcache_threadFunction · 0.85
dfs_page_removeFunction · 0.85
dfs_page_lookupFunction · 0.85
dfs_aspace_readFunction · 0.85
dfs_aspace_writeFunction · 0.85
dfs_aspace_mmapFunction · 0.85
dfs_aspace_page_unmapFunction · 0.85
dfs_aspace_page_dirtyFunction · 0.85

Calls 6

dfs_aspace_lockFunction · 0.85
dfs_page_unmapFunction · 0.85
rt_pages_freeFunction · 0.85
rt_freeFunction · 0.85
dfs_aspace_unlockFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected