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

Function dfs_pcache_release

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

* @brief Release page cache entries to free up memory * * This function attempts to release a specified number of page cache entries. * If count is 0, it calculates the number of pages to release based on the * current cache size and GC stop level. It first tries to release from inactive * list, then from active list if needed. * * @param[in] count Number of pages to release. If 0, calculat

Source from the content-addressed store, hash-verified

150 * inactive list over active list.
151 */
152void dfs_pcache_release(size_t count)
153{
154 rt_list_t *node = RT_NULL;
155 struct dfs_aspace *aspace = RT_NULL;
156
157 dfs_pcache_lock();
158
159 if (count == 0)
160 {
161 count = rt_atomic_load(&(__pcache.pages_count)) - RT_PAGECACHE_COUNT * RT_PAGECACHE_GC_STOP_LEVEL / 100;
162 }
163
164 node = __pcache.list_inactive.next;
165 while (count && node != &__pcache.list_active)
166 {
167 aspace = rt_list_entry(node, struct dfs_aspace, cache_node);
168 node = node->next;
169 if (aspace)
170 {
171 count -= dfs_aspace_gc(aspace, count);
172 dfs_aspace_release(aspace);
173 }
174 }
175
176 node = __pcache.list_active.next;
177 while (count && node != &__pcache.list_inactive)
178 {
179 aspace = rt_list_entry(node, struct dfs_aspace, cache_node);
180 node = node->next;
181 if (aspace)
182 {
183 count -= dfs_aspace_gc(aspace, count);
184 }
185 }
186
187 dfs_pcache_unlock();
188}
189
190/**
191 * @brief Clean up page cache entries for a specific mount point

Callers 1

dfs_pcache_limit_checkFunction · 0.85

Calls 4

dfs_pcache_lockFunction · 0.85
dfs_aspace_gcFunction · 0.85
dfs_aspace_releaseFunction · 0.85
dfs_pcache_unlockFunction · 0.85

Tested by

no test coverage detected