diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-11-19 02:58:40 -0500 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-11-19 20:05:52 -0500 |
commit | f50a4c8149cc135921a8a0476bff8e622f59aef9 (patch) | |
tree | eba1d25b71d85daf34153ffc1b1e8eaf8b83cccc /fs | |
parent | 050b4142c9f3cb3a213f254bd1a1fa1476800585 (diff) |
nilfs2: move recovery completion into load_nilfs function
Although mount recovery of nilfs is integrated in load_nilfs()
procedure, the completion of recovery was isolated from the procedure
and performed at the end of the fill_super routine.
This was somewhat confusing since the recovery is needed for the nilfs
object, not for a super block instance.
To resolve the inconsistency, this will integrate the recovery
completion into load_nilfs().
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nilfs2/super.c | 39 | ||||
-rw-r--r-- | fs/nilfs2/the_nilfs.c | 70 |
2 files changed, 53 insertions, 56 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index f52616977ea0..990ead43a833 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -414,22 +414,6 @@ void nilfs_detach_checkpoint(struct nilfs_sb_info *sbi) | |||
414 | up_write(&nilfs->ns_super_sem); | 414 | up_write(&nilfs->ns_super_sem); |
415 | } | 415 | } |
416 | 416 | ||
417 | static int nilfs_mark_recovery_complete(struct nilfs_sb_info *sbi) | ||
418 | { | ||
419 | struct the_nilfs *nilfs = sbi->s_nilfs; | ||
420 | int err = 0; | ||
421 | |||
422 | down_write(&nilfs->ns_sem); | ||
423 | if (!(nilfs->ns_mount_state & NILFS_VALID_FS)) { | ||
424 | nilfs->ns_mount_state |= NILFS_VALID_FS; | ||
425 | err = nilfs_commit_super(sbi, 1); | ||
426 | if (likely(!err)) | ||
427 | printk(KERN_INFO "NILFS: recovery complete.\n"); | ||
428 | } | ||
429 | up_write(&nilfs->ns_sem); | ||
430 | return err; | ||
431 | } | ||
432 | |||
433 | static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 417 | static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
434 | { | 418 | { |
435 | struct super_block *sb = dentry->d_sb; | 419 | struct super_block *sb = dentry->d_sb; |
@@ -649,9 +633,7 @@ static int nilfs_setup_super(struct nilfs_sb_info *sbi) | |||
649 | int mnt_count = le16_to_cpu(sbp->s_mnt_count); | 633 | int mnt_count = le16_to_cpu(sbp->s_mnt_count); |
650 | 634 | ||
651 | /* nilfs->sem must be locked by the caller. */ | 635 | /* nilfs->sem must be locked by the caller. */ |
652 | if (!(nilfs->ns_mount_state & NILFS_VALID_FS)) { | 636 | if (nilfs->ns_mount_state & NILFS_ERROR_FS) { |
653 | printk(KERN_WARNING "NILFS warning: mounting unchecked fs\n"); | ||
654 | } else if (nilfs->ns_mount_state & NILFS_ERROR_FS) { | ||
655 | printk(KERN_WARNING | 637 | printk(KERN_WARNING |
656 | "NILFS warning: mounting fs with errors\n"); | 638 | "NILFS warning: mounting fs with errors\n"); |
657 | #if 0 | 639 | #if 0 |
@@ -759,11 +741,10 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent, | |||
759 | sb->s_root = NULL; | 741 | sb->s_root = NULL; |
760 | sb->s_time_gran = 1; | 742 | sb->s_time_gran = 1; |
761 | 743 | ||
762 | if (!nilfs_loaded(nilfs)) { | 744 | err = load_nilfs(nilfs, sbi); |
763 | err = load_nilfs(nilfs, sbi); | 745 | if (err) |
764 | if (err) | 746 | goto failed_sbi; |
765 | goto failed_sbi; | 747 | |
766 | } | ||
767 | cno = nilfs_last_cno(nilfs); | 748 | cno = nilfs_last_cno(nilfs); |
768 | 749 | ||
769 | if (sb->s_flags & MS_RDONLY) { | 750 | if (sb->s_flags & MS_RDONLY) { |
@@ -831,12 +812,6 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent, | |||
831 | up_write(&nilfs->ns_sem); | 812 | up_write(&nilfs->ns_sem); |
832 | } | 813 | } |
833 | 814 | ||
834 | err = nilfs_mark_recovery_complete(sbi); | ||
835 | if (unlikely(err)) { | ||
836 | printk(KERN_ERR "NILFS: recovery failed.\n"); | ||
837 | goto failed_root; | ||
838 | } | ||
839 | |||
840 | down_write(&nilfs->ns_super_sem); | 815 | down_write(&nilfs->ns_super_sem); |
841 | if (!nilfs_test_opt(sbi, SNAPSHOT)) | 816 | if (!nilfs_test_opt(sbi, SNAPSHOT)) |
842 | nilfs->ns_current = sbi; | 817 | nilfs->ns_current = sbi; |
@@ -844,10 +819,6 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent, | |||
844 | 819 | ||
845 | return 0; | 820 | return 0; |
846 | 821 | ||
847 | failed_root: | ||
848 | dput(sb->s_root); | ||
849 | sb->s_root = NULL; | ||
850 | |||
851 | failed_segctor: | 822 | failed_segctor: |
852 | nilfs_detach_segment_constructor(sbi); | 823 | nilfs_detach_segment_constructor(sbi); |
853 | 824 | ||
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c index 4d4d35c6fbef..aea2b58ba03b 100644 --- a/fs/nilfs2/the_nilfs.c +++ b/fs/nilfs2/the_nilfs.c | |||
@@ -262,28 +262,27 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | |||
262 | unsigned int s_flags = sbi->s_super->s_flags; | 262 | unsigned int s_flags = sbi->s_super->s_flags; |
263 | int really_read_only = bdev_read_only(nilfs->ns_bdev); | 263 | int really_read_only = bdev_read_only(nilfs->ns_bdev); |
264 | unsigned valid_fs; | 264 | unsigned valid_fs; |
265 | int err = 0; | 265 | int err; |
266 | 266 | ||
267 | nilfs_init_recovery_info(&ri); | 267 | if (nilfs_loaded(nilfs)) |
268 | return 0; | ||
268 | 269 | ||
269 | down_write(&nilfs->ns_sem); | 270 | down_write(&nilfs->ns_sem); |
270 | valid_fs = (nilfs->ns_mount_state & NILFS_VALID_FS); | 271 | valid_fs = (nilfs->ns_mount_state & NILFS_VALID_FS); |
271 | up_write(&nilfs->ns_sem); | 272 | up_write(&nilfs->ns_sem); |
272 | 273 | ||
273 | if (!valid_fs && (s_flags & MS_RDONLY)) { | 274 | if (!valid_fs) { |
274 | printk(KERN_INFO "NILFS: INFO: recovery " | 275 | printk(KERN_WARNING "NILFS warning: mounting unchecked fs\n"); |
275 | "required for readonly filesystem.\n"); | 276 | if (s_flags & MS_RDONLY) { |
276 | if (really_read_only) { | 277 | printk(KERN_INFO "NILFS: INFO: recovery " |
277 | printk(KERN_ERR "NILFS: write access " | 278 | "required for readonly filesystem.\n"); |
278 | "unavailable, cannot proceed.\n"); | 279 | printk(KERN_INFO "NILFS: write access will " |
279 | err = -EROFS; | 280 | "be enabled during recovery.\n"); |
280 | goto failed; | ||
281 | } | 281 | } |
282 | printk(KERN_INFO "NILFS: write access will " | ||
283 | "be enabled during recovery.\n"); | ||
284 | sbi->s_super->s_flags &= ~MS_RDONLY; | ||
285 | } | 282 | } |
286 | 283 | ||
284 | nilfs_init_recovery_info(&ri); | ||
285 | |||
287 | err = nilfs_search_super_root(nilfs, sbi, &ri); | 286 | err = nilfs_search_super_root(nilfs, sbi, &ri); |
288 | if (unlikely(err)) { | 287 | if (unlikely(err)) { |
289 | printk(KERN_ERR "NILFS: error searching super root.\n"); | 288 | printk(KERN_ERR "NILFS: error searching super root.\n"); |
@@ -296,19 +295,46 @@ int load_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi) | |||
296 | goto failed; | 295 | goto failed; |
297 | } | 296 | } |
298 | 297 | ||
299 | if (!valid_fs) { | 298 | if (valid_fs) |
300 | err = nilfs_recover_logical_segments(nilfs, sbi, &ri); | 299 | goto skip_recovery; |
301 | if (unlikely(err)) { | 300 | |
302 | nilfs_mdt_destroy(nilfs->ns_cpfile); | 301 | if (s_flags & MS_RDONLY) { |
303 | nilfs_mdt_destroy(nilfs->ns_sufile); | 302 | if (really_read_only) { |
304 | nilfs_mdt_destroy(nilfs->ns_dat); | 303 | printk(KERN_ERR "NILFS: write access " |
305 | goto failed; | 304 | "unavailable, cannot proceed.\n"); |
305 | err = -EROFS; | ||
306 | goto failed_unload; | ||
306 | } | 307 | } |
307 | if (ri.ri_need_recovery == NILFS_RECOVERY_SR_UPDATED) | 308 | sbi->s_super->s_flags &= ~MS_RDONLY; |
308 | sbi->s_super->s_dirt = 1; | 309 | } |
310 | |||
311 | err = nilfs_recover_logical_segments(nilfs, sbi, &ri); | ||
312 | if (err) | ||
313 | goto failed_unload; | ||
314 | |||
315 | down_write(&nilfs->ns_sem); | ||
316 | nilfs->ns_mount_state |= NILFS_VALID_FS; | ||
317 | nilfs->ns_sbp[0]->s_state = cpu_to_le16(nilfs->ns_mount_state); | ||
318 | err = nilfs_commit_super(sbi, 1); | ||
319 | up_write(&nilfs->ns_sem); | ||
320 | |||
321 | if (err) { | ||
322 | printk(KERN_ERR "NILFS: failed to update super block. " | ||
323 | "recovery unfinished.\n"); | ||
324 | goto failed_unload; | ||
309 | } | 325 | } |
326 | printk(KERN_INFO "NILFS: recovery complete.\n"); | ||
310 | 327 | ||
328 | skip_recovery: | ||
311 | set_nilfs_loaded(nilfs); | 329 | set_nilfs_loaded(nilfs); |
330 | nilfs_clear_recovery_info(&ri); | ||
331 | sbi->s_super->s_flags = s_flags; | ||
332 | return 0; | ||
333 | |||
334 | failed_unload: | ||
335 | nilfs_mdt_destroy(nilfs->ns_cpfile); | ||
336 | nilfs_mdt_destroy(nilfs->ns_sufile); | ||
337 | nilfs_mdt_destroy(nilfs->ns_dat); | ||
312 | 338 | ||
313 | failed: | 339 | failed: |
314 | nilfs_clear_recovery_info(&ri); | 340 | nilfs_clear_recovery_info(&ri); |