aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/export.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/export.c')
-rw-r--r--fs/nfsd/export.c434
1 files changed, 2 insertions, 432 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index d7c4f02..a0205fc 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -16,7 +16,6 @@
#include <linux/module.h>
#include <linux/exportfs.h>
-#include <linux/nfsd/syscall.h>
#include <net/ipv6.h>
#include "nfsd.h"
@@ -318,7 +317,6 @@ static void svc_export_put(struct kref *ref)
struct svc_export *exp = container_of(ref, struct svc_export, h.ref);
path_put(&exp->ex_path);
auth_domain_put(exp->ex_client);
- kfree(exp->ex_pathname);
nfsd4_fslocs_free(&exp->ex_fslocs);
kfree(exp);
}
@@ -528,11 +526,6 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
exp.ex_client = dom;
- err = -ENOMEM;
- exp.ex_pathname = kstrdup(buf, GFP_KERNEL);
- if (!exp.ex_pathname)
- goto out2;
-
/* expiry */
err = -EINVAL;
exp.h.expiry_time = get_expiry(&mesg);
@@ -613,8 +606,6 @@ out4:
nfsd4_fslocs_free(&exp.ex_fslocs);
kfree(exp.ex_uuid);
out3:
- kfree(exp.ex_pathname);
-out2:
path_put(&exp.ex_path);
out1:
auth_domain_put(dom);
@@ -678,7 +669,6 @@ static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
new->ex_client = item->ex_client;
new->ex_path.dentry = dget(item->ex_path.dentry);
new->ex_path.mnt = mntget(item->ex_path.mnt);
- new->ex_pathname = NULL;
new->ex_fslocs.locations = NULL;
new->ex_fslocs.locations_count = 0;
new->ex_fslocs.migrated = 0;
@@ -696,8 +686,6 @@ static void export_update(struct cache_head *cnew, struct cache_head *citem)
new->ex_fsid = item->ex_fsid;
new->ex_uuid = item->ex_uuid;
item->ex_uuid = NULL;
- new->ex_pathname = item->ex_pathname;
- item->ex_pathname = NULL;
new->ex_fslocs.locations = item->ex_fslocs.locations;
item->ex_fslocs.locations = NULL;
new->ex_fslocs.locations_count = item->ex_fslocs.locations_count;
@@ -797,58 +785,6 @@ exp_find_key(svc_client *clp, int fsid_type, u32 *fsidv, struct cache_req *reqp)
return ek;
}
-#ifdef CONFIG_NFSD_DEPRECATED
-static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv,
- struct svc_export *exp)
-{
- struct svc_expkey key, *ek;
-
- key.ek_client = clp;
- key.ek_fsidtype = fsid_type;
- memcpy(key.ek_fsid, fsidv, key_len(fsid_type));
- key.ek_path = exp->ex_path;
- key.h.expiry_time = NEVER;
- key.h.flags = 0;
-
- ek = svc_expkey_lookup(&key);
- if (ek)
- ek = svc_expkey_update(&key,ek);
- if (ek) {
- cache_put(&ek->h, &svc_expkey_cache);
- return 0;
- }
- return -ENOMEM;
-}
-
-/*
- * Find the client's export entry matching xdev/xino.
- */
-static inline struct svc_expkey *
-exp_get_key(svc_client *clp, dev_t dev, ino_t ino)
-{
- u32 fsidv[3];
-
- if (old_valid_dev(dev)) {
- mk_fsid(FSID_DEV, fsidv, dev, ino, 0, NULL);
- return exp_find_key(clp, FSID_DEV, fsidv, NULL);
- }
- mk_fsid(FSID_ENCODE_DEV, fsidv, dev, ino, 0, NULL);
- return exp_find_key(clp, FSID_ENCODE_DEV, fsidv, NULL);
-}
-
-/*
- * Find the client's export entry matching fsid
- */
-static inline struct svc_expkey *
-exp_get_fsid_key(svc_client *clp, int fsid)
-{
- u32 fsidv[2];
-
- mk_fsid(FSID_NUM, fsidv, 0, 0, fsid, NULL);
-
- return exp_find_key(clp, FSID_NUM, fsidv, NULL);
-}
-#endif
static svc_export *exp_get_by_name(svc_client *clp, const struct path *path,
struct cache_req *reqp)
@@ -890,275 +826,7 @@ static struct svc_export *exp_parent(svc_client *clp, struct path *path)
return exp;
}
-#ifdef CONFIG_NFSD_DEPRECATED
-/*
- * Hashtable locking. Write locks are placed only by user processes
- * wanting to modify export information.
- * Write locking only done in this file. Read locking
- * needed externally.
- */
-static DECLARE_RWSEM(hash_sem);
-
-void
-exp_readlock(void)
-{
- down_read(&hash_sem);
-}
-
-static inline void
-exp_writelock(void)
-{
- down_write(&hash_sem);
-}
-
-void
-exp_readunlock(void)
-{
- up_read(&hash_sem);
-}
-
-static inline void
-exp_writeunlock(void)
-{
- up_write(&hash_sem);
-}
-#else
-
-/* hash_sem not needed once deprecated interface is removed */
-void exp_readlock(void) {}
-static inline void exp_writelock(void){}
-void exp_readunlock(void) {}
-static inline void exp_writeunlock(void){}
-
-#endif
-
-#ifdef CONFIG_NFSD_DEPRECATED
-static void exp_do_unexport(svc_export *unexp);
-static int exp_verify_string(char *cp, int max);
-
-static void exp_fsid_unhash(struct svc_export *exp)
-{
- struct svc_expkey *ek;
-
- if ((exp->ex_flags & NFSEXP_FSID) == 0)
- return;
-
- ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid);
- if (!IS_ERR(ek)) {
- sunrpc_invalidate(&ek->h, &svc_expkey_cache);
- cache_put(&ek->h, &svc_expkey_cache);
- }
-}
-
-static int exp_fsid_hash(svc_client *clp, struct svc_export *exp)
-{
- u32 fsid[2];
-
- if ((exp->ex_flags & NFSEXP_FSID) == 0)
- return 0;
-
- mk_fsid(FSID_NUM, fsid, 0, 0, exp->ex_fsid, NULL);
- return exp_set_key(clp, FSID_NUM, fsid, exp);
-}
-
-static int exp_hash(struct auth_domain *clp, struct svc_export *exp)
-{
- u32 fsid[2];
- struct inode *inode = exp->ex_path.dentry->d_inode;
- dev_t dev = inode->i_sb->s_dev;
-
- if (old_valid_dev(dev)) {
- mk_fsid(FSID_DEV, fsid, dev, inode->i_ino, 0, NULL);
- return exp_set_key(clp, FSID_DEV, fsid, exp);
- }
- mk_fsid(FSID_ENCODE_DEV, fsid, dev, inode->i_ino, 0, NULL);
- return exp_set_key(clp, FSID_ENCODE_DEV, fsid, exp);
-}
-
-static void exp_unhash(struct svc_export *exp)
-{
- struct svc_expkey *ek;
- struct inode *inode = exp->ex_path.dentry->d_inode;
-
- ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino);
- if (!IS_ERR(ek)) {
- sunrpc_invalidate(&ek->h, &svc_expkey_cache);
- cache_put(&ek->h, &svc_expkey_cache);
- }
-}
-
-/*
- * Export a file system.
- */
-int
-exp_export(struct nfsctl_export *nxp)
-{
- svc_client *clp;
- struct svc_export *exp = NULL;
- struct svc_export new;
- struct svc_expkey *fsid_key = NULL;
- struct path path;
- int err;
-
- /* Consistency check */
- err = -EINVAL;
- if (!exp_verify_string(nxp->ex_path, NFS_MAXPATHLEN) ||
- !exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX))
- goto out;
-
- dprintk("exp_export called for %s:%s (%x/%ld fl %x).\n",
- nxp->ex_client, nxp->ex_path,
- (unsigned)nxp->ex_dev, (long)nxp->ex_ino,
- nxp->ex_flags);
-
- /* Try to lock the export table for update */
- exp_writelock();
-
- /* Look up client info */
- if (!(clp = auth_domain_find(nxp->ex_client)))
- goto out_unlock;
-
-
- /* Look up the dentry */
- err = kern_path(nxp->ex_path, 0, &path);
- if (err)
- goto out_put_clp;
- err = -EINVAL;
-
- exp = exp_get_by_name(clp, &path, NULL);
-
- memset(&new, 0, sizeof(new));
-
- /* must make sure there won't be an ex_fsid clash */
- if ((nxp->ex_flags & NFSEXP_FSID) &&
- (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) &&
- fsid_key->ek_path.mnt &&
- (fsid_key->ek_path.mnt != path.mnt ||
- fsid_key->ek_path.dentry != path.dentry))
- goto finish;
-
- if (!IS_ERR(exp)) {
- /* just a flags/id/fsid update */
-
- exp_fsid_unhash(exp);
- exp->ex_flags = nxp->ex_flags;
- exp->ex_anon_uid = nxp->ex_anon_uid;
- exp->ex_anon_gid = nxp->ex_anon_gid;
- exp->ex_fsid = nxp->ex_dev;
-
- err = exp_fsid_hash(clp, exp);
- goto finish;
- }
-
- err = check_export(path.dentry->d_inode, &nxp->ex_flags, NULL);
- if (err) goto finish;
-
- err = -ENOMEM;
-
- dprintk("nfsd: creating export entry %p for client %p\n", exp, clp);
-
- new.h.expiry_time = NEVER;
- new.h.flags = 0;
- new.ex_pathname = kstrdup(nxp->ex_path, GFP_KERNEL);
- if (!new.ex_pathname)
- goto finish;
- new.ex_client = clp;
- new.ex_path = path;
- new.ex_flags = nxp->ex_flags;
- new.ex_anon_uid = nxp->ex_anon_uid;
- new.ex_anon_gid = nxp->ex_anon_gid;
- new.ex_fsid = nxp->ex_dev;
-
- exp = svc_export_lookup(&new);
- if (exp)
- exp = svc_export_update(&new, exp);
-
- if (!exp)
- goto finish;
-
- if (exp_hash(clp, exp) ||
- exp_fsid_hash(clp, exp)) {
- /* failed to create at least one index */
- exp_do_unexport(exp);
- cache_flush();
- } else
- err = 0;
-finish:
- kfree(new.ex_pathname);
- if (!IS_ERR_OR_NULL(exp))
- exp_put(exp);
- if (!IS_ERR_OR_NULL(fsid_key))
- cache_put(&fsid_key->h, &svc_expkey_cache);
- path_put(&path);
-out_put_clp:
- auth_domain_put(clp);
-out_unlock:
- exp_writeunlock();
-out:
- return err;
-}
-
-/*
- * Unexport a file system. The export entry has already
- * been removed from the client's list of exported fs's.
- */
-static void
-exp_do_unexport(svc_export *unexp)
-{
- sunrpc_invalidate(&unexp->h, &svc_export_cache);
- exp_unhash(unexp);
- exp_fsid_unhash(unexp);
-}
-
-
-/*
- * unexport syscall.
- */
-int
-exp_unexport(struct nfsctl_export *nxp)
-{
- struct auth_domain *dom;
- svc_export *exp;
- struct path path;
- int err;
-
- /* Consistency check */
- if (!exp_verify_string(nxp->ex_path, NFS_MAXPATHLEN) ||
- !exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX))
- return -EINVAL;
-
- exp_writelock();
-
- err = -EINVAL;
- dom = auth_domain_find(nxp->ex_client);
- if (!dom) {
- dprintk("nfsd: unexport couldn't find %s\n", nxp->ex_client);
- goto out_unlock;
- }
-
- err = kern_path(nxp->ex_path, 0, &path);
- if (err)
- goto out_domain;
-
- err = -EINVAL;
- exp = exp_get_by_name(dom, &path, NULL);
- path_put(&path);
- if (IS_ERR(exp))
- goto out_domain;
-
- exp_do_unexport(exp);
- exp_put(exp);
- err = 0;
-
-out_domain:
- auth_domain_put(dom);
- cache_flush();
-out_unlock:
- exp_writeunlock();
- return err;
-}
-#endif /* CONFIG_NFSD_DEPRECATED */
/*
* Obtain the root fh on behalf of a client.
@@ -1330,7 +998,7 @@ rqst_exp_parent(struct svc_rqst *rqstp, struct path *path)
return exp;
}
-static struct svc_export *find_fsidzero_export(struct svc_rqst *rqstp)
+struct svc_export *rqst_find_fsidzero_export(struct svc_rqst *rqstp)
{
u32 fsidv[2];
@@ -1350,7 +1018,7 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
struct svc_export *exp;
__be32 rv;
- exp = find_fsidzero_export(rqstp);
+ exp = rqst_find_fsidzero_export(rqstp);
if (IS_ERR(exp))
return nfserrno(PTR_ERR(exp));
rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL);
@@ -1367,7 +1035,6 @@ static void *e_start(struct seq_file *m, loff_t *pos)
unsigned hash, export;
struct cache_head *ch;
- exp_readlock();
read_lock(&svc_export_cache.hash_lock);
if (!n--)
return SEQ_START_TOKEN;
@@ -1418,7 +1085,6 @@ 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();
}
static struct flags {
@@ -1550,97 +1216,6 @@ const struct seq_operations nfs_exports_op = {
.show = e_show,
};
-#ifdef CONFIG_NFSD_DEPRECATED
-/*
- * Add or modify a client.
- * Change requests may involve the list of host addresses. The list of
- * exports and possibly existing uid maps are left untouched.
- */
-int
-exp_addclient(struct nfsctl_client *ncp)
-{
- struct auth_domain *dom;
- int i, err;
- struct in6_addr addr6;
-
- /* First, consistency check. */
- err = -EINVAL;
- if (! exp_verify_string(ncp->cl_ident, NFSCLNT_IDMAX))
- goto out;
- if (ncp->cl_naddr > NFSCLNT_ADDRMAX)
- goto out;
-
- /* Lock the hashtable */
- exp_writelock();
-
- dom = unix_domain_find(ncp->cl_ident);
-
- err = -ENOMEM;
- if (!dom)
- goto out_unlock;
-
- /* Insert client into hashtable. */
- for (i = 0; i < ncp->cl_naddr; i++) {
- ipv6_addr_set_v4mapped(ncp->cl_addrlist[i].s_addr, &addr6);
- auth_unix_add_addr(&init_net, &addr6, dom);
- }
- auth_unix_forget_old(dom);
- auth_domain_put(dom);
-
- err = 0;
-
-out_unlock:
- exp_writeunlock();
-out:
- return err;
-}
-
-/*
- * Delete a client given an identifier.
- */
-int
-exp_delclient(struct nfsctl_client *ncp)
-{
- int err;
- struct auth_domain *dom;
-
- err = -EINVAL;
- if (!exp_verify_string(ncp->cl_ident, NFSCLNT_IDMAX))
- goto out;
-
- /* Lock the hashtable */
- exp_writelock();
-
- dom = auth_domain_find(ncp->cl_ident);
- /* just make sure that no addresses work
- * and that it will expire soon
- */
- if (dom) {
- err = auth_unix_forget_old(dom);
- auth_domain_put(dom);
- }
-
- exp_writeunlock();
-out:
- return err;
-}
-
-/*
- * Verify that string is non-empty and does not exceed max length.
- */
-static int
-exp_verify_string(char *cp, int max)
-{
- int i;
-
- for (i = 0; i < max; i++)
- if (!cp[i])
- return i;
- cp[i] = 0;
- printk(KERN_NOTICE "nfsd: couldn't validate string %s\n", cp);
- return 0;
-}
-#endif /* CONFIG_NFSD_DEPRECATED */
/*
* Initialize the exports module.
@@ -1667,10 +1242,8 @@ nfsd_export_init(void)
void
nfsd_export_flush(void)
{
- exp_writelock();
cache_purge(&svc_expkey_cache);
cache_purge(&svc_export_cache);
- exp_writeunlock();
}
/*
@@ -1682,12 +1255,9 @@ nfsd_export_shutdown(void)
dprintk("nfsd: shutting down export module.\n");
- exp_writelock();
-
cache_unregister(&svc_expkey_cache);
cache_unregister(&svc_export_cache);
svcauth_unix_purge();
- exp_writeunlock();
dprintk("nfsd: export shutdown complete.\n");
}