nilfs2: separate function that updates log position
This moves out section that updates information of the recent log position stored in super blocks from nilfs_commit_super to a new routine named nilfs_set_log_cursor. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
This commit is contained in:
parent
c8a11c8a14
commit
60f46b7efc
|
@ -270,6 +270,8 @@ extern struct nilfs_super_block *
|
||||||
nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
|
nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
|
||||||
extern int nilfs_store_magic_and_option(struct super_block *,
|
extern int nilfs_store_magic_and_option(struct super_block *,
|
||||||
struct nilfs_super_block *, char *);
|
struct nilfs_super_block *, char *);
|
||||||
|
extern void nilfs_set_log_cursor(struct nilfs_super_block *,
|
||||||
|
struct the_nilfs *);
|
||||||
extern int nilfs_commit_super(struct nilfs_sb_info *, int);
|
extern int nilfs_commit_super(struct nilfs_sb_info *, int);
|
||||||
extern int nilfs_cleanup_super(struct nilfs_sb_info *);
|
extern int nilfs_cleanup_super(struct nilfs_sb_info *);
|
||||||
extern int nilfs_attach_checkpoint(struct nilfs_sb_info *, __u64);
|
extern int nilfs_attach_checkpoint(struct nilfs_sb_info *, __u64);
|
||||||
|
|
|
@ -237,13 +237,27 @@ static int nilfs_sync_super(struct nilfs_sb_info *sbi, int dupsb)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nilfs_set_log_cursor(struct nilfs_super_block *sbp,
|
||||||
|
struct the_nilfs *nilfs)
|
||||||
|
{
|
||||||
|
sector_t nfreeblocks;
|
||||||
|
|
||||||
|
/* nilfs->ns_sem must be locked by the caller. */
|
||||||
|
nilfs_count_free_blocks(nilfs, &nfreeblocks);
|
||||||
|
sbp->s_free_blocks_count = cpu_to_le64(nfreeblocks);
|
||||||
|
|
||||||
|
spin_lock(&nilfs->ns_last_segment_lock);
|
||||||
|
sbp->s_last_seq = cpu_to_le64(nilfs->ns_last_seq);
|
||||||
|
sbp->s_last_pseg = cpu_to_le64(nilfs->ns_last_pseg);
|
||||||
|
sbp->s_last_cno = cpu_to_le64(nilfs->ns_last_cno);
|
||||||
|
spin_unlock(&nilfs->ns_last_segment_lock);
|
||||||
|
}
|
||||||
|
|
||||||
int nilfs_commit_super(struct nilfs_sb_info *sbi, int dupsb)
|
int nilfs_commit_super(struct nilfs_sb_info *sbi, int dupsb)
|
||||||
{
|
{
|
||||||
struct the_nilfs *nilfs = sbi->s_nilfs;
|
struct the_nilfs *nilfs = sbi->s_nilfs;
|
||||||
struct nilfs_super_block **sbp = nilfs->ns_sbp;
|
struct nilfs_super_block **sbp = nilfs->ns_sbp;
|
||||||
sector_t nfreeblocks;
|
|
||||||
time_t t;
|
time_t t;
|
||||||
int err;
|
|
||||||
|
|
||||||
/* nilfs->sem must be locked by the caller. */
|
/* nilfs->sem must be locked by the caller. */
|
||||||
if (sbp[0]->s_magic != cpu_to_le16(NILFS_SUPER_MAGIC)) {
|
if (sbp[0]->s_magic != cpu_to_le16(NILFS_SUPER_MAGIC)) {
|
||||||
|
@ -255,20 +269,10 @@ int nilfs_commit_super(struct nilfs_sb_info *sbi, int dupsb)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = nilfs_count_free_blocks(nilfs, &nfreeblocks);
|
nilfs_set_log_cursor(sbp[0], nilfs);
|
||||||
if (unlikely(err)) {
|
|
||||||
printk(KERN_ERR "NILFS: failed to count free blocks\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
spin_lock(&nilfs->ns_last_segment_lock);
|
|
||||||
sbp[0]->s_last_seq = cpu_to_le64(nilfs->ns_last_seq);
|
|
||||||
sbp[0]->s_last_pseg = cpu_to_le64(nilfs->ns_last_pseg);
|
|
||||||
sbp[0]->s_last_cno = cpu_to_le64(nilfs->ns_last_cno);
|
|
||||||
spin_unlock(&nilfs->ns_last_segment_lock);
|
|
||||||
|
|
||||||
t = get_seconds();
|
t = get_seconds();
|
||||||
nilfs->ns_sbwtime[0] = t;
|
nilfs->ns_sbwtime[0] = t;
|
||||||
sbp[0]->s_free_blocks_count = cpu_to_le64(nfreeblocks);
|
|
||||||
sbp[0]->s_wtime = cpu_to_le64(t);
|
sbp[0]->s_wtime = cpu_to_le64(t);
|
||||||
sbp[0]->s_sum = 0;
|
sbp[0]->s_sum = 0;
|
||||||
sbp[0]->s_sum = cpu_to_le32(crc32_le(nilfs->ns_crc_seed,
|
sbp[0]->s_sum = cpu_to_le32(crc32_le(nilfs->ns_crc_seed,
|
||||||
|
|
Loading…
Reference in a new issue