nilfs2: fix missing zero-fill initialization of btree node cache
authorRyusuke Konishi <[email protected]>
Sun, 27 Sep 2009 16:46:11 +0000 (01:46 +0900)
committerRyusuke Konishi <[email protected]>
Tue, 29 Sep 2009 11:12:56 +0000 (20:12 +0900)
This will fix file system corruption which infrequently happens after
mount.  The problem was reported from users with the title "[NILFS
users] Fail to mount NILFS." (Message-ID:
<200908211918[email protected]>), and so forth.  I've also
experienced the corruption multiple times on kernel 2.6.30 and 2.6.31.

The problem turned out to be caused due to discordance between
mapping->nrpages of a btree node cache and the actual number of pages
hung on the cache; if the mapping->nrpages becomes zero even as it has
pages, truncate_inode_pages() returns without doing anything.  Usually
this is harmless except it may cause page leak, but garbage collection
fairly infrequently sees a stale page remained in the btree node cache
of DAT (i.e. disk address translation file of nilfs), and induces the
corruption.

I identified a missing initialization in btree node caches was the
root cause.  This corrects the bug.

I've tested this for kernel 2.6.30 and 2.6.31.

Reported-by: Yuri Chislov <[email protected]>
Signed-off-by: Ryusuke Konishi <[email protected]>
Cc: stable <[email protected]>
fs/nilfs2/btnode.c

index 6a2711f4c32122e9900c209f0521ec6b5f6d59f3..5941958f1e47325e9497cef3101065f3efd73f46 100644 (file)
@@ -36,6 +36,7 @@
 
 void nilfs_btnode_cache_init_once(struct address_space *btnc)
 {
+       memset(btnc, 0, sizeof(*btnc));
        INIT_RADIX_TREE(&btnc->page_tree, GFP_ATOMIC);
        spin_lock_init(&btnc->tree_lock);
        INIT_LIST_HEAD(&btnc->private_list);