nilfs2: use list_first_entry
[firefly-linux-kernel-4.4.55.git] / fs / nilfs2 / segment.c
index abbfab974700ef0fab18c4138c64d7c94769f99d..186cabbe54d7001ace29d8a5e8b81ec346bd64af 100644 (file)
@@ -889,12 +889,14 @@ static void nilfs_segctor_fill_in_super_root(struct nilfs_sc_info *sci,
 {
        struct buffer_head *bh_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;
        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);
+       raw_sr->sr_bytes = cpu_to_le16(srsz);
        raw_sr->sr_nongc_ctime
                = cpu_to_le64(nilfs_doing_gc() ?
                              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,
                                 NILFS_SR_CPFILE_OFFSET(isz), 1);
        nilfs_write_inode_common(nilfs->ns_sufile, (void *)raw_sr +
                                 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)
@@ -954,8 +957,8 @@ static int nilfs_segctor_apply_buffers(struct nilfs_sc_info *sci,
 
  dispose_buffers:
        while (!list_empty(listp)) {
-               bh = list_entry(listp->next, struct buffer_head,
-                               b_assoc_buffers);
+               bh = list_first_entry(listp, struct buffer_head,
+                                     b_assoc_buffers);
                list_del_init(&bh->b_assoc_buffers);
                brelse(bh);
        }