提交 89ed41a0 编写于 作者: O openharmony_ci 提交者: Gitee

!173 [Desc] fix bug: kernel crashed after rmdir the umounted folder

Merge pull request !173 from LeonChan/lc-master
......@@ -145,7 +145,6 @@ int VfsJffs2Bind(struct Mount *mnt, struct Vnode *blkDriver, const void *data)
g_jffs2PartList[partNo] = blkDriver;
PRINTK("%s-%d: vnode=%p, inode=%p, i_nlink=%d\n", __FUNCTION__, __LINE__, pv, rootNode, rootNode->i_nlink);
LOS_MuxUnlock(&g_jffs2FsLock);
return 0;
......@@ -220,6 +219,9 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct
Jffs2SetVtype(node, newVnode);
node->i_vnode = newVnode;
if (&g_jffs2Vops != parentVnode->vop) {
LOS_Panic("jffs2 vop failed");
}
newVnode->vop = parentVnode->vop;
newVnode->fop = parentVnode->fop;
newVnode->data = node;
......@@ -232,7 +234,6 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct
(void)VfsHashInsert(newVnode, node->i_ino);
*ppVnode = newVnode;
PRINTK("%s-%d: vnode=%p, inode=%p, i_nlink=%d path=%s\n", __FUNCTION__, __LINE__, newVnode, node, node->i_nlink, path);
LOS_MuxUnlock(&g_jffs2FsLock);
return 0;
......@@ -260,6 +261,9 @@ int VfsJffs2Create(struct Vnode *parentVnode, const char *path, int mode, struct
newVnode->type = VNODE_TYPE_REG;
newNode->i_vnode = newVnode;
newVnode->vop = parentVnode->vop;
if (&g_jffs2Vops != parentVnode->vop) {
LOS_Panic("jffs2 vop failed");
}
newVnode->fop = parentVnode->fop;
newVnode->data = newNode;
newVnode->parent = parentVnode;
......@@ -271,7 +275,6 @@ int VfsJffs2Create(struct Vnode *parentVnode, const char *path, int mode, struct
(void)VfsHashInsert(newVnode, newNode->i_ino);
*ppVnode = newVnode;
PRINTK("%s-%d: vnode=%p, inode=%p, i_nlink=%d path=%s\n", __FUNCTION__, __LINE__, newVnode, newNode, newNode->i_nlink, path);
LOS_MuxUnlock(&g_jffs2FsLock);
return 0;
......@@ -531,6 +534,9 @@ int VfsJffs2Mkdir(struct Vnode *parentNode, const char *dirName, mode_t mode, st
newVnode->type = VNODE_TYPE_DIR;
node->i_vnode = newVnode;
newVnode->vop = parentNode->vop;
if (&g_jffs2Vops != parentNode->vop) {
LOS_Panic("jffs2 vop failed");
}
newVnode->fop = parentNode->fop;
newVnode->data = node;
newVnode->parent = parentNode;
......@@ -542,7 +548,6 @@ int VfsJffs2Mkdir(struct Vnode *parentNode, const char *dirName, mode_t mode, st
*ppVnode = newVnode;
(void)VfsHashInsert(newVnode, node->i_ino);
PRINTK("%s-%d: vnode=%p, inode=%p, i_nlink=%d path=%s\n", __FUNCTION__, __LINE__, newVnode, node, node->i_nlink, dirName);
LOS_MuxUnlock(&g_jffs2FsLock);
......@@ -597,8 +602,6 @@ int VfsJffs2Chattr(struct Vnode *pVnode, struct IATTR *attr)
return ret;
}
extern struct Vnode *g_parentOfCoveredVnode;
int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, char *path)
{
int ret;
......@@ -609,10 +612,6 @@ int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, char *pa
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
if (parentVnode->data == NULL) {
PRINT_ERR("%s-%d: rmdir parent of mounted vnode. vnode=%p userCount=%d inode=%p\n", __FUNCTION__, __LINE__, parentVnode, parentVnode->useCount, parentVnode->data);
PRINT_ERR("%s-%d: global rmdir parent of mounted vnode. vnode=%p userCount=%d inode=%p\n", __FUNCTION__, __LINE__, g_parentOfCoveredVnode, g_parentOfCoveredVnode->useCount, g_parentOfCoveredVnode->data);
}
ret = jffs2_rmdir((struct jffs2_inode *)parentVnode->data, (struct jffs2_inode *)targetVnode->data,
(const unsigned char *)path);
......
......@@ -44,9 +44,6 @@ static LosMux g_vnodeMux;
static struct Vnode *g_rootVnode = NULL;
static struct VnodeOps g_devfsOps;
extern int g_coveredVnodeTop;
extern struct Vnode *g_coveredVnodeList[100];
#define ENTRY_TO_VNODE(ptr) LOS_DL_LIST_ENTRY(ptr, struct Vnode, actFreeEntry)
#define VNODE_LRU_COUNT 10
#define DEV_VNODE_MODE 0755
......@@ -93,8 +90,6 @@ static struct Vnode *GetFromFreeList(void)
return vnode;
}
extern struct Vnode *g_parentOfCoveredVnode;
struct Vnode *VnodeReclaimLru(void)
{
struct Vnode *item = NULL;
......@@ -165,7 +160,6 @@ int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode)
VnodeDrop();
*newVnode = vnode;
PRINTK("%s-%d: vnode=%p userCount=%d inode=%p\n", __FUNCTION__, __LINE__, vnode, vnode->useCount, vnode->data);
return LOS_OK;
}
......@@ -179,14 +173,6 @@ int VnodeFree(struct Vnode *vnode)
struct PathCache *nextItem = NULL;
VnodeHold();
for (int i = 0; i < g_coveredVnodeTop; i++) {
if (vnode == g_coveredVnodeList[i]) {
PRINTK("%s-%d: reclaim mounted vnode. vnode=%p userCount=%d inode=%p\n", __FUNCTION__, __LINE__, vnode, vnode->useCount, vnode->data);
}
}
if (g_parentOfCoveredVnode == vnode) {
PRINTK("%s-%d: reclaim parent of mounted vnode. vnode=%p userCount=%d inode=%p\n", __FUNCTION__, __LINE__, vnode, vnode->useCount, vnode->data);
}
if (vnode->useCount > 0) {
VnodeDrop();
return -EBUSY;
......@@ -205,7 +191,6 @@ int VnodeFree(struct Vnode *vnode)
vnode->vop->Reclaim(vnode);
}
PRINTK("%s-%d: vnode=%p userCount=%d inode=%p\n", __FUNCTION__, __LINE__, vnode, vnode->useCount, vnode->data);
LOS_ListDelete(&vnode->actFreeEntry);
memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
LOS_ListAdd(&g_vnodeFreeList, &vnode->actFreeEntry);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册