From 0f8d5789470567f92fb303db68f93ba15809bd81 Mon Sep 17 00:00:00 2001 From: chenwei Date: Fri, 16 Apr 2021 11:04:39 +0800 Subject: [PATCH] add debug code to fix bug: kernel crashed after rmdir the umounted folder Change-Id: I074b2fd47b57a5b991fb99e458eb58694e5efe09 --- fs/jffs2/dir.c | 3 +++ fs/jffs2/fs.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index 80069e3..6648a6a 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c @@ -243,6 +243,9 @@ int jffs2_rmdir (struct jffs2_inode *dir_i, struct jffs2_inode *d_inode, const u int ret; uint32_t now = Jffs2CurSec(); + if (c == NULL) { + PRINT_ERR("%s-%d: sb_info null. sb=%p, inode=%p, vnode=%p\n", __FUNCTION__, __LINE__, dir_i->i_sb, dir_i, dir_i->i_vnode); + } for (fd = f->dents ; fd; fd = fd->next) { if (fd->ino) { PRINT_ERR("%s-%d: ret=%d\n", __FUNCTION__, __LINE__, ENOTEMPTY); diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index d25e6f8..d740d8c 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -262,6 +262,8 @@ struct jffs2_inode *jffs2_iget(struct super_block *sb, uint32_t ino) return inode; } +extern int g_coveredVnodeTop; +extern struct Vnode *g_coveredVnodeList[100]; // ------------------------------------------------------------------------- // Decrement the reference count on an inode. If this makes the ref count @@ -275,6 +277,12 @@ int jffs2_iput(struct jffs2_inode *i) // and gc.c jffs2_garbage_collect_pass struct jffs2_inode_info *f = NULL; + for (int p = 0; p < g_coveredVnodeTop; p++) { + if (i->i_vnode == g_coveredVnodeList[p]) { + PRINT_ERR("%s-%d: jffs2_iput mounted vnode. vnode=%p, inode=%p, i->i_nlink=%d\n", __FUNCTION__, __LINE__, i->i_vnode, i, i->i_nlink); + } + } + Jffs2NodeLock(); if (!i || i->i_nlink) { // and let it fault... -- Gitee