Re: Segment magic number invalid

2010-05-19 Thread Ryusuke Konishi
On Wed, 19 May 2010 22:49:30 +0900, Jiro SEKIBA wrote:
   Actually, I now wonder what could have gone wrong in my case. I wasn't
   doing any disk intensive task and the machine wasn't suspended to ram
   during the course.
  
  This problem can happen if the block device doesn't support write
  barrier properly.  Unfortunately, such devices are not uncommon even
  now.
  
  I feel we should do something for it.
 
 How abou updating one of super blocks when super block update needed?
 
 I'm hoping that even write barrier is not supported, back up super block
 likely points valid older log.
 
 In case latest super block, which has greater CP, points invalid log,
 try to search log from the other super block that has older log and
 roll forwad the log until it finds newer super root.
 
 Futher more, because each super block is less frequently updated,
 it may address low-end consumer flash super block hot-spot issue.

Seems a nice solution.

And it looks feasible now since the patch titled nilfs2: use
checkpoint number instead of timestamp to select super block made it
easy.

The secondary super block is written to disk along with the primary
one, but less frequently.  So it can be implemented by changing spec
of the dupsb argument of nilfs_commit_super to other one from both
(dupsb).

Can you make draft patches?

Thanks,
Ryusuke Konishi
--
To unsubscribe from this list: send the line unsubscribe linux-nilfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Segment magic number invalid

2010-05-15 Thread Ryusuke Konishi
Hi,
On Fri, 14 May 2010 20:24:02 -0400, Paul L wrote:
 I have my home directory mounted as a nilfs2 partition. Today what
 happened was that first I noticed google-chrome reporting it cannot
 load user profile, I initially thought it was a google-chrome error.
 At the time I was still able to view and modify my home directory. But
 then after rebooting the system, my home partition no longer mounts.
 I'm using nilfs-2.0.19 and nilfs-utils-2.0.18 with Linux kernel
 2.6.28.
 
 Here is the error message from dmesg (after turning on debugging
 message for nilfs2):
 
 NILFS nilfs_fill_super: start(silent=0)
 NILFS(recovery) nilfs_search_super_root: looking segment
 (seg_start=1607680, seg_end=1609727, segnum=785, seg_seq=307637)
 NILFS(recovery) load_segment_summary: checking segment
 (pseg_start=1608334, full_check=0)
 NILFS(recovery) load_segment_summary: done (ret=3)
 NILFS(recovery) nilfs_search_super_root: strayed: scan_newer=0, ret=3
 NILFS warning: Segment magic number invalid
 NILFS: error searching super root.
 NILFS nilfs_fill_super: aborted
 NILFS put_nilfs: the_nilfs on bdev mmcblk0p1 was freed
 
 I then dumped the first and last (backup) copy of the nilfs2 super
 block, they are identical, and given below:
 
 0400   02 00 00 00 00 00 34 34  00 01 00 00 A1 6A E9 71  ..44.j.q
 0410   A3 F1 DD BE 02 00 00 00  AF 07 00 00 00 00 00 00  
 0420   00 E0 BF D7 03 00 00 00  01 00 00 00 00 00 00 00  
 0430   00 08 00 00 05 00 00 00  7C 3D 0A 00 00 00 00 00  |=..
 0440   8E 8A 18 00 00 00 00 00  B5 B1 04 00 00 00 00 00  
 0450   00 B8 23 00 00 00 00 00  B9 AF F3 4A 00 00 00 00  ..#J
 0460   D9 E1 D6 4B 00 00 00 00  49 8F ED 4B 00 00 00 00  ...KI..K
 0470   37 00 32 00 03 00 01 00  B9 AF F3 4A 00 00 00 00  
 7.2Jelp
 0480   00 4E ED 00 00 00 00 00  00 00 00 00 0B 00 00 00  .N..
 0490   80 00 20 00 C0 00 10 00  13 1C FC 11 D7 43 4C 09  .. ..CL.
 04A0   81 64 93 0A F4 54 CF 5E  48 4F 4D 45 00 00 00 00  .d...T.^HOME
 
 
 I wonder if there is a fsck tool to help me recover the file system.
 Any help is greatly appreciated!

 PS: last time I had a different problem of losing partition info, and
 later successfully recovered with the help from people on the list. So
 thanks! Now I'm actually backing up my files every two weeks, but
 it'll still be great if it can recover and even better if we can trace
 the problem.

Your filesystem seems to have lost the latest log according to the
report.

The attached patch may help to recover it.  It is revised scan tool
for nilfs-utils-2.0.18.

After compiling the tool, you can use it like:

 # cd nilfs-utils-2.0.18
 # sbin/fsck/fsck0 device

The tool will confirm whether to update super blocks if it finds the
latest log.

You may need to do

 $ aclocal  autoheader  libtoolize -c --foce  automake -a -c  autoconf
 $ ./configure

before build the tool.

With regards,
Ryusuke Konishi
From b1a403ed4a7cb6987052729075255d5d893bebdb Mon Sep 17 00:00:00 2001
From: Ryusuke Konishi konishi.ryus...@lab.ntt.co.jp
Date: Sat, 15 May 2010 12:33:27 +0900
Subject: [PATCH] nilfs2-utils: add test tool to correct log pointer in super 
block

Signed-off-by: Ryusuke Konishi konishi.ryus...@lab.ntt.co.jp
---
 configure.ac |1 +
 sbin/Makefile.am |2 +-
 sbin/fsck/Makefile.am|7 +
 sbin/fsck/fsck0.nilfs2.c | 1150 ++
 4 files changed, 1159 insertions(+), 1 deletions(-)
 create mode 100644 sbin/fsck/Makefile.am
 create mode 100644 sbin/fsck/fsck0.nilfs2.c

diff --git a/configure.ac b/configure.ac
index 2b2dfd7..30e91eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,6 +86,7 @@ AC_CONFIG_FILES([Makefile
  man/Makefile
  sbin/Makefile
  sbin/cleanerd/Makefile
+sbin/fsck/Makefile
  sbin/mkfs/Makefile
 sbin/mount/Makefile])
 AC_OUTPUT
diff --git a/sbin/Makefile.am b/sbin/Makefile.am
index 6038b8f..7f2c6db 100644
--- a/sbin/Makefile.am
+++ b/sbin/Makefile.am
@@ -1,3 +1,3 @@
 ## Makefile.am
 
-SUBDIRS = cleanerd mkfs mount
+SUBDIRS = cleanerd mkfs mount fsck
diff --git a/sbin/fsck/Makefile.am b/sbin/fsck/Makefile.am
new file mode 100644
index 000..4a2f380
--- /dev/null
+++ b/sbin/fsck/Makefile.am
@@ -0,0 +1,7 @@
+## Makefile.am
+
+sbin_PROGRAMS = fsck0.nilfs2
+
+fsck0_nilfs2_SOURCES = fsck0.nilfs2.c ../../lib/crc32.c ../mkfs/mkfs.h
+fsck0_nilfs2_CFLAGS = -Wall
+fsck0_nilfs2_CPPFLAGS = -I$(top_srcdir)/include
diff --git a/sbin/fsck/fsck0.nilfs2.c b/sbin/fsck/fsck0.nilfs2.c
new file mode 100644
index 000..2d3a435
--- /dev/null
+++ b/sbin/fsck/fsck0.nilfs2.c
@@ -0,0 +1,1150 @@
+/*
+ * fsck0.nilfs2.c - correct inconsistencies of nilfs2 volume
+ *
+ * Licensed under GPLv2: the complete text of the GNU General Public License
+ * can be found in COPYING file of the