nilfs2: super root size should change depending on inode size
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Sat, 30 Apr 2011 09:56:12 +0000 (18:56 +0900)
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Tue, 10 May 2011 13:21:44 +0000 (22:21 +0900)
The size of super root structure depends on inode size, so
NILFS_SR_BYTES macro should be a function of the inode size.  This
fixes the issue.

Even though a different size value will be written for a possible
future filesystem with extended inode, but fortunately this does not
break disk format compatibility.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
fs/nilfs2/segbuf.c
fs/nilfs2/segment.c
include/linux/nilfs2_fs.h

index 410ec2b1af4f1e1d22c933132bd9c102b5c0cb63..850a7c0228fbd949be2e861faaed9cc79bbe7564 100644 (file)
@@ -239,12 +239,15 @@ nilfs_segbuf_fill_in_super_root_crc(struct nilfs_segment_buffer *segbuf,
                                    u32 seed)
 {
        struct nilfs_super_root *raw_sr;
+       struct the_nilfs *nilfs = segbuf->sb_super->s_fs_info;
+       unsigned srsize;
        u32 crc;
 
        raw_sr = (struct nilfs_super_root *)segbuf->sb_super_root->b_data;
+       srsize = NILFS_SR_BYTES(nilfs->ns_inode_size);
        crc = crc32_le(seed,
                       (unsigned char *)raw_sr + sizeof(raw_sr->sr_sum),
-                      NILFS_SR_BYTES - sizeof(raw_sr->sr_sum));
+                      srsize - sizeof(raw_sr->sr_sum));
        raw_sr->sr_sum = cpu_to_le32(crc);
 }
 
index abbfab974700ef0fab18c4138c64d7c94769f99d..8006d0cd4440b88f2a1faade26c165ef954a2258 100644 (file)
@@ -894,7 +894,7 @@ static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci,
        bh_sr = NILFS_LAST_SEGBUF(&sci->sc_segbufs)->sb_super_root;
        raw_sr = (struct nilfs_super_root *)bh_sr->b_data;
 
-       raw_sr->sr_bytes = cpu_to_le16(NILFS_SR_BYTES);
+       raw_sr->sr_bytes = cpu_to_le16(NILFS_SR_BYTES(isz));
        raw_sr->sr_nongc_ctime
                = cpu_to_le64(nilfs_doing_gc() ?
                              nilfs->ns_nongc_ctime : sci->sc_seg_ctime);
index 8768c469e93e611f1636748cf5cabf8250896ec7..bd8678f8a421d1e50a914254ad49272f864fa29a 100644 (file)
@@ -107,7 +107,7 @@ struct nilfs_super_root {
 #define NILFS_SR_DAT_OFFSET(inode_size)     NILFS_SR_MDT_OFFSET(inode_size, 0)
 #define NILFS_SR_CPFILE_OFFSET(inode_size)  NILFS_SR_MDT_OFFSET(inode_size, 1)
 #define NILFS_SR_SUFILE_OFFSET(inode_size)  NILFS_SR_MDT_OFFSET(inode_size, 2)
-#define NILFS_SR_BYTES                  (sizeof(struct nilfs_super_root))
+#define NILFS_SR_BYTES(inode_size)         NILFS_SR_MDT_OFFSET(inode_size, 3)
 
 /*
  * Maximal mount counts