aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-06-28 04:49:31 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-07-22 21:02:10 -0400
commit60f46b7efc1d6b980511c2644cb89903062f6e98 (patch)
tree6a0093650f858279db262c3b39de721bf3b20098 /fs/nilfs2
parentc8a11c8a1455c380286cfd3d3442e2b60edee49a (diff)
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>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/nilfs.h2
-rw-r--r--fs/nilfs2/super.c30
2 files changed, 19 insertions, 13 deletions
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 469541711a1f..6718616183b7 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -270,6 +270,8 @@ extern struct nilfs_super_block *
270nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **); 270nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
271extern int nilfs_store_magic_and_option(struct super_block *, 271extern int nilfs_store_magic_and_option(struct super_block *,
272 struct nilfs_super_block *, char *); 272 struct nilfs_super_block *, char *);
273extern void nilfs_set_log_cursor(struct nilfs_super_block *,
274 struct the_nilfs *);
273extern int nilfs_commit_super(struct nilfs_sb_info *, int); 275extern int nilfs_commit_super(struct nilfs_sb_info *, int);
274extern int nilfs_cleanup_super(struct nilfs_sb_info *); 276extern int nilfs_cleanup_super(struct nilfs_sb_info *);
275extern int nilfs_attach_checkpoint(struct nilfs_sb_info *, __u64); 277extern int nilfs_attach_checkpoint(struct nilfs_sb_info *, __u64);
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 4a85dfb70b8e..c5328c8ba1d2 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -237,13 +237,27 @@ static int nilfs_sync_super(struct nilfs_sb_info *sbi, int dupsb)
237 return err; 237 return err;
238} 238}
239 239
240void nilfs_set_log_cursor(struct nilfs_super_block *sbp,
241 struct the_nilfs *nilfs)
242{
243 sector_t nfreeblocks;
244
245 /* nilfs->ns_sem must be locked by the caller. */
246 nilfs_count_free_blocks(nilfs, &nfreeblocks);
247 sbp->s_free_blocks_count = cpu_to_le64(nfreeblocks);
248
249 spin_lock(&nilfs->ns_last_segment_lock);
250 sbp->s_last_seq = cpu_to_le64(nilfs->ns_last_seq);
251 sbp->s_last_pseg = cpu_to_le64(nilfs->ns_last_pseg);
252 sbp->s_last_cno = cpu_to_le64(nilfs->ns_last_cno);
253 spin_unlock(&nilfs->ns_last_segment_lock);
254}
255
240int nilfs_commit_super(struct nilfs_sb_info *sbi, int dupsb) 256int nilfs_commit_super(struct nilfs_sb_info *sbi, int dupsb)
241{ 257{
242 struct the_nilfs *nilfs = sbi->s_nilfs; 258 struct the_nilfs *nilfs = sbi->s_nilfs;
243 struct nilfs_super_block **sbp = nilfs->ns_sbp; 259 struct nilfs_super_block **sbp = nilfs->ns_sbp;
244 sector_t nfreeblocks;
245 time_t t; 260 time_t t;
246 int err;
247 261
248 /* nilfs->sem must be locked by the caller. */ 262 /* nilfs->sem must be locked by the caller. */
249 if (sbp[0]->s_magic != cpu_to_le16(NILFS_SUPER_MAGIC)) { 263 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)
255 return -EIO; 269 return -EIO;
256 } 270 }
257 } 271 }
258 err = nilfs_count_free_blocks(nilfs, &nfreeblocks); 272 nilfs_set_log_cursor(sbp[0], nilfs);
259 if (unlikely(err)) {
260 printk(KERN_ERR "NILFS: failed to count free blocks\n");
261 return err;
262 }
263 spin_lock(&nilfs->ns_last_segment_lock);
264 sbp[0]->s_last_seq = cpu_to_le64(nilfs->ns_last_seq);
265 sbp[0]->s_last_pseg = cpu_to_le64(nilfs->ns_last_pseg);
266 sbp[0]->s_last_cno = cpu_to_le64(nilfs->ns_last_cno);
267 spin_unlock(&nilfs->ns_last_segment_lock);
268 273
269 t = get_seconds(); 274 t = get_seconds();
270 nilfs->ns_sbwtime[0] = t; 275 nilfs->ns_sbwtime[0] = t;
271 sbp[0]->s_free_blocks_count = cpu_to_le64(nfreeblocks);
272 sbp[0]->s_wtime = cpu_to_le64(t); 276 sbp[0]->s_wtime = cpu_to_le64(t);
273 sbp[0]->s_sum = 0; 277 sbp[0]->s_sum = 0;
274 sbp[0]->s_sum = cpu_to_le32(crc32_le(nilfs->ns_crc_seed, 278 sbp[0]->s_sum = cpu_to_le32(crc32_le(nilfs->ns_crc_seed,