aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2011-04-30 05:56:12 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2011-05-10 09:21:45 -0400
commit56eb55388580ebd51f3bbd9af40ebb56849356af (patch)
tree7d1ed80fa05150c40a75d5755981c8d949ae634b /fs/nilfs2
parent6c6de1aa65189c37cc3c9af78da756c06a99899b (diff)
nilfs2: zero fill unused portion of super root block
The super root block is newly-allocated each time it is written back to disk, so unused portion of the block should be cleared. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/inode.c10
-rw-r--r--fs/nilfs2/segment.c7
2 files changed, 15 insertions, 2 deletions
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 2cc8c087b2d5..699170e0f308 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -596,6 +596,16 @@ void nilfs_write_inode_common(struct inode *inode,
596 raw_inode->i_flags = cpu_to_le32(ii->i_flags); 596 raw_inode->i_flags = cpu_to_le32(ii->i_flags);
597 raw_inode->i_generation = cpu_to_le32(inode->i_generation); 597 raw_inode->i_generation = cpu_to_le32(inode->i_generation);
598 598
599 if (NILFS_ROOT_METADATA_FILE(inode->i_ino)) {
600 struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
601
602 /* zero-fill unused portion in the case of super root block */
603 raw_inode->i_xattr = 0;
604 raw_inode->i_pad = 0;
605 memset((void *)raw_inode + sizeof(*raw_inode), 0,
606 nilfs->ns_inode_size - sizeof(*raw_inode));
607 }
608
599 if (has_bmap) 609 if (has_bmap)
600 nilfs_bmap_write(ii->i_bmap, raw_inode); 610 nilfs_bmap_write(ii->i_bmap, raw_inode);
601 else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) 611 else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 8006d0cd4440..8a2b428b1838 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -889,12 +889,14 @@ static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci,
889{ 889{
890 struct buffer_head *bh_sr; 890 struct buffer_head *bh_sr;
891 struct nilfs_super_root *raw_sr; 891 struct nilfs_super_root *raw_sr;
892 unsigned isz = nilfs->ns_inode_size; 892 unsigned isz, srsz;
893 893
894 bh_sr = NILFS_LAST_SEGBUF(&sci->sc_segbufs)->sb_super_root; 894 bh_sr = NILFS_LAST_SEGBUF(&sci->sc_segbufs)->sb_super_root;
895 raw_sr = (struct nilfs_super_root *)bh_sr->b_data; 895 raw_sr = (struct nilfs_super_root *)bh_sr->b_data;
896 isz = nilfs->ns_inode_size;
897 srsz = NILFS_SR_BYTES(isz);
896 898
897 raw_sr->sr_bytes = cpu_to_le16(NILFS_SR_BYTES(isz)); 899 raw_sr->sr_bytes = cpu_to_le16(srsz);
898 raw_sr->sr_nongc_ctime 900 raw_sr->sr_nongc_ctime
899 = cpu_to_le64(nilfs_doing_gc() ? 901 = cpu_to_le64(nilfs_doing_gc() ?
900 nilfs->ns_nongc_ctime : sci->sc_seg_ctime); 902 nilfs->ns_nongc_ctime : sci->sc_seg_ctime);
@@ -906,6 +908,7 @@ static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci,
906 NILFS_SR_CPFILE_OFFSET(isz), 1); 908 NILFS_SR_CPFILE_OFFSET(isz), 1);
907 nilfs_write_inode_common(nilfs->ns_sufile, (void *)raw_sr + 909 nilfs_write_inode_common(nilfs->ns_sufile, (void *)raw_sr +
908 NILFS_SR_SUFILE_OFFSET(isz), 1); 910 NILFS_SR_SUFILE_OFFSET(isz), 1);
911 memset((void *)raw_sr + srsz, 0, nilfs->ns_blocksize - srsz);
909} 912}
910 913
911static void nilfs_redirty_inodes(struct list_head *head) 914static void nilfs_redirty_inodes(struct list_head *head)