提交 ac0d083b 编写于 作者: C chenwei

fix: kernel crashed after rmdir the umounted folder

Close: I3NGBT
Change-Id: I70130c42061e51f5978b48befea66a5925386343
上级 c6e92124
...@@ -145,7 +145,6 @@ int VfsJffs2Bind(struct Mount *mnt, struct Vnode *blkDriver, const void *data) ...@@ -145,7 +145,6 @@ int VfsJffs2Bind(struct Mount *mnt, struct Vnode *blkDriver, const void *data)
g_jffs2PartList[partNo] = blkDriver; 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); LOS_MuxUnlock(&g_jffs2FsLock);
return 0; return 0;
...@@ -220,6 +219,9 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct ...@@ -220,6 +219,9 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct
Jffs2SetVtype(node, newVnode); Jffs2SetVtype(node, newVnode);
node->i_vnode = newVnode; node->i_vnode = newVnode;
if (&g_jffs2Vops != parentVnode->vop) {
LOS_Panic("jffs2 vop failed");
}
newVnode->vop = parentVnode->vop; newVnode->vop = parentVnode->vop;
newVnode->fop = parentVnode->fop; newVnode->fop = parentVnode->fop;
newVnode->data = node; newVnode->data = node;
...@@ -232,7 +234,6 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct ...@@ -232,7 +234,6 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct
(void)VfsHashInsert(newVnode, node->i_ino); (void)VfsHashInsert(newVnode, node->i_ino);
*ppVnode = newVnode; *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); LOS_MuxUnlock(&g_jffs2FsLock);
return 0; return 0;
...@@ -260,6 +261,9 @@ int VfsJffs2Create(struct Vnode *parentVnode, const char *path, int mode, struct ...@@ -260,6 +261,9 @@ int VfsJffs2Create(struct Vnode *parentVnode, const char *path, int mode, struct
newVnode->type = VNODE_TYPE_REG; newVnode->type = VNODE_TYPE_REG;
newNode->i_vnode = newVnode; newNode->i_vnode = newVnode;
newVnode->vop = parentVnode->vop; newVnode->vop = parentVnode->vop;
if (&g_jffs2Vops != parentVnode->vop) {
LOS_Panic("jffs2 vop failed");
}
newVnode->fop = parentVnode->fop; newVnode->fop = parentVnode->fop;
newVnode->data = newNode; newVnode->data = newNode;
newVnode->parent = parentVnode; newVnode->parent = parentVnode;
...@@ -271,7 +275,6 @@ int VfsJffs2Create(struct Vnode *parentVnode, const char *path, int mode, struct ...@@ -271,7 +275,6 @@ int VfsJffs2Create(struct Vnode *parentVnode, const char *path, int mode, struct
(void)VfsHashInsert(newVnode, newNode->i_ino); (void)VfsHashInsert(newVnode, newNode->i_ino);
*ppVnode = newVnode; *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); LOS_MuxUnlock(&g_jffs2FsLock);
return 0; return 0;
...@@ -531,6 +534,9 @@ int VfsJffs2Mkdir(struct Vnode *parentNode, const char *dirName, mode_t mode, st ...@@ -531,6 +534,9 @@ int VfsJffs2Mkdir(struct Vnode *parentNode, const char *dirName, mode_t mode, st
newVnode->type = VNODE_TYPE_DIR; newVnode->type = VNODE_TYPE_DIR;
node->i_vnode = newVnode; node->i_vnode = newVnode;
newVnode->vop = parentNode->vop; newVnode->vop = parentNode->vop;
if (&g_jffs2Vops != parentVnode->vop) {
LOS_Panic("jffs2 vop failed");
}
newVnode->fop = parentNode->fop; newVnode->fop = parentNode->fop;
newVnode->data = node; newVnode->data = node;
newVnode->parent = parentNode; newVnode->parent = parentNode;
...@@ -542,7 +548,6 @@ int VfsJffs2Mkdir(struct Vnode *parentNode, const char *dirName, mode_t mode, st ...@@ -542,7 +548,6 @@ int VfsJffs2Mkdir(struct Vnode *parentNode, const char *dirName, mode_t mode, st
*ppVnode = newVnode; *ppVnode = newVnode;
(void)VfsHashInsert(newVnode, node->i_ino); (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); LOS_MuxUnlock(&g_jffs2FsLock);
...@@ -597,8 +602,6 @@ int VfsJffs2Chattr(struct Vnode *pVnode, struct IATTR *attr) ...@@ -597,8 +602,6 @@ int VfsJffs2Chattr(struct Vnode *pVnode, struct IATTR *attr)
return ret; return ret;
} }
extern struct Vnode *g_parentOfCoveredVnode;
int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, char *path) int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, char *path)
{ {
int ret; int ret;
...@@ -609,10 +612,6 @@ int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, char *pa ...@@ -609,10 +612,6 @@ int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, char *pa
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER); 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, ret = jffs2_rmdir((struct jffs2_inode *)parentVnode->data, (struct jffs2_inode *)targetVnode->data,
(const unsigned char *)path); (const unsigned char *)path);
......
...@@ -44,9 +44,6 @@ static LosMux g_vnodeMux; ...@@ -44,9 +44,6 @@ static LosMux g_vnodeMux;
static struct Vnode *g_rootVnode = NULL; static struct Vnode *g_rootVnode = NULL;
static struct VnodeOps g_devfsOps; 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 ENTRY_TO_VNODE(ptr) LOS_DL_LIST_ENTRY(ptr, struct Vnode, actFreeEntry)
#define VNODE_LRU_COUNT 10 #define VNODE_LRU_COUNT 10
#define DEV_VNODE_MODE 0755 #define DEV_VNODE_MODE 0755
...@@ -92,8 +89,6 @@ static struct Vnode *GetFromFreeList(void) ...@@ -92,8 +89,6 @@ static struct Vnode *GetFromFreeList(void)
return vnode; return vnode;
} }
extern struct Vnode *g_parentOfCoveredVnode;
struct Vnode *VnodeReclaimLru(void) struct Vnode *VnodeReclaimLru(void)
{ {
struct Vnode *item = NULL; struct Vnode *item = NULL;
...@@ -164,7 +159,6 @@ int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode) ...@@ -164,7 +159,6 @@ int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode)
VnodeDrop(); VnodeDrop();
*newVnode = vnode; *newVnode = vnode;
PRINTK("%s-%d: vnode=%p userCount=%d inode=%p\n", __FUNCTION__, __LINE__, vnode, vnode->useCount, vnode->data);
return LOS_OK; return LOS_OK;
} }
...@@ -178,14 +172,6 @@ int VnodeFree(struct Vnode *vnode) ...@@ -178,14 +172,6 @@ int VnodeFree(struct Vnode *vnode)
struct PathCache *nextItem = NULL; struct PathCache *nextItem = NULL;
VnodeHold(); 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) { if (vnode->useCount > 0) {
VnodeDrop(); VnodeDrop();
return -EBUSY; return -EBUSY;
...@@ -204,7 +190,6 @@ int VnodeFree(struct Vnode *vnode) ...@@ -204,7 +190,6 @@ int VnodeFree(struct Vnode *vnode)
vnode->vop->Reclaim(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); 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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册