commit
58e5632714
|
@ -121,5 +121,6 @@ void ChangeRoot(struct Vnode *newRoot);
|
||||||
BOOL VnodeInUseIter(const struct Mount *mount);
|
BOOL VnodeInUseIter(const struct Mount *mount);
|
||||||
struct Vnode *VnodeGetRoot(void);
|
struct Vnode *VnodeGetRoot(void);
|
||||||
void VnodeMemoryDump(void);
|
void VnodeMemoryDump(void);
|
||||||
|
int VnodeDestory(struct Vnode *vnode);
|
||||||
|
|
||||||
#endif /* !_VNODE_H_ */
|
#endif /* !_VNODE_H_ */
|
||||||
|
|
|
@ -168,29 +168,21 @@ int VnodeFree(struct Vnode *vnode)
|
||||||
if (vnode == NULL) {
|
if (vnode == NULL) {
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
struct PathCache *item = NULL;
|
|
||||||
struct PathCache *nextItem = NULL;
|
|
||||||
|
|
||||||
VnodeHold();
|
VnodeHold();
|
||||||
if (vnode->useCount > 0) {
|
if (vnode->useCount > 0) {
|
||||||
VnodeDrop();
|
VnodeDrop();
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &vnode->childPathCaches, struct PathCache, childEntry) {
|
|
||||||
PathCacheFree(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &vnode->parentPathCaches, struct PathCache, parentEntry) {
|
|
||||||
PathCacheFree(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
VnodePathCacheFree(vnode);
|
||||||
LOS_ListDelete(&(vnode->hashEntry));
|
LOS_ListDelete(&(vnode->hashEntry));
|
||||||
|
LOS_ListDelete(&vnode->actFreeEntry);
|
||||||
|
|
||||||
if (vnode->vop->Reclaim) {
|
if (vnode->vop->Reclaim) {
|
||||||
vnode->vop->Reclaim(vnode);
|
vnode->vop->Reclaim(vnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOS_ListDelete(&vnode->actFreeEntry);
|
|
||||||
memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
|
memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
|
||||||
LOS_ListAdd(&g_vnodeFreeList, &vnode->actFreeEntry);
|
LOS_ListAdd(&g_vnodeFreeList, &vnode->actFreeEntry);
|
||||||
|
|
||||||
|
@ -630,3 +622,27 @@ void VnodeMemoryDump(void)
|
||||||
PRINTK("Vnode number = %d\n", vnodeCount);
|
PRINTK("Vnode number = %d\n", vnodeCount);
|
||||||
PRINTK("Vnode memory size = %d(B)\n", vnodeCount * sizeof(struct Vnode));
|
PRINTK("Vnode memory size = %d(B)\n", vnodeCount * sizeof(struct Vnode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VnodeDestory(struct Vnode *vnode)
|
||||||
|
{
|
||||||
|
if (vnode == NULL || vnode->vop != &g_devfsOps) {
|
||||||
|
/* destory only support dev vnode */
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
VnodeHold();
|
||||||
|
if (vnode->useCount > 0) {
|
||||||
|
VnodeDrop();
|
||||||
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
VnodePathCacheFree(vnode);
|
||||||
|
LOS_ListDelete(&(vnode->hashEntry));
|
||||||
|
LOS_ListDelete(&vnode->actFreeEntry);
|
||||||
|
|
||||||
|
free(vnode->data);
|
||||||
|
free(vnode);
|
||||||
|
VnodeDrop();
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue