]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfs/getroot.c
[PATCH] switch all filesystems over to d_obtain_alias
[linux-2.6-omap-h63xx.git] / fs / nfs / getroot.c
index fae97196daadb74c1dd1c28a5767460557402478..b7c9b2df1f299dd15d30b81d533b602d8ae09572 100644 (file)
@@ -107,11 +107,10 @@ struct dentry *nfs_get_root(struct super_block *sb, struct nfs_fh *mntfh)
         * if the dentry tree reaches them; however if the dentry already
         * exists, we'll pick it up at this point and use it as the root
         */
-       mntroot = d_alloc_anon(inode);
-       if (!mntroot) {
-               iput(inode);
+       mntroot = d_obtain_alias(inode);
+       if (IS_ERR(mntroot)) {
                dprintk("nfs_get_root: get root dentry failed\n");
-               return ERR_PTR(-ENOMEM);
+               return mntroot;
        }
 
        security_d_instantiate(mntroot, inode);
@@ -277,11 +276,10 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh)
         * if the dentry tree reaches them; however if the dentry already
         * exists, we'll pick it up at this point and use it as the root
         */
-       mntroot = d_alloc_anon(inode);
-       if (!mntroot) {
-               iput(inode);
+       mntroot = d_obtain_alias(inode);
+       if (IS_ERR(mntroot)) {
                dprintk("nfs_get_root: get root dentry failed\n");
-               return ERR_PTR(-ENOMEM);
+               return mntroot;
        }
 
        security_d_instantiate(mntroot, inode);