aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/the_nilfs.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-19 02:58:40 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-11-19 20:05:52 -0500
commitf50a4c8149cc135921a8a0476bff8e622f59aef9 (patch)
treeeba1d25b71d85daf34153ffc1b1e8eaf8b83cccc /fs/nilfs2/the_nilfs.c
parent050b4142c9f3cb3a213f254bd1a1fa1476800585 (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/nilfs2/the_nilfs.c')
-rw-r--r--fs/nilfs2/the_nilfs.c70
1 files changed, 48 insertions, 22 deletions
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);