Commit 56eb5538 authored by Ryusuke Konishi's avatar Ryusuke Konishi

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: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent 6c6de1aa
...@@ -596,6 +596,16 @@ void nilfs_write_inode_common(struct inode *inode, ...@@ -596,6 +596,16 @@ void nilfs_write_inode_common(struct inode *inode,
raw_inode->i_flags = cpu_to_le32(ii->i_flags); raw_inode->i_flags = cpu_to_le32(ii->i_flags);
raw_inode->i_generation = cpu_to_le32(inode->i_generation); raw_inode->i_generation = cpu_to_le32(inode->i_generation);
if (NILFS_ROOT_METADATA_FILE(inode->i_ino)) {
struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
/* zero-fill unused portion in the case of super root block */
raw_inode->i_xattr = 0;
raw_inode->i_pad = 0;
memset((void *)raw_inode + sizeof(*raw_inode), 0,
nilfs->ns_inode_size - sizeof(*raw_inode));
}
if (has_bmap) if (has_bmap)
nilfs_bmap_write(ii->i_bmap, raw_inode); nilfs_bmap_write(ii->i_bmap, raw_inode);
else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
......
...@@ -889,12 +889,14 @@ static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci, ...@@ -889,12 +889,14 @@ static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci,
{ {
struct buffer_head *bh_sr; struct buffer_head *bh_sr;
struct nilfs_super_root *raw_sr; struct nilfs_super_root *raw_sr;
unsigned isz = nilfs->ns_inode_size; unsigned isz, srsz;
bh_sr = NILFS_LAST_SEGBUF(&sci->sc_segbufs)->sb_super_root; bh_sr = NILFS_LAST_SEGBUF(&sci->sc_segbufs)->sb_super_root;
raw_sr = (struct nilfs_super_root *)bh_sr->b_data; raw_sr = (struct nilfs_super_root *)bh_sr->b_data;
isz = nilfs->ns_inode_size;
srsz = NILFS_SR_BYTES(isz);
raw_sr->sr_bytes = cpu_to_le16(NILFS_SR_BYTES(isz)); raw_sr->sr_bytes = cpu_to_le16(srsz);
raw_sr->sr_nongc_ctime raw_sr->sr_nongc_ctime
= cpu_to_le64(nilfs_doing_gc() ? = cpu_to_le64(nilfs_doing_gc() ?
nilfs->ns_nongc_ctime : sci->sc_seg_ctime); 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,6 +908,7 @@ static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci,
NILFS_SR_CPFILE_OFFSET(isz), 1); NILFS_SR_CPFILE_OFFSET(isz), 1);
nilfs_write_inode_common(nilfs->ns_sufile, (void *)raw_sr + nilfs_write_inode_common(nilfs->ns_sufile, (void *)raw_sr +
NILFS_SR_SUFILE_OFFSET(isz), 1); NILFS_SR_SUFILE_OFFSET(isz), 1);
memset((void *)raw_sr + srsz, 0, nilfs->ns_blocksize - srsz);
} }
static void nilfs_redirty_inodes(struct list_head *head) static void nilfs_redirty_inodes(struct list_head *head)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment