From: Hou Tao <houtao1@huawei.com>
To: <linux-mtd@lists.infradead.org>
Cc: David Woodhouse <dwmw2@infradead.org>,
Richard Weinberger <richard@nod.at>,
<linux-kernel@vger.kernel.org>, <houtao1@huawei.com>
Subject: [PATCH 2/2] jffs2: handle INO_STATE_CLEARING in jffs2_do_read_inode()
Date: Wed, 20 Feb 2019 18:21:33 +0800 [thread overview]
Message-ID: <20190220102133.7878-3-houtao1@huawei.com> (raw)
In-Reply-To: <20190220102133.7878-1-houtao1@huawei.com>
For inode that fails to be created midway, GC procedure may
try to GC its dnode, and in the following case BUG() will be
triggered:
CPU 0 CPU 1
in jffs2_do_create() in jffs2_garbage_collect_pass()
jffs2_write_dnode succeed
// for dirent
jffs2_reserve_space fail
inum = ic->ino
nlink = ic->pino_nlink (> 0)
iget_failed
make_bad_inode
remove_inode_hash
iput
jffs2_evict_inode
jffs2_do_clear_inode
jffs2_set_inocache_state(INO_STATE_CLEARING)
jffs2_gc_fetch_inode
jffs2_iget
// a new inode is created because
// the old inode had been unhashed
iget_locked
jffs2_do_read_inode
jffs2_get_ino_cache
// assert BUG()
f->inocache->state = INO_STATE_CLEARING
Fix it by waiting for its state changes to INO_STATE_CHECKEDABSENT.
Fixes: 67e345d17ff8 ("[JFFS2] Prevent ino cache removal for inodes in use")
Cc: stable@vger.kernel.org
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
fs/jffs2/readinode.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 389ea53ea487..0bae0583106e 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -1328,6 +1328,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
case INO_STATE_CHECKING:
case INO_STATE_GC:
+ case INO_STATE_CLEARING:
/* If it's in either of these states, we need
to wait for whoever's got it to finish and
put it back. */
--
2.16.2.dirty
prev parent reply other threads:[~2019-02-20 10:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 10:21 [PATCH 0/2] jffs2: fixes for file creation failed halfway Hou Tao
2019-02-20 10:21 ` [PATCH 1/2] jffs2: reset pino_nlink to 0 when inode creation failed Hou Tao
2019-02-20 10:21 ` Hou Tao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190220102133.7878-3-houtao1@huawei.com \
--to=houtao1@huawei.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®