aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/super.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2011-03-08 21:05:08 -0500
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2011-03-08 21:54:26 -0500
commite3154e9748f0f337e9f6ff9dc7d7bf24d426bd1a (patch)
treeac2a3f3dca6189b8a608571c49da66386fd1bdec /fs/nilfs2/super.c
parentf7545144c2e3d280139260df934043e0a6ccce6f (diff)
nilfs2: get rid of nilfs_sb_info structure
This directly uses sb->s_fs_info to keep a nilfs filesystem object and fully removes the intermediate nilfs_sb_info structure. With this change, the hierarchy of on-memory structures of nilfs will be simplified as follows: Before: super_block -> nilfs_sb_info -> the_nilfs -> cptree --+-> nilfs_root (current file system) +-> nilfs_root (snapshot A) +-> nilfs_root (snapshot B) : -> nilfs_sc_info (log writer structure) After: super_block -> the_nilfs -> cptree --+-> nilfs_root (current file system) +-> nilfs_root (snapshot A) +-> nilfs_root (snapshot B) : -> nilfs_sc_info (log writer structure) The reason why we didn't design so from the beginning is because the initial shape also differed from the above. The early hierachy was composed of "per-mount-point" super_block -> nilfs_sb_info pairs and a shared nilfs object. On the kernel 2.6.37, it was changed to the current shape in order to unify super block instances into one per device, and this cleanup became applicable as the result. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/super.c')
-rw-r--r--fs/nilfs2/super.c63
1 files changed, 23 insertions, 40 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index a8cbd695441..062cca06519 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -76,7 +76,7 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data);
76 76
77static void nilfs_set_error(struct super_block *sb) 77static void nilfs_set_error(struct super_block *sb)
78{ 78{
79 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 79 struct the_nilfs *nilfs = sb->s_fs_info;
80 struct nilfs_super_block **sbp; 80 struct nilfs_super_block **sbp;
81 81
82 down_write(&nilfs->ns_sem); 82 down_write(&nilfs->ns_sem);
@@ -108,7 +108,7 @@ static void nilfs_set_error(struct super_block *sb)
108void nilfs_error(struct super_block *sb, const char *function, 108void nilfs_error(struct super_block *sb, const char *function,
109 const char *fmt, ...) 109 const char *fmt, ...)
110{ 110{
111 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 111 struct the_nilfs *nilfs = sb->s_fs_info;
112 struct va_format vaf; 112 struct va_format vaf;
113 va_list args; 113 va_list args;
114 114
@@ -190,7 +190,7 @@ void nilfs_destroy_inode(struct inode *inode)
190 190
191static int nilfs_sync_super(struct super_block *sb, int flag) 191static int nilfs_sync_super(struct super_block *sb, int flag)
192{ 192{
193 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 193 struct the_nilfs *nilfs = sb->s_fs_info;
194 int err; 194 int err;
195 195
196 retry: 196 retry:
@@ -265,7 +265,7 @@ void nilfs_set_log_cursor(struct nilfs_super_block *sbp,
265struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb, 265struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb,
266 int flip) 266 int flip)
267{ 267{
268 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 268 struct the_nilfs *nilfs = sb->s_fs_info;
269 struct nilfs_super_block **sbp = nilfs->ns_sbp; 269 struct nilfs_super_block **sbp = nilfs->ns_sbp;
270 270
271 /* nilfs->ns_sem must be locked by the caller. */ 271 /* nilfs->ns_sem must be locked by the caller. */
@@ -291,7 +291,7 @@ struct nilfs_super_block **nilfs_prepare_super(struct super_block *sb,
291 291
292int nilfs_commit_super(struct super_block *sb, int flag) 292int nilfs_commit_super(struct super_block *sb, int flag)
293{ 293{
294 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 294 struct the_nilfs *nilfs = sb->s_fs_info;
295 struct nilfs_super_block **sbp = nilfs->ns_sbp; 295 struct nilfs_super_block **sbp = nilfs->ns_sbp;
296 time_t t; 296 time_t t;
297 297
@@ -324,7 +324,7 @@ int nilfs_commit_super(struct super_block *sb, int flag)
324 */ 324 */
325int nilfs_cleanup_super(struct super_block *sb) 325int nilfs_cleanup_super(struct super_block *sb)
326{ 326{
327 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 327 struct the_nilfs *nilfs = sb->s_fs_info;
328 struct nilfs_super_block **sbp; 328 struct nilfs_super_block **sbp;
329 int flag = NILFS_SB_COMMIT; 329 int flag = NILFS_SB_COMMIT;
330 int ret = -EIO; 330 int ret = -EIO;
@@ -349,8 +349,7 @@ int nilfs_cleanup_super(struct super_block *sb)
349 349
350static void nilfs_put_super(struct super_block *sb) 350static void nilfs_put_super(struct super_block *sb)
351{ 351{
352 struct nilfs_sb_info *sbi = NILFS_SB(sb); 352 struct the_nilfs *nilfs = sb->s_fs_info;
353 struct the_nilfs *nilfs = sbi->s_nilfs;
354 353
355 nilfs_detach_log_writer(sb); 354 nilfs_detach_log_writer(sb);
356 355
@@ -365,14 +364,12 @@ static void nilfs_put_super(struct super_block *sb)
365 iput(nilfs->ns_dat); 364 iput(nilfs->ns_dat);
366 365
367 destroy_nilfs(nilfs); 366 destroy_nilfs(nilfs);
368 sbi->s_super = NULL;
369 sb->s_fs_info = NULL; 367 sb->s_fs_info = NULL;
370 kfree(sbi);
371} 368}
372 369
373static int nilfs_sync_fs(struct super_block *sb, int wait) 370static int nilfs_sync_fs(struct super_block *sb, int wait)
374{ 371{
375 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 372 struct the_nilfs *nilfs = sb->s_fs_info;
376 struct nilfs_super_block **sbp; 373 struct nilfs_super_block **sbp;
377 int err = 0; 374 int err = 0;
378 375
@@ -396,7 +393,7 @@ static int nilfs_sync_fs(struct super_block *sb, int wait)
396int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt, 393int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt,
397 struct nilfs_root **rootp) 394 struct nilfs_root **rootp)
398{ 395{
399 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 396 struct the_nilfs *nilfs = sb->s_fs_info;
400 struct nilfs_root *root; 397 struct nilfs_root *root;
401 struct nilfs_checkpoint *raw_cp; 398 struct nilfs_checkpoint *raw_cp;
402 struct buffer_head *bh_cp; 399 struct buffer_head *bh_cp;
@@ -449,7 +446,7 @@ int nilfs_attach_checkpoint(struct super_block *sb, __u64 cno, int curr_mnt,
449 446
450static int nilfs_freeze(struct super_block *sb) 447static int nilfs_freeze(struct super_block *sb)
451{ 448{
452 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 449 struct the_nilfs *nilfs = sb->s_fs_info;
453 int err; 450 int err;
454 451
455 if (sb->s_flags & MS_RDONLY) 452 if (sb->s_flags & MS_RDONLY)
@@ -464,7 +461,7 @@ static int nilfs_freeze(struct super_block *sb)
464 461
465static int nilfs_unfreeze(struct super_block *sb) 462static int nilfs_unfreeze(struct super_block *sb)
466{ 463{
467 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 464 struct the_nilfs *nilfs = sb->s_fs_info;
468 465
469 if (sb->s_flags & MS_RDONLY) 466 if (sb->s_flags & MS_RDONLY)
470 return 0; 467 return 0;
@@ -527,7 +524,7 @@ static int nilfs_statfs(struct dentry *dentry, struct kstatfs *buf)
527static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs) 524static int nilfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
528{ 525{
529 struct super_block *sb = vfs->mnt_sb; 526 struct super_block *sb = vfs->mnt_sb;
530 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 527 struct the_nilfs *nilfs = sb->s_fs_info;
531 struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root; 528 struct nilfs_root *root = NILFS_I(vfs->mnt_root->d_inode)->i_root;
532 529
533 if (!nilfs_test_opt(nilfs, BARRIER)) 530 if (!nilfs_test_opt(nilfs, BARRIER))
@@ -591,7 +588,7 @@ static match_table_t tokens = {
591 588
592static int parse_options(char *options, struct super_block *sb, int is_remount) 589static int parse_options(char *options, struct super_block *sb, int is_remount)
593{ 590{
594 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 591 struct the_nilfs *nilfs = sb->s_fs_info;
595 char *p; 592 char *p;
596 substring_t args[MAX_OPT_ARGS]; 593 substring_t args[MAX_OPT_ARGS];
597 594
@@ -660,7 +657,7 @@ static inline void
660nilfs_set_default_options(struct super_block *sb, 657nilfs_set_default_options(struct super_block *sb,
661 struct nilfs_super_block *sbp) 658 struct nilfs_super_block *sbp)
662{ 659{
663 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 660 struct the_nilfs *nilfs = sb->s_fs_info;
664 661
665 nilfs->ns_mount_opt = 662 nilfs->ns_mount_opt =
666 NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER; 663 NILFS_MOUNT_ERRORS_RO | NILFS_MOUNT_BARRIER;
@@ -668,7 +665,7 @@ nilfs_set_default_options(struct super_block *sb,
668 665
669static int nilfs_setup_super(struct super_block *sb, int is_mount) 666static int nilfs_setup_super(struct super_block *sb, int is_mount)
670{ 667{
671 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 668 struct the_nilfs *nilfs = sb->s_fs_info;
672 struct nilfs_super_block **sbp; 669 struct nilfs_super_block **sbp;
673 int max_mnt_count; 670 int max_mnt_count;
674 int mnt_count; 671 int mnt_count;
@@ -726,7 +723,7 @@ int nilfs_store_magic_and_option(struct super_block *sb,
726 struct nilfs_super_block *sbp, 723 struct nilfs_super_block *sbp,
727 char *data) 724 char *data)
728{ 725{
729 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 726 struct the_nilfs *nilfs = sb->s_fs_info;
730 727
731 sb->s_magic = le16_to_cpu(sbp->s_magic); 728 sb->s_magic = le16_to_cpu(sbp->s_magic);
732 729
@@ -821,7 +818,7 @@ static int nilfs_get_root_dentry(struct super_block *sb,
821static int nilfs_attach_snapshot(struct super_block *s, __u64 cno, 818static int nilfs_attach_snapshot(struct super_block *s, __u64 cno,
822 struct dentry **root_dentry) 819 struct dentry **root_dentry)
823{ 820{
824 struct the_nilfs *nilfs = NILFS_SB(s)->s_nilfs; 821 struct the_nilfs *nilfs = s->s_fs_info;
825 struct nilfs_root *root; 822 struct nilfs_root *root;
826 int ret; 823 int ret;
827 824
@@ -873,7 +870,7 @@ static int nilfs_try_to_shrink_tree(struct dentry *root_dentry)
873 870
874int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno) 871int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno)
875{ 872{
876 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 873 struct the_nilfs *nilfs = sb->s_fs_info;
877 struct nilfs_root *root; 874 struct nilfs_root *root;
878 struct inode *inode; 875 struct inode *inode;
879 struct dentry *dentry; 876 struct dentry *dentry;
@@ -886,7 +883,7 @@ int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno)
886 return true; /* protect recent checkpoints */ 883 return true; /* protect recent checkpoints */
887 884
888 ret = false; 885 ret = false;
889 root = nilfs_lookup_root(NILFS_SB(sb)->s_nilfs, cno); 886 root = nilfs_lookup_root(nilfs, cno);
890 if (root) { 887 if (root) {
891 inode = nilfs_ilookup(sb, root, NILFS_ROOT_INO); 888 inode = nilfs_ilookup(sb, root, NILFS_ROOT_INO);
892 if (inode) { 889 if (inode) {
@@ -916,25 +913,16 @@ static int
916nilfs_fill_super(struct super_block *sb, void *data, int silent) 913nilfs_fill_super(struct super_block *sb, void *data, int silent)
917{ 914{
918 struct the_nilfs *nilfs; 915 struct the_nilfs *nilfs;
919 struct nilfs_sb_info *sbi;
920 struct nilfs_root *fsroot; 916 struct nilfs_root *fsroot;
921 struct backing_dev_info *bdi; 917 struct backing_dev_info *bdi;
922 __u64 cno; 918 __u64 cno;
923 int err; 919 int err;
924 920
925 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 921 nilfs = alloc_nilfs(sb->s_bdev);
926 if (!sbi) 922 if (!nilfs)
927 return -ENOMEM; 923 return -ENOMEM;
928 924
929 sb->s_fs_info = sbi; 925 sb->s_fs_info = nilfs;
930 sbi->s_super = sb;
931
932 nilfs = alloc_nilfs(sb->s_bdev);
933 if (!nilfs) {
934 err = -ENOMEM;
935 goto failed_sbi;
936 }
937 sbi->s_nilfs = nilfs;
938 926
939 err = init_nilfs(nilfs, sb, (char *)data); 927 err = init_nilfs(nilfs, sb, (char *)data);
940 if (err) 928 if (err)
@@ -993,16 +981,12 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent)
993 981
994 failed_nilfs: 982 failed_nilfs:
995 destroy_nilfs(nilfs); 983 destroy_nilfs(nilfs);
996
997 failed_sbi:
998 sb->s_fs_info = NULL;
999 kfree(sbi);
1000 return err; 984 return err;
1001} 985}
1002 986
1003static int nilfs_remount(struct super_block *sb, int *flags, char *data) 987static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1004{ 988{
1005 struct the_nilfs *nilfs = NILFS_SB(sb)->s_nilfs; 989 struct the_nilfs *nilfs = sb->s_fs_info;
1006 unsigned long old_sb_flags; 990 unsigned long old_sb_flags;
1007 unsigned long old_mount_opt; 991 unsigned long old_mount_opt;
1008 int err; 992 int err;
@@ -1083,7 +1067,6 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1083 1067
1084struct nilfs_super_data { 1068struct nilfs_super_data {
1085 struct block_device *bdev; 1069 struct block_device *bdev;
1086 struct nilfs_sb_info *sbi;
1087 __u64 cno; 1070 __u64 cno;
1088 int flags; 1071 int flags;
1089}; 1072};