Commit d96fb997 authored by David Woodhouse's avatar David Woodhouse

[JFFS2] Fix race in post-mount node checking

For a while now, we've postponed CRC-checking of data nodes to be done
by the GC thread, instead of being done while the user is waiting for
mount to finish. The GC thread would iterate through all the inodes on
the system and check each of their data nodes. It would skip over inodes
which had already been used or were already being read in by
read_inode(), because their data nodes would have been examined anyway.

However, we could sometimes reach the end of the for-each-inode loop and
still have some unchecked space left, if an inode we'd skipped was
_still_ in the process of being read. This fixes that race by actually
waiting for read_inode() to finish rather than just moving on.

Thanks to Ladislav Michl for coming up with a reproducible test case and
helping to track it down.
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent fb6a82c9
...@@ -181,6 +181,10 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -181,6 +181,10 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
and trigger the BUG() above while we haven't yet and trigger the BUG() above while we haven't yet
finished checking all its nodes */ finished checking all its nodes */
D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino));
/* We need to come back again for the _same_ inode. We've
made no progress in this case, but that should be OK */
c->checked_ino--;
up(&c->alloc_sem); up(&c->alloc_sem);
sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment