* @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
| 790 | * @return 0 on successful release, -1 if space cannot be released yet |
| 791 | */ |
| 792 | static 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 |
no test coverage detected