* @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
| 150 | * inactive list over active list. |
| 151 | */ |
| 152 | void 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 |
no test coverage detected