diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-06-28 06:15:24 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2010-07-22 21:02:11 -0400 |
commit | 843d63baa5babf3d8786f6a4377a2448525da7aa (patch) | |
tree | 15466ecdb0e65b1f654d6bc67f3607b4b5740eb5 /fs/nilfs2 | |
parent | b2ac86e1a8e3a3b0ab4449d062c582f07a078e7b (diff) |
nilfs2: separate setup of log cursor from init_nilfs
This separates a setup routine of log cursor from init_nilfs(). The
routine, nilfs_store_log_cursor, reads the last position of the log
containing a super root, and initializes relevant state on the nilfs
object.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r-- | fs/nilfs2/the_nilfs.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 530d2777b4c7..0d2a46cb75f8 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
@@ -247,6 +247,36 @@ static void nilfs_clear_recovery_info(struct nilfs_recovery_info *ri) | |||
247 | } | 247 | } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | * nilfs_store_log_cursor - load log cursor from a super block | ||
251 | * @nilfs: nilfs object | ||
252 | * @sbp: buffer storing super block to be read | ||
253 | * | ||
254 | * nilfs_store_log_cursor() reads the last position of the log | ||
255 | * containing a super root from a given super block, and initializes | ||
256 | * relevant information on the nilfs object preparatory for log | ||
257 | * scanning and recovery. | ||
258 | */ | ||
259 | static int nilfs_store_log_cursor(struct the_nilfs *nilfs, | ||
260 | struct nilfs_super_block *sbp) | ||
261 | { | ||
262 | int ret = 0; | ||
263 | |||
264 | nilfs->ns_last_pseg = le64_to_cpu(sbp->s_last_pseg); | ||
265 | nilfs->ns_last_cno = le64_to_cpu(sbp->s_last_cno); | ||
266 | nilfs->ns_last_seq = le64_to_cpu(sbp->s_last_seq); | ||
267 | |||
268 | nilfs->ns_seg_seq = nilfs->ns_last_seq; | ||
269 | nilfs->ns_segnum = | ||
270 | nilfs_get_segnum_of_block(nilfs, nilfs->ns_last_pseg); | ||
271 | nilfs->ns_cno = nilfs->ns_last_cno + 1; | ||
272 | if (nilfs->ns_segnum >= nilfs->ns_nsegments) { | ||
273 | printk(KERN_ERR "NILFS invalid last segment number.\n"); | ||
274 | ret = -EINVAL; | ||
275 | } | ||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | /** | ||
250 | * load_nilfs - load and recover the nilfs | 280 | * load_nilfs - load and recover the nilfs |
251 | * @nilfs: the_nilfs structure to be released | 281 | * @nilfs: the_nilfs structure to be released |
252 | * @sbi: nilfs_sb_info used to recover past segment | 282 | * @sbi: nilfs_sb_info used to recover past segment |
@@ -615,20 +645,9 @@ int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data) | |||
615 | bdi = nilfs->ns_bdev->bd_inode->i_mapping->backing_dev_info; | 645 | bdi = nilfs->ns_bdev->bd_inode->i_mapping->backing_dev_info; |
616 | nilfs->ns_bdi = bdi ? : &default_backing_dev_info; | 646 | nilfs->ns_bdi = bdi ? : &default_backing_dev_info; |
617 | 647 | ||
618 | /* Finding last segment */ | 648 | err = nilfs_store_log_cursor(nilfs, sbp); |
619 | nilfs->ns_last_pseg = le64_to_cpu(sbp->s_last_pseg); | 649 | if (err) |
620 | nilfs->ns_last_cno = le64_to_cpu(sbp->s_last_cno); | ||
621 | nilfs->ns_last_seq = le64_to_cpu(sbp->s_last_seq); | ||
622 | |||
623 | nilfs->ns_seg_seq = nilfs->ns_last_seq; | ||
624 | nilfs->ns_segnum = | ||
625 | nilfs_get_segnum_of_block(nilfs, nilfs->ns_last_pseg); | ||
626 | nilfs->ns_cno = nilfs->ns_last_cno + 1; | ||
627 | if (nilfs->ns_segnum >= nilfs->ns_nsegments) { | ||
628 | printk(KERN_ERR "NILFS invalid last segment number.\n"); | ||
629 | err = -EINVAL; | ||
630 | goto failed_sbh; | 650 | goto failed_sbh; |
631 | } | ||
632 | 651 | ||
633 | /* Initialize gcinode cache */ | 652 | /* Initialize gcinode cache */ |
634 | err = nilfs_init_gccache(nilfs); | 653 | err = nilfs_init_gccache(nilfs); |