Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294451
b: refs/heads/master
c: e6499c6
h: refs/heads/master
i:
  294449: 2615787
  294447: c657164
v: v3
  • Loading branch information
Bryan Schumaker authored and Trond Myklebust committed Feb 6, 2012
1 parent b47e219 commit cef5fe3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 83 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2d3fe01c36a9b881fae89c5bdf4085a4d7d53ae1
refs/heads/master: e6499c6f4b5f56a16f8b8ef60529c1da28b13aea
11 changes: 0 additions & 11 deletions trunk/fs/nfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,3 @@ config NFS_USE_KERNEL_DNS
select DNS_RESOLVER
select KEYS
default y

config NFS_USE_NEW_IDMAPPER
bool "Use the new idmapper upcall routine"
depends on NFS_V4 && KEYS
help
Say Y here if you want NFS to use the new idmapper upcall functions.
You will need /sbin/request-key (usually provided by the keyutils
package). For details, read
<file:Documentation/filesystems/nfs/idmapper.txt>.

If you are unsure, say N.
91 changes: 37 additions & 54 deletions trunk/fs/nfs/idmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ static int nfs_map_numeric_to_string(__u32 id, char *buf, size_t buflen)
return snprintf(buf, buflen, "%u", id);
}

#ifdef CONFIG_NFS_USE_NEW_IDMAPPER

#include <linux/cred.h>
#include <linux/sunrpc/sched.h>
#include <linux/nfs4.h>
Expand All @@ -169,7 +167,7 @@ struct key_type key_type_id_resolver = {
.read = user_read,
};

int nfs_idmap_init(void)
static int nfs_idmap_init_keyring(void)
{
struct cred *cred;
struct key *keyring;
Expand Down Expand Up @@ -211,7 +209,7 @@ int nfs_idmap_init(void)
return ret;
}

void nfs_idmap_quit(void)
static void nfs_idmap_quit_keyring(void)
{
key_revoke(id_resolver_cache->thread_keyring);
unregister_key_type(&key_type_id_resolver);
Expand Down Expand Up @@ -328,43 +326,7 @@ static int nfs_idmap_lookup_id(const char *name, size_t namelen,
return ret;
}

int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
{
if (nfs_map_string_to_numeric(name, namelen, uid))
return 0;
return nfs_idmap_lookup_id(name, namelen, "uid", uid);
}

int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *gid)
{
if (nfs_map_string_to_numeric(name, namelen, gid))
return 0;
return nfs_idmap_lookup_id(name, namelen, "gid", gid);
}

int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
{
int ret = -EINVAL;

if (!(server->caps & NFS_CAP_UIDGID_NOMAP))
ret = nfs_idmap_lookup_name(uid, "user", buf, buflen);
if (ret < 0)
ret = nfs_map_numeric_to_string(uid, buf, buflen);
return ret;
}
int nfs_map_gid_to_group(const struct nfs_server *server, __u32 gid, char *buf, size_t buflen)
{
int ret = -EINVAL;

if (!(server->caps & NFS_CAP_UIDGID_NOMAP))
ret = nfs_idmap_lookup_name(gid, "group", buf, buflen);
if (ret < 0)
ret = nfs_map_numeric_to_string(gid, buf, buflen);
return ret;
}

#else /* CONFIG_NFS_USE_NEW_IDMAPPER not defined */

/* idmap classic begins here */
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/init.h>
Expand Down Expand Up @@ -600,12 +562,21 @@ static struct notifier_block nfs_idmap_block = {

int nfs_idmap_init(void)
{
return rpc_pipefs_notifier_register(&nfs_idmap_block);
int ret;
ret = nfs_idmap_init_keyring();
if (ret != 0)
goto out;
ret = rpc_pipefs_notifier_register(&nfs_idmap_block);
if (ret != 0)
nfs_idmap_quit_keyring();
out:
return ret;
}

void nfs_idmap_quit(void)
{
rpc_pipefs_notifier_unregister(&nfs_idmap_block);
nfs_idmap_quit_keyring();
}

/*
Expand Down Expand Up @@ -930,42 +901,54 @@ static unsigned int fnvhash32(const void *buf, size_t buflen)
int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
{
struct idmap *idmap = server->nfs_client->cl_idmap;
int ret = -EINVAL;

if (nfs_map_string_to_numeric(name, namelen, uid))
return 0;
return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid);
ret = nfs_idmap_lookup_id(name, namelen, "uid", uid);
if (ret < 0)
ret = nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid);
return ret;
}

int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *gid)
{
struct idmap *idmap = server->nfs_client->cl_idmap;
int ret = -EINVAL;

if (nfs_map_string_to_numeric(name, namelen, uid))
if (nfs_map_string_to_numeric(name, namelen, gid))
return 0;
return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid);
ret = nfs_idmap_lookup_id(name, namelen, "gid", gid);
if (ret < 0)
ret = nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, gid);
return ret;
}

int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
{
struct idmap *idmap = server->nfs_client->cl_idmap;
int ret = -EINVAL;

if (!(server->caps & NFS_CAP_UIDGID_NOMAP))
ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf);
if (!(server->caps & NFS_CAP_UIDGID_NOMAP)) {
ret = nfs_idmap_lookup_name(uid, "user", buf, buflen);
if (ret < 0)
ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf);
}
if (ret < 0)
ret = nfs_map_numeric_to_string(uid, buf, buflen);
return ret;
}
int nfs_map_gid_to_group(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
int nfs_map_gid_to_group(const struct nfs_server *server, __u32 gid, char *buf, size_t buflen)
{
struct idmap *idmap = server->nfs_client->cl_idmap;
int ret = -EINVAL;

if (!(server->caps & NFS_CAP_UIDGID_NOMAP))
ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf);
if (!(server->caps & NFS_CAP_UIDGID_NOMAP)) {
ret = nfs_idmap_lookup_name(gid, "group", buf, buflen);
if (ret < 0)
ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, gid, buf);
}
if (ret < 0)
ret = nfs_map_numeric_to_string(uid, buf, buflen);
ret = nfs_map_numeric_to_string(gid, buf, buflen);
return ret;
}

#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
2 changes: 0 additions & 2 deletions trunk/fs/nfs/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ static ctl_table nfs_cb_sysctls[] = {
.extra1 = (int *)&nfs_set_port_min,
.extra2 = (int *)&nfs_set_port_max,
},
#ifndef CONFIG_NFS_USE_NEW_IDMAPPER
{
.procname = "idmap_cache_timeout",
.data = &nfs_idmap_cache_timeout,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = proc_dointvec_jiffies,
},
#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
#endif
{
.procname = "nfs_mountpoint_timeout",
Expand Down
15 changes: 0 additions & 15 deletions trunk/include/linux/nfs_idmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,9 @@ static inline void nfs_idmap_quit(void)
{}
#endif

#ifdef CONFIG_NFS_USE_NEW_IDMAPPER

static inline int nfs_idmap_new(struct nfs_client *clp)
{
return 0;
}

static inline void nfs_idmap_delete(struct nfs_client *clp)
{
}

#else /* CONFIG_NFS_USE_NEW_IDMAPPER not set */

int nfs_idmap_new(struct nfs_client *);
void nfs_idmap_delete(struct nfs_client *);

#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */

void nfs_fattr_init_names(struct nfs_fattr *fattr,
struct nfs4_string *owner_name,
struct nfs4_string *group_name);
Expand Down

0 comments on commit cef5fe3

Please sign in to comment.