aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-08-25 12:52:51 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-10-22 20:24:35 -0400
commit367ea33486a68f935a01311a3be9b7e97d2e5ead (patch)
treede5ccfd05a527bc85ba63b9f22fdef57bfa80053 /fs/nilfs2
parentdc3d3b810a644dfa329efaa230cd514226f8981d (diff)
nilfs2: split out nilfs_get_root_dentry
This splits the code to allocate root dentry into a separate routine for convenience in successive changes. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/super.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index acfa74e45f0b..1e12930f8b94 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -750,6 +750,39 @@ int nilfs_check_feature_compatibility(struct super_block *sb,
750 return 0; 750 return 0;
751} 751}
752 752
753static int nilfs_get_root_dentry(struct super_block *sb,
754 struct nilfs_root *root,
755 struct dentry **root_dentry)
756{
757 struct inode *inode;
758 struct dentry *dentry;
759 int ret = 0;
760
761 inode = nilfs_iget(sb, root, NILFS_ROOT_INO);
762 if (IS_ERR(inode)) {
763 printk(KERN_ERR "NILFS: get root inode failed\n");
764 ret = PTR_ERR(inode);
765 goto out;
766 }
767 if (!S_ISDIR(inode->i_mode) || !inode->i_blocks || !inode->i_size) {
768 iput(inode);
769 printk(KERN_ERR "NILFS: corrupt root inode.\n");
770 ret = -EINVAL;
771 goto out;
772 }
773
774 dentry = d_alloc_root(inode);
775 if (!dentry) {
776 iput(inode);
777 printk(KERN_ERR "NILFS: get root dentry failed\n");
778 ret = -ENOMEM;
779 goto out;
780 }
781 *root_dentry = dentry;
782 out:
783 return ret;
784}
785
753/** 786/**
754 * nilfs_fill_super() - initialize a super block instance 787 * nilfs_fill_super() - initialize a super block instance
755 * @sb: super_block 788 * @sb: super_block
@@ -766,7 +799,6 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent,
766{ 799{
767 struct nilfs_sb_info *sbi; 800 struct nilfs_sb_info *sbi;
768 struct nilfs_root *fsroot; 801 struct nilfs_root *fsroot;
769 struct inode *root;
770 __u64 cno; 802 __u64 cno;
771 int err, curr_mnt; 803 int err, curr_mnt;
772 804
@@ -850,25 +882,9 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent,
850 goto failed_checkpoint; 882 goto failed_checkpoint;
851 } 883 }
852 884
853 root = nilfs_iget(sb, fsroot, NILFS_ROOT_INO); 885 err = nilfs_get_root_dentry(sb, fsroot, &sb->s_root);
854 if (IS_ERR(root)) { 886 if (err)
855 printk(KERN_ERR "NILFS: get root inode failed\n");
856 err = PTR_ERR(root);
857 goto failed_segctor;
858 }
859 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
860 iput(root);
861 printk(KERN_ERR "NILFS: corrupt root inode.\n");
862 err = -EINVAL;
863 goto failed_segctor;
864 }
865 sb->s_root = d_alloc_root(root);
866 if (!sb->s_root) {
867 iput(root);
868 printk(KERN_ERR "NILFS: get root dentry failed\n");
869 err = -ENOMEM;
870 goto failed_segctor; 887 goto failed_segctor;
871 }
872 888
873 nilfs_put_root(fsroot); 889 nilfs_put_root(fsroot);
874 890