]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfsd/export.c
[PATCH] knfsd: nfsd: store export path in export
[linux-2.6-omap-h63xx.git] / fs / nfsd / export.c
index 3eec30000f3fb3955e029283e8a26bee184b66ba..d3178de589e42aeed21053e199b07bf16bb381a5 100644 (file)
@@ -126,7 +126,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
        if (*ep)
                goto out;
        dprintk("found fsidtype %d\n", fsidtype);
-       if (fsidtype > 2)
+       if (key_len(fsidtype)==0) /* invalid type */
                goto out;
        if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
                goto out;
@@ -325,6 +325,7 @@ static void svc_export_put(struct kref *ref)
        dput(exp->ex_dentry);
        mntput(exp->ex_mnt);
        auth_domain_put(exp->ex_client);
+       kfree(exp->ex_path);
        kfree(exp);
 }
 
@@ -370,7 +371,7 @@ static int check_export(struct inode *inode, int flags)
         */
        if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) &&
            !(flags & NFSEXP_FSID)) {
-               dprintk("exp_export: export of non-dev fs without fsid");
+               dprintk("exp_export: export of non-dev fs without fsid\n");
                return -EINVAL;
        }
        if (!inode->i_sb->s_export_op) {
@@ -398,6 +399,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
        int an_int;
 
        nd.dentry = NULL;
+       exp.ex_path = NULL;
 
        if (mesg[mlen-1] != '\n')
                return -EINVAL;
@@ -428,6 +430,10 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
        exp.ex_client = dom;
        exp.ex_mnt = nd.mnt;
        exp.ex_dentry = nd.dentry;
+       exp.ex_path = kstrdup(buf, GFP_KERNEL);
+       err = -ENOMEM;
+       if (!exp.ex_path)
+               goto out;
 
        /* expiry */
        err = -EINVAL;
@@ -473,6 +479,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
        else
                exp_put(expp);
  out:
+       kfree(exp.ex_path);
        if (nd.dentry)
                path_release(&nd);
  out_no_path:
@@ -524,6 +531,7 @@ static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
        new->ex_client = item->ex_client;
        new->ex_dentry = dget(item->ex_dentry);
        new->ex_mnt = mntget(item->ex_mnt);
+       new->ex_path = NULL;
 }
 
 static void export_update(struct cache_head *cnew, struct cache_head *citem)
@@ -535,6 +543,8 @@ static void export_update(struct cache_head *cnew, struct cache_head *citem)
        new->ex_anon_uid = item->ex_anon_uid;
        new->ex_anon_gid = item->ex_anon_gid;
        new->ex_fsid = item->ex_fsid;
+       new->ex_path = item->ex_path;
+       item->ex_path = NULL;
 }
 
 static struct cache_head *svc_export_alloc(void)
@@ -1048,36 +1058,28 @@ int
 exp_pseudoroot(struct auth_domain *clp, struct svc_fh *fhp,
               struct cache_req *creq)
 {
-       struct svc_expkey *fsid_key;
        struct svc_export *exp;
        int rv;
        u32 fsidv[2];
 
        mk_fsid_v1(fsidv, 0);
 
-       fsid_key = exp_find_key(clp, 1, fsidv, creq);
-       if (IS_ERR(fsid_key) && PTR_ERR(fsid_key) == -EAGAIN)
+       exp = exp_find(clp, 1, fsidv, creq);
+       if (IS_ERR(exp) && PTR_ERR(exp) == -EAGAIN)
                return nfserr_dropit;
-       if (!fsid_key || IS_ERR(fsid_key))
-               return nfserr_perm;
-
-       exp = exp_get_by_name(clp, fsid_key->ek_mnt, fsid_key->ek_dentry, creq);
        if (exp == NULL)
-               rv = nfserr_perm;
+               return nfserr_perm;
        else if (IS_ERR(exp))
-               rv = nfserrno(PTR_ERR(exp));
-       else {
-               rv = fh_compose(fhp, exp,
-                               fsid_key->ek_dentry, NULL);
-               exp_put(exp);
-       }
-       cache_put(&fsid_key->h, &svc_expkey_cache);
+               return nfserrno(PTR_ERR(exp));
+       rv = fh_compose(fhp, exp, exp->ex_dentry, NULL);
+       exp_put(exp);
        return rv;
 }
 
 /* Iterator */
 
 static void *e_start(struct seq_file *m, loff_t *pos)
+       __acquires(svc_export_cache.hash_lock)
 {
        loff_t n = *pos;
        unsigned hash, export;
@@ -1086,7 +1088,7 @@ static void *e_start(struct seq_file *m, loff_t *pos)
        exp_readlock();
        read_lock(&svc_export_cache.hash_lock);
        if (!n--)
-               return (void *)1;
+               return SEQ_START_TOKEN;
        hash = n >> 32;
        export = n & ((1LL<<32) - 1);
 
@@ -1110,7 +1112,7 @@ static void *e_next(struct seq_file *m, void *p, loff_t *pos)
        struct cache_head *ch = p;
        int hash = (*pos >> 32);
 
-       if (p == (void *)1)
+       if (p == SEQ_START_TOKEN)
                hash = 0;
        else if (ch->next == NULL) {
                hash++;
@@ -1131,6 +1133,7 @@ static void *e_next(struct seq_file *m, void *p, loff_t *pos)
 }
 
 static void e_stop(struct seq_file *m, void *p)
+       __releases(svc_export_cache.hash_lock)
 {
        read_unlock(&svc_export_cache.hash_lock);
        exp_readunlock();
@@ -1178,15 +1181,13 @@ static int e_show(struct seq_file *m, void *p)
 {
        struct cache_head *cp = p;
        struct svc_export *exp = container_of(cp, struct svc_export, h);
-       svc_client *clp;
 
-       if (p == (void *)1) {
+       if (p == SEQ_START_TOKEN) {
                seq_puts(m, "# Version 1.1\n");
                seq_puts(m, "# Path Client(Flags) # IPs\n");
                return 0;
        }
 
-       clp = exp->ex_client;
        cache_get(&exp->h);
        if (cache_check(&svc_export_cache, &exp->h, NULL))
                return 0;