* @brief Destroy an address space and release its resources * * This function decrements the reference count of the address space and marks it as inactive. * If the reference count reaches 1 and there are no pages left, it will be fully released. * * @param[in] aspace Pointer to the address space to be destroyed * * @return 0 on successful release, -EINVAL if aspace is NULL */
| 756 | * @return 0 on successful release, -EINVAL if aspace is NULL |
| 757 | */ |
| 758 | int dfs_aspace_destroy(struct dfs_aspace *aspace) |
| 759 | { |
| 760 | int ret = -EINVAL; |
| 761 | |
| 762 | if (aspace) |
| 763 | { |
| 764 | dfs_pcache_lock(); |
| 765 | dfs_aspace_lock(aspace); |
| 766 | rt_atomic_sub(&aspace->ref_count, 1); |
| 767 | RT_ASSERT(rt_atomic_load(&aspace->ref_count) > 0); |
| 768 | dfs_aspace_inactive(aspace); |
| 769 | aspace->vnode = RT_NULL; |
| 770 | if (dfs_aspace_release(aspace) != 0) |
| 771 | { |
| 772 | dfs_aspace_unlock(aspace); |
| 773 | } |
| 774 | dfs_pcache_unlock(); |
| 775 | } |
| 776 | |
| 777 | return ret; |
| 778 | } |
| 779 | |
| 780 | /** |
| 781 | * @brief Release an address space when its reference count reaches 1 |
no test coverage detected