]> err.no Git - linux-2.6/blobdiff - fs/nfsd/export.c
Embed a struct path into struct nameidata instead of nd->{dentry,mnt}
[linux-2.6] / fs / nfsd / export.c
index 04b266729802f698c1203577c4ad52a78ed71ae6..2ac0e30285c2ce37e105a6a0b7cdfcb4b2605290 100644 (file)
@@ -169,8 +169,8 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
                        goto out;
 
                dprintk("Found the path %s\n", buf);
-               key.ek_mnt = nd.mnt;
-               key.ek_dentry = nd.dentry;
+               key.ek_mnt = nd.path.mnt;
+               key.ek_dentry = nd.path.dentry;
                
                ek = svc_expkey_update(&key, ek);
                if (ek)
@@ -386,15 +386,13 @@ static int check_export(struct inode *inode, int flags, unsigned char *uuid)
                dprintk("exp_export: export of non-dev fs without fsid\n");
                return -EINVAL;
        }
-       if (!inode->i_sb->s_export_op) {
+
+       if (!inode->i_sb->s_export_op ||
+           !inode->i_sb->s_export_op->fh_to_dentry) {
                dprintk("exp_export: export of invalid fs type.\n");
                return -EINVAL;
        }
 
-       /* Ok, we can export it */;
-       if (!inode->i_sb->s_export_op->find_exported_dentry)
-               inode->i_sb->s_export_op->find_exported_dentry =
-                       find_exported_dentry;
        return 0;
 
 }
@@ -509,7 +507,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
        struct svc_export exp, *expp;
        int an_int;
 
-       nd.dentry = NULL;
+       nd.path.dentry = NULL;
        exp.ex_path = NULL;
 
        /* fs locations */
@@ -549,8 +547,8 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
 
        exp.h.flags = 0;
        exp.ex_client = dom;
-       exp.ex_mnt = nd.mnt;
-       exp.ex_dentry = nd.dentry;
+       exp.ex_mnt = nd.path.mnt;
+       exp.ex_dentry = nd.path.dentry;
        exp.ex_path = kstrdup(buf, GFP_KERNEL);
        err = -ENOMEM;
        if (!exp.ex_path)
@@ -612,7 +610,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
                                goto out;
                }
 
-               err = check_export(nd.dentry->d_inode, exp.ex_flags,
+               err = check_export(nd.path.dentry->d_inode, exp.ex_flags,
                                   exp.ex_uuid);
                if (err) goto out;
        }
@@ -631,7 +629,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
        nfsd4_fslocs_free(&exp.ex_fslocs);
        kfree(exp.ex_uuid);
        kfree(exp.ex_path);
-       if (nd.dentry)
+       if (nd.path.dentry)
                path_release(&nd);
  out_no_path:
        if (dom)
@@ -1032,7 +1030,7 @@ exp_export(struct nfsctl_export *nxp)
                goto out_unlock;
        err = -EINVAL;
 
-       exp = exp_get_by_name(clp, nd.mnt, nd.dentry, NULL);
+       exp = exp_get_by_name(clp, nd.path.mnt, nd.path.dentry, NULL);
 
        memset(&new, 0, sizeof(new));
 
@@ -1040,7 +1038,8 @@ exp_export(struct nfsctl_export *nxp)
        if ((nxp->ex_flags & NFSEXP_FSID) &&
            (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) &&
            fsid_key->ek_mnt &&
-           (fsid_key->ek_mnt != nd.mnt || fsid_key->ek_dentry != nd.dentry) )
+           (fsid_key->ek_mnt != nd.path.mnt ||
+            fsid_key->ek_dentry != nd.path.dentry))
                goto finish;
 
        if (!IS_ERR(exp)) {
@@ -1056,7 +1055,7 @@ exp_export(struct nfsctl_export *nxp)
                goto finish;
        }
 
-       err = check_export(nd.dentry->d_inode, nxp->ex_flags, NULL);
+       err = check_export(nd.path.dentry->d_inode, nxp->ex_flags, NULL);
        if (err) goto finish;
 
        err = -ENOMEM;
@@ -1069,8 +1068,8 @@ exp_export(struct nfsctl_export *nxp)
        if (!new.ex_path)
                goto finish;
        new.ex_client = clp;
-       new.ex_mnt = nd.mnt;
-       new.ex_dentry = nd.dentry;
+       new.ex_mnt = nd.path.mnt;
+       new.ex_dentry = nd.path.dentry;
        new.ex_flags = nxp->ex_flags;
        new.ex_anon_uid = nxp->ex_anon_uid;
        new.ex_anon_gid = nxp->ex_anon_gid;
@@ -1150,7 +1149,7 @@ exp_unexport(struct nfsctl_export *nxp)
                goto out_domain;
 
        err = -EINVAL;
-       exp = exp_get_by_name(dom, nd.mnt, nd.dentry, NULL);
+       exp = exp_get_by_name(dom, nd.path.mnt, nd.path.dentry, NULL);
        path_release(&nd);
        if (IS_ERR(exp))
                goto out_domain;
@@ -1187,12 +1186,12 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
                printk("nfsd: exp_rootfh path not found %s", path);
                return err;
        }
-       inode = nd.dentry->d_inode;
+       inode = nd.path.dentry->d_inode;
 
        dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n",
-                path, nd.dentry, clp->name,
+                path, nd.path.dentry, clp->name,
                 inode->i_sb->s_id, inode->i_ino);
-       exp = exp_parent(clp, nd.mnt, nd.dentry, NULL);
+       exp = exp_parent(clp, nd.path.mnt, nd.path.dentry, NULL);
        if (IS_ERR(exp)) {
                err = PTR_ERR(exp);
                goto out;
@@ -1202,7 +1201,7 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
         * fh must be initialized before calling fh_compose
         */
        fh_init(&fh, maxsize);
-       if (fh_compose(&fh, exp, nd.dentry, NULL))
+       if (fh_compose(&fh, exp, nd.path.dentry, NULL))
                err = -EINVAL;
        else
                err = 0;
@@ -1220,13 +1219,13 @@ static struct svc_export *exp_find(struct auth_domain *clp, int fsid_type,
        struct svc_export *exp;
        struct svc_expkey *ek = exp_find_key(clp, fsid_type, fsidv, reqp);
        if (IS_ERR(ek))
-               return ERR_PTR(PTR_ERR(ek));
+               return ERR_CAST(ek);
 
        exp = exp_get_by_name(clp, ek->ek_mnt, ek->ek_dentry, reqp);
        cache_put(&ek->h, &svc_expkey_cache);
 
        if (IS_ERR(exp))
-               return ERR_PTR(PTR_ERR(exp));
+               return ERR_CAST(exp);
        return exp;
 }
 
@@ -1359,8 +1358,6 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
        mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);
 
        exp = rqst_exp_find(rqstp, FSID_NUM, fsidv);
-       if (PTR_ERR(exp) == -ENOENT)
-               return nfserr_perm;
        if (IS_ERR(exp))
                return nfserrno(PTR_ERR(exp));
        rv = fh_compose(fhp, exp, exp->ex_dentry, NULL);
@@ -1639,13 +1636,19 @@ exp_verify_string(char *cp, int max)
 /*
  * Initialize the exports module.
  */
-void
+int
 nfsd_export_init(void)
 {
+       int rv;
        dprintk("nfsd: initializing export module.\n");
 
-       cache_register(&svc_export_cache);
-       cache_register(&svc_expkey_cache);
+       rv = cache_register(&svc_export_cache);
+       if (rv)
+               return rv;
+       rv = cache_register(&svc_expkey_cache);
+       if (rv)
+               cache_unregister(&svc_export_cache);
+       return rv;
 
 }
 
@@ -1672,10 +1675,8 @@ nfsd_export_shutdown(void)
 
        exp_writelock();
 
-       if (cache_unregister(&svc_expkey_cache))
-               printk(KERN_ERR "nfsd: failed to unregister expkey cache\n");
-       if (cache_unregister(&svc_export_cache))
-               printk(KERN_ERR "nfsd: failed to unregister export cache\n");
+       cache_unregister(&svc_expkey_cache);
+       cache_unregister(&svc_export_cache);
        svcauth_unix_purge();
 
        exp_writeunlock();