aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/super.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-14 00:07:15 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:35 -0400
commite912a5b66837ee89fb025e67b5efeaa11930c2ce (patch)
tree46209cdf7417863024131ff54f56120e43ae7a7b /fs/nilfs2/super.c
parent8e656fd518784b49453f60c5f78b78703bc85cb2 (diff)
nilfs2: use root object to get ifile
This rewrites functions using ifile so that they get ifile from nilfs_root object, and will remove sbi->s_ifile. Some functions that don't know the root object are extended to receive it from caller. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/super.c')
-rw-r--r--fs/nilfs2/super.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index adbf5826b837..87c57810ae88 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -358,9 +358,9 @@ static void nilfs_put_super(struct super_block *sb)
358 down_write(&nilfs->ns_super_sem); 358 down_write(&nilfs->ns_super_sem);
359 if (nilfs->ns_current == sbi) 359 if (nilfs->ns_current == sbi)
360 nilfs->ns_current = NULL; 360 nilfs->ns_current = NULL;
361 list_del_init(&sbi->s_list);
361 up_write(&nilfs->ns_super_sem); 362 up_write(&nilfs->ns_super_sem);
362 363
363 nilfs_detach_checkpoint(sbi);
364 put_nilfs(sbi->s_nilfs); 364 put_nilfs(sbi->s_nilfs);
365 sbi->s_super = NULL; 365 sbi->s_super = NULL;
366 sb->s_fs_info = NULL; 366 sb->s_fs_info = NULL;
@@ -405,13 +405,12 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno, int curr_mnt,
405 if (!root) 405 if (!root)
406 return err; 406 return err;
407 407
408 down_write(&nilfs->ns_super_sem); 408 if (root->ifile)
409 list_add(&sbi->s_list, &nilfs->ns_supers); 409 goto reuse; /* already attached checkpoint */
410 up_write(&nilfs->ns_super_sem);
411 410
412 sbi->s_ifile = nilfs_ifile_new(sbi, nilfs->ns_inode_size); 411 root->ifile = nilfs_ifile_new(sbi, nilfs->ns_inode_size);
413 if (!sbi->s_ifile) 412 if (!root->ifile)
414 goto delist; 413 goto failed;
415 414
416 down_read(&nilfs->ns_segctor_sem); 415 down_read(&nilfs->ns_segctor_sem);
417 err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp, 416 err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp,
@@ -427,7 +426,7 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno, int curr_mnt,
427 } 426 }
428 goto failed; 427 goto failed;
429 } 428 }
430 err = nilfs_read_inode_common(sbi->s_ifile, &raw_cp->cp_ifile_inode); 429 err = nilfs_read_inode_common(root->ifile, &raw_cp->cp_ifile_inode);
431 if (unlikely(err)) 430 if (unlikely(err))
432 goto failed_bh; 431 goto failed_bh;
433 atomic_set(&sbi->s_inodes_count, le64_to_cpu(raw_cp->cp_inodes_count)); 432 atomic_set(&sbi->s_inodes_count, le64_to_cpu(raw_cp->cp_inodes_count));
@@ -435,35 +434,18 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno, int curr_mnt,
435 434
436 nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, cno, bh_cp); 435 nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, cno, bh_cp);
437 436
437 reuse:
438 *rootp = root; 438 *rootp = root;
439 return 0; 439 return 0;
440 440
441 failed_bh: 441 failed_bh:
442 nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, cno, bh_cp); 442 nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, cno, bh_cp);
443 failed: 443 failed:
444 nilfs_mdt_destroy(sbi->s_ifile);
445 sbi->s_ifile = NULL;
446
447 delist:
448 down_write(&nilfs->ns_super_sem);
449 list_del_init(&sbi->s_list);
450 up_write(&nilfs->ns_super_sem);
451 nilfs_put_root(root); 444 nilfs_put_root(root);
452 445
453 return err; 446 return err;
454} 447}
455 448
456void nilfs_detach_checkpoint(struct nilfs_sb_info *sbi)
457{
458 struct the_nilfs *nilfs = sbi->s_nilfs;
459
460 nilfs_mdt_destroy(sbi->s_ifile);
461 sbi->s_ifile = NULL;
462 down_write(&nilfs->ns_super_sem);
463 list_del_init(&sbi->s_list);
464 up_write(&nilfs->ns_super_sem);
465}
466
467static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf) 449static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf)
468{ 450{
469 struct super_block *sb = dentry->d_sb; 451 struct super_block *sb = dentry->d_sb;
@@ -862,7 +844,7 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent,
862 } 844 }
863 845
864 if (!(sb->s_flags & MS_RDONLY)) { 846 if (!(sb->s_flags & MS_RDONLY)) {
865 err = nilfs_attach_segment_constructor(sbi); 847 err = nilfs_attach_segment_constructor(sbi, fsroot);
866 if (err) 848 if (err)
867 goto failed_checkpoint; 849 goto failed_checkpoint;
868 } 850 }
@@ -896,6 +878,7 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent,
896 } 878 }
897 879
898 down_write(&nilfs->ns_super_sem); 880 down_write(&nilfs->ns_super_sem);
881 list_add(&sbi->s_list, &nilfs->ns_supers);
899 if (!nilfs_test_opt(sbi, SNAPSHOT)) 882 if (!nilfs_test_opt(sbi, SNAPSHOT))
900 nilfs->ns_current = sbi; 883 nilfs->ns_current = sbi;
901 up_write(&nilfs->ns_super_sem); 884 up_write(&nilfs->ns_super_sem);
@@ -906,7 +889,6 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent,
906 nilfs_detach_segment_constructor(sbi); 889 nilfs_detach_segment_constructor(sbi);
907 890
908 failed_checkpoint: 891 failed_checkpoint:
909 nilfs_detach_checkpoint(sbi);
910 nilfs_put_root(fsroot); 892 nilfs_put_root(fsroot);
911 893
912 failed_sbi: 894 failed_sbi:
@@ -966,6 +948,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
966 up_write(&nilfs->ns_sem); 948 up_write(&nilfs->ns_sem);
967 } else { 949 } else {
968 __u64 features; 950 __u64 features;
951 struct nilfs_root *root;
969 952
970 /* 953 /*
971 * Mounting a RDONLY partition read-write, so reread and 954 * Mounting a RDONLY partition read-write, so reread and
@@ -987,7 +970,8 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
987 970
988 sb->s_flags &= ~MS_RDONLY; 971 sb->s_flags &= ~MS_RDONLY;
989 972
990 err = nilfs_attach_segment_constructor(sbi); 973 root = NILFS_I(sb->s_root->d_inode)->i_root;
974 err = nilfs_attach_segment_constructor(sbi, root);
991 if (err) 975 if (err)
992 goto restore_opts; 976 goto restore_opts;
993 977