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

Function dfs_vnode_unref

components/dfs/dfs_v2/src/dfs_vnode.c:139–180  ·  view source on GitHub ↗

* @brief Decrease reference count of a virtual node (vnode) and potentially free it * * @param[in,out] vnode Pointer to the vnode to be unreferenced */

Source from the content-addressed store, hash-verified

137 * @param[in,out] vnode Pointer to the vnode to be unreferenced
138 */
139void dfs_vnode_unref(struct dfs_vnode *vnode)
140{
141 rt_err_t ret = RT_EOK;
142
143 if (vnode)
144 {
145 ret = dfs_file_lock();
146 if (ret == RT_EOK)
147 {
148 rt_atomic_sub(&(vnode->ref_count), 1);
149 DLOG(note, "vnode", "vnode ref_count=%d", rt_atomic_load(&(vnode->ref_count)));
150#ifdef RT_USING_PAGECACHE
151 if (vnode->aspace)
152 {
153 dfs_aspace_destroy(vnode->aspace);
154 }
155#endif
156 if (rt_atomic_load(&(vnode->ref_count)) == 0)
157 {
158 LOG_I("free a vnode: %p", vnode);
159 DLOG(msg, "vnode", "vnode", DLOG_MSG, "free vnode, ref_count=0");
160
161 if (vnode->mnt)
162 {
163 DLOG(msg, "vnode", vnode->mnt->fs_ops->name, DLOG_MSG, "fs_ops->free_vnode");
164 vnode->mnt->fs_ops->free_vnode(vnode);
165 }
166
167 dfs_file_unlock();
168
169 rt_free(vnode);
170 }
171 else
172 {
173 dfs_file_unlock();
174 DLOG(note, "vnode", "vnode ref_count=%d", rt_atomic_load(&(vnode->ref_count)));
175 }
176 }
177 }
178
179 return;
180}

Callers 1

dfs_dentry_unrefFunction · 0.85

Calls 4

dfs_aspace_destroyFunction · 0.85
rt_freeFunction · 0.85
dfs_file_lockFunction · 0.70
dfs_file_unlockFunction · 0.70

Tested by

no test coverage detected