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

Function dfs_aspace_release

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

* @brief Release an address space when its reference count reaches 1 * * This function checks if the address space can be safely released by verifying: * - Reference count is 1 (only caller holds reference) * - No pages remain in the address space * If conditions are met, it removes the space from cache and frees all resources. * * @param[in] aspace Pointer to the address space to be releas

Source from the content-addressed store, hash-verified

790 * @return 0 on successful release, -1 if space cannot be released yet
791 */
792static int dfs_aspace_release(struct dfs_aspace *aspace)
793{
794 int ret = -1;
795
796 if (aspace)
797 {
798 dfs_pcache_lock();
799 dfs_aspace_lock(aspace);
800
801 if (rt_atomic_load(&aspace->ref_count) == 1 && aspace->pages_count == 0)
802 {
803 dfs_aspace_remove(aspace);
804 if (aspace->fullpath)
805 {
806 rt_free(aspace->fullpath);
807 }
808 if (aspace->pathname)
809 {
810 rt_free(aspace->pathname);
811 }
812 rt_mutex_detach(&aspace->lock);
813 rt_free(aspace);
814 ret = 0;
815 }
816 else
817 {
818 dfs_aspace_unlock(aspace);
819 }
820 dfs_pcache_unlock();
821 }
822
823 return ret;
824}
825
826/**
827 * @brief Dump address space page information for debugging

Callers 2

dfs_pcache_releaseFunction · 0.85
dfs_aspace_destroyFunction · 0.85

Calls 7

dfs_pcache_lockFunction · 0.85
dfs_aspace_lockFunction · 0.85
dfs_aspace_removeFunction · 0.85
rt_freeFunction · 0.85
rt_mutex_detachFunction · 0.85
dfs_aspace_unlockFunction · 0.85
dfs_pcache_unlockFunction · 0.85

Tested by

no test coverage detected