Hi folks,

I found a bug which is guessed to be the cause of file system
corruption after mount.  The following patch is the bugfix.

If you have experienced the problem, please try this patch.

I made it for the mainline kernel; if you apply it to the standalone
module, do as follows:

 $ cd nilfs2-module/fs
 $ patch -p3 < path-to-the-patch

I will send it upstream after some tests.

Thanks,
Ryusuke Konishi
--
From: Ryusuke Konishi <[email protected]>

nilfs2: fix missing zero-fill initialization of btree node cache

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:
<[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), thus the
corruption is induced.

I found a missing zero-fill initialization of btree node caches was
the root cause.  This corrects the bug.

Signed-off-by: Ryusuke Konishi <[email protected]>
---
 fs/nilfs2/btnode.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index 6a2711f..5941958 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -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);
_______________________________________________
users mailing list
[email protected]
https://www.nilfs.org/mailman/listinfo/users

Reply via email to