aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kernel-parameters.txt4
-rw-r--r--fs/nfs/idmap.c9
-rw-r--r--fs/nfs/inode.c14
-rw-r--r--fs/nfs/sysctl.c10
-rw-r--r--include/linux/nfs_idmap.h2
5 files changed, 39 insertions, 0 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 309c9cec6e7c..a482fde09bbb 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -914,6 +914,10 @@ running once the system is up.
914 [NFS] set the TCP port on which the NFSv4 callback 914 [NFS] set the TCP port on which the NFSv4 callback
915 channel should listen. 915 channel should listen.
916 916
917 nfs.idmap_cache_timeout=
918 [NFS] set the maximum lifetime for idmapper cache
919 entries.
920
917 nmi_watchdog= [KNL,BUGS=IA-32] Debugging features for SMP kernels 921 nmi_watchdog= [KNL,BUGS=IA-32] Debugging features for SMP kernels
918 922
919 no387 [BUGS=IA-32] Tells the kernel to use the 387 maths 923 no387 [BUGS=IA-32] Tells the kernel to use the 387 maths
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index ffb8df91dc34..821edd30333b 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -54,7 +54,11 @@
54 54
55#define IDMAP_HASH_SZ 128 55#define IDMAP_HASH_SZ 128
56 56
57/* Default cache timeout is 10 minutes */
58unsigned int nfs_idmap_cache_timeout = 600 * HZ;
59
57struct idmap_hashent { 60struct idmap_hashent {
61 unsigned long ih_expires;
58 __u32 ih_id; 62 __u32 ih_id;
59 int ih_namelen; 63 int ih_namelen;
60 char ih_name[IDMAP_NAMESZ]; 64 char ih_name[IDMAP_NAMESZ];
@@ -149,6 +153,8 @@ idmap_lookup_name(struct idmap_hashtable *h, const char *name, size_t len)
149 153
150 if (he->ih_namelen != len || memcmp(he->ih_name, name, len) != 0) 154 if (he->ih_namelen != len || memcmp(he->ih_name, name, len) != 0)
151 return NULL; 155 return NULL;
156 if (time_after(jiffies, he->ih_expires))
157 return NULL;
152 return he; 158 return he;
153} 159}
154 160
@@ -164,6 +170,8 @@ idmap_lookup_id(struct idmap_hashtable *h, __u32 id)
164 struct idmap_hashent *he = idmap_id_hash(h, id); 170 struct idmap_hashent *he = idmap_id_hash(h, id);
165 if (he->ih_id != id || he->ih_namelen == 0) 171 if (he->ih_id != id || he->ih_namelen == 0)
166 return NULL; 172 return NULL;
173 if (time_after(jiffies, he->ih_expires))
174 return NULL;
167 return he; 175 return he;
168} 176}
169 177
@@ -192,6 +200,7 @@ idmap_update_entry(struct idmap_hashent *he, const char *name,
192 memcpy(he->ih_name, name, namelen); 200 memcpy(he->ih_name, name, namelen);
193 he->ih_name[namelen] = '\0'; 201 he->ih_name[namelen] = '\0';
194 he->ih_namelen = namelen; 202 he->ih_namelen = namelen;
203 he->ih_expires = jiffies + nfs_idmap_cache_timeout;
195} 204}
196 205
197/* 206/*
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 4625479a6b62..e7bd0d92600f 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -2050,6 +2050,20 @@ static int param_set_port(const char *val, struct kernel_param *kp)
2050module_param_call(callback_tcpport, param_set_port, param_get_int, 2050module_param_call(callback_tcpport, param_set_port, param_get_int,
2051 &nfs_callback_set_tcpport, 0644); 2051 &nfs_callback_set_tcpport, 0644);
2052 2052
2053static int param_set_idmap_timeout(const char *val, struct kernel_param *kp)
2054{
2055 char *endp;
2056 int num = simple_strtol(val, &endp, 0);
2057 int jif = num * HZ;
2058 if (endp == val || *endp || num < 0 || jif < num)
2059 return -EINVAL;
2060 *((int *)kp->arg) = jif;
2061 return 0;
2062}
2063
2064module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int,
2065 &nfs_idmap_cache_timeout, 0644);
2066
2053#define nfs4_init_once(nfsi) \ 2067#define nfs4_init_once(nfsi) \
2054 do { \ 2068 do { \
2055 INIT_LIST_HEAD(&(nfsi)->open_states); \ 2069 INIT_LIST_HEAD(&(nfsi)->open_states); \
diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c
index fdc64b59a4ee..4c486eb867ca 100644
--- a/fs/nfs/sysctl.c
+++ b/fs/nfs/sysctl.c
@@ -11,6 +11,7 @@
11#include <linux/sysctl.h> 11#include <linux/sysctl.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/nfs4.h> 13#include <linux/nfs4.h>
14#include <linux/nfs_idmap.h>
14 15
15#include "callback.h" 16#include "callback.h"
16 17
@@ -35,6 +36,15 @@ static ctl_table nfs_cb_sysctls[] = {
35 .extra1 = (int *)&nfs_set_port_min, 36 .extra1 = (int *)&nfs_set_port_min,
36 .extra2 = (int *)&nfs_set_port_max, 37 .extra2 = (int *)&nfs_set_port_max,
37 }, 38 },
39 {
40 .ctl_name = CTL_UNNUMBERED,
41 .procname = "idmap_cache_timeout",
42 .data = &nfs_idmap_cache_timeout,
43 .maxlen = sizeof(int),
44 .mode = 0644,
45 .proc_handler = &proc_dointvec_jiffies,
46 .strategy = &sysctl_jiffies,
47 },
38#endif 48#endif
39 { .ctl_name = 0 } 49 { .ctl_name = 0 }
40}; 50};
diff --git a/include/linux/nfs_idmap.h b/include/linux/nfs_idmap.h
index a0f1f25e0ead..102e56094296 100644
--- a/include/linux/nfs_idmap.h
+++ b/include/linux/nfs_idmap.h
@@ -71,6 +71,8 @@ int nfs_map_name_to_uid(struct nfs4_client *, const char *, size_t, __u32 *);
71int nfs_map_group_to_gid(struct nfs4_client *, const char *, size_t, __u32 *); 71int nfs_map_group_to_gid(struct nfs4_client *, const char *, size_t, __u32 *);
72int nfs_map_uid_to_name(struct nfs4_client *, __u32, char *); 72int nfs_map_uid_to_name(struct nfs4_client *, __u32, char *);
73int nfs_map_gid_to_group(struct nfs4_client *, __u32, char *); 73int nfs_map_gid_to_group(struct nfs4_client *, __u32, char *);
74
75extern unsigned int nfs_idmap_cache_timeout;
74#endif /* __KERNEL__ */ 76#endif /* __KERNEL__ */
75 77
76#endif /* NFS_IDMAP_H */ 78#endif /* NFS_IDMAP_H */