36def90
commit e6499c6f4b5f56a16f8b8ef60529c1da28b13aea
36def90
Author: Bryan Schumaker <bjschuma@netapp.com>
36def90
Date:   Thu Jan 26 16:54:23 2012 -0500
36def90
36def90
    NFS: Fall back on old idmapper if request_key() fails
36def90
    
36def90
    This patch removes the CONFIG_NFS_USE_NEW_IDMAPPER compile option.
36def90
    First, the idmapper will attempt to map the id using /sbin/request-key
36def90
    and nfsidmap.  If this fails (if /etc/request-key.conf is not configured
36def90
    properly) then the idmapper will call the legacy code to perform the
36def90
    mapping.  I left a comment stating where the legacy code begins to make
36def90
    it easier for somebody to remove in the future.
36def90
    
36def90
    Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
36def90
    Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
36def90
36def90
diff -up linux-3.2.noarch/fs/nfs/idmap.c.orig linux-3.2.noarch/fs/nfs/idmap.c
36def90
--- linux-3.2.noarch/fs/nfs/idmap.c.orig	2012-01-27 10:07:07.209851446 -0500
36def90
+++ linux-3.2.noarch/fs/nfs/idmap.c	2012-01-27 10:15:42.914563082 -0500
36def90
@@ -142,8 +142,6 @@ static int nfs_map_numeric_to_string(__u
36def90
 	return snprintf(buf, buflen, "%u", id);
36def90
 }
36def90
 
36def90
-#ifdef CONFIG_NFS_USE_NEW_IDMAPPER
36def90
-
36def90
 #include <linux/cred.h>
36def90
 #include <linux/sunrpc/sched.h>
36def90
 #include <linux/nfs4.h>
36def90
@@ -328,43 +326,7 @@ static int nfs_idmap_lookup_id(const cha
36def90
 	return ret;
36def90
 }
36def90
 
36def90
-int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
36def90
-{
36def90
-	if (nfs_map_string_to_numeric(name, namelen, uid))
36def90
-		return 0;
36def90
-	return nfs_idmap_lookup_id(name, namelen, "uid", uid);
36def90
-}
36def90
-
36def90
-int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *gid)
36def90
-{
36def90
-	if (nfs_map_string_to_numeric(name, namelen, gid))
36def90
-		return 0;
36def90
-	return nfs_idmap_lookup_id(name, namelen, "gid", gid);
36def90
-}
36def90
-
36def90
-int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
36def90
-{
36def90
-	int ret = -EINVAL;
36def90
-
36def90
-	if (!(server->caps & NFS_CAP_UIDGID_NOMAP))
36def90
-		ret = nfs_idmap_lookup_name(uid, "user", buf, buflen);
36def90
-	if (ret < 0)
36def90
-		ret = nfs_map_numeric_to_string(uid, buf, buflen);
36def90
-	return ret;
36def90
-}
36def90
-int nfs_map_gid_to_group(const struct nfs_server *server, __u32 gid, char *buf, size_t buflen)
36def90
-{
36def90
-	int ret = -EINVAL;
36def90
-
36def90
-	if (!(server->caps & NFS_CAP_UIDGID_NOMAP))
36def90
-		ret = nfs_idmap_lookup_name(gid, "group", buf, buflen);
36def90
-	if (ret < 0)
36def90
-		ret = nfs_map_numeric_to_string(gid, buf, buflen);
36def90
-	return ret;
36def90
-}
36def90
-
36def90
-#else  /* CONFIG_NFS_USE_NEW_IDMAPPER not defined */
36def90
-
36def90
+/* idmap classic begins here */
36def90
 #include <linux/module.h>
36def90
 #include <linux/mutex.h>
36def90
 #include <linux/init.h>
36def90
@@ -796,19 +758,27 @@ static unsigned int fnvhash32(const void
36def90
 int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
36def90
 {
36def90
 	struct idmap *idmap = server->nfs_client->cl_idmap;
36def90
+	int ret = -EINVAL;
36def90
 
36def90
 	if (nfs_map_string_to_numeric(name, namelen, uid))
36def90
 		return 0;
36def90
-	return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid);
36def90
+	ret = nfs_idmap_lookup_id(name, namelen, "uid", uid);
36def90
+	if (ret < 0)
36def90
+		ret = nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid);
36def90
+	return ret;
36def90
 }
36def90
 
36def90
-int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
36def90
+int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *gid)
36def90
 {
36def90
 	struct idmap *idmap = server->nfs_client->cl_idmap;
36def90
+	int ret = -EINVAL;
36def90
 
36def90
-	if (nfs_map_string_to_numeric(name, namelen, uid))
36def90
+	if (nfs_map_string_to_numeric(name, namelen, gid))
36def90
 		return 0;
36def90
-	return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid);
36def90
+	ret = nfs_idmap_lookup_id(name, namelen, "gid", gid);
36def90
+	if (ret < 0)
36def90
+		ret = nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, gid);
36def90
+	return ret;
36def90
 }
36def90
 
36def90
 int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
36def90
@@ -816,22 +786,26 @@ int nfs_map_uid_to_name(const struct nfs
36def90
 	struct idmap *idmap = server->nfs_client->cl_idmap;
36def90
 	int ret = -EINVAL;
36def90
 
36def90
-	if (!(server->caps & NFS_CAP_UIDGID_NOMAP))
36def90
-		ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf);
36def90
+	if (!(server->caps & NFS_CAP_UIDGID_NOMAP)) {
36def90
+		ret = nfs_idmap_lookup_name(uid, "user", buf, buflen);
36def90
+		if (ret < 0)
36def90
+			ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf);
36def90
+	}
36def90
 	if (ret < 0)
36def90
 		ret = nfs_map_numeric_to_string(uid, buf, buflen);
36def90
 	return ret;
36def90
 }
36def90
-int nfs_map_gid_to_group(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
36def90
+int nfs_map_gid_to_group(const struct nfs_server *server, __u32 gid, char *buf, size_t buflen)
36def90
 {
36def90
 	struct idmap *idmap = server->nfs_client->cl_idmap;
36def90
 	int ret = -EINVAL;
36def90
 
36def90
-	if (!(server->caps & NFS_CAP_UIDGID_NOMAP))
36def90
-		ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf);
36def90
+	if (!(server->caps & NFS_CAP_UIDGID_NOMAP)) {
36def90
+		ret = nfs_idmap_lookup_name(gid, "group", buf, buflen);
36def90
+		if (ret < 0)
36def90
+			ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, gid, buf);
36def90
+	}
36def90
 	if (ret < 0)
36def90
-		ret = nfs_map_numeric_to_string(uid, buf, buflen);
36def90
+		ret = nfs_map_numeric_to_string(gid, buf, buflen);
36def90
 	return ret;
36def90
 }
36def90
-
36def90
-#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
36def90
diff -up linux-3.2.noarch/fs/nfs/Kconfig.orig linux-3.2.noarch/fs/nfs/Kconfig
36def90
--- linux-3.2.noarch/fs/nfs/Kconfig.orig	2012-01-04 18:55:44.000000000 -0500
36def90
+++ linux-3.2.noarch/fs/nfs/Kconfig	2012-01-27 10:15:42.913562572 -0500
36def90
@@ -132,14 +132,3 @@ config NFS_USE_KERNEL_DNS
36def90
 	select DNS_RESOLVER
36def90
 	select KEYS
36def90
 	default y
36def90
-
36def90
-config NFS_USE_NEW_IDMAPPER
36def90
-	bool "Use the new idmapper upcall routine"
36def90
-	depends on NFS_V4 && KEYS
36def90
-	help
36def90
-	  Say Y here if you want NFS to use the new idmapper upcall functions.
36def90
-	  You will need /sbin/request-key (usually provided by the keyutils
36def90
-	  package).  For details, read
36def90
-	  <file:Documentation/filesystems/nfs/idmapper.txt>.
36def90
-
36def90
-	  If you are unsure, say N.
36def90
diff -up linux-3.2.noarch/fs/nfs/sysctl.c.orig linux-3.2.noarch/fs/nfs/sysctl.c
36def90
--- linux-3.2.noarch/fs/nfs/sysctl.c.orig	2012-01-04 18:55:44.000000000 -0500
36def90
+++ linux-3.2.noarch/fs/nfs/sysctl.c	2012-01-27 10:15:42.914563082 -0500
36def90
@@ -32,7 +32,6 @@ static ctl_table nfs_cb_sysctls[] = {
36def90
 		.extra1 = (int *)&nfs_set_port_min,
36def90
 		.extra2 = (int *)&nfs_set_port_max,
36def90
 	},
36def90
-#ifndef CONFIG_NFS_USE_NEW_IDMAPPER
36def90
 	{
36def90
 		.procname = "idmap_cache_timeout",
36def90
 		.data = &nfs_idmap_cache_timeout,
36def90
@@ -40,7 +39,6 @@ static ctl_table nfs_cb_sysctls[] = {
36def90
 		.mode = 0644,
36def90
 		.proc_handler = proc_dointvec_jiffies,
36def90
 	},
36def90
-#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
36def90
 #endif
36def90
 	{
36def90
 		.procname	= "nfs_mountpoint_timeout",
36def90
diff -up linux-3.2.noarch/include/linux/nfs_idmap.h.orig linux-3.2.noarch/include/linux/nfs_idmap.h
36def90
--- linux-3.2.noarch/include/linux/nfs_idmap.h.orig	2012-01-27 10:06:46.783643915 -0500
36def90
+++ linux-3.2.noarch/include/linux/nfs_idmap.h	2012-01-27 10:15:42.915563594 -0500
36def90
@@ -69,36 +69,11 @@ struct nfs_server;
36def90
 struct nfs_fattr;
36def90
 struct nfs4_string;
36def90
 
36def90
-#ifdef CONFIG_NFS_USE_NEW_IDMAPPER
36def90
-
36def90
 int nfs_idmap_init(void);
36def90
 void nfs_idmap_quit(void);
36def90
-
36def90
-static inline int nfs_idmap_new(struct nfs_client *clp)
36def90
-{
36def90
-	return 0;
36def90
-}
36def90
-
36def90
-static inline void nfs_idmap_delete(struct nfs_client *clp)
36def90
-{
36def90
-}
36def90
-
36def90
-#else /* CONFIG_NFS_USE_NEW_IDMAPPER not set */
36def90
-
36def90
-static inline int nfs_idmap_init(void)
36def90
-{
36def90
-	return 0;
36def90
-}
36def90
-
36def90
-static inline void nfs_idmap_quit(void)
36def90
-{
36def90
-}
36def90
-
36def90
 int nfs_idmap_new(struct nfs_client *);
36def90
 void nfs_idmap_delete(struct nfs_client *);
36def90
 
36def90
-#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
36def90
-
36def90
 void nfs_fattr_init_names(struct nfs_fattr *fattr,
36def90
 		struct nfs4_string *owner_name,
36def90
 		struct nfs4_string *group_name);