diff options
Diffstat (limited to 'fs/nfs/idmap.c')
-rw-r--r-- | fs/nfs/idmap.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c index 07a5dd57646e..82ad7110a1c0 100644 --- a/fs/nfs/idmap.c +++ b/fs/nfs/idmap.c | |||
@@ -57,6 +57,20 @@ | |||
57 | /* Default cache timeout is 10 minutes */ | 57 | /* Default cache timeout is 10 minutes */ |
58 | unsigned int nfs_idmap_cache_timeout = 600 * HZ; | 58 | unsigned int nfs_idmap_cache_timeout = 600 * HZ; |
59 | 59 | ||
60 | static int param_set_idmap_timeout(const char *val, struct kernel_param *kp) | ||
61 | { | ||
62 | char *endp; | ||
63 | int num = simple_strtol(val, &endp, 0); | ||
64 | int jif = num * HZ; | ||
65 | if (endp == val || *endp || num < 0 || jif < num) | ||
66 | return -EINVAL; | ||
67 | *((int *)kp->arg) = jif; | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int, | ||
72 | &nfs_idmap_cache_timeout, 0644); | ||
73 | |||
60 | struct idmap_hashent { | 74 | struct idmap_hashent { |
61 | unsigned long ih_expires; | 75 | unsigned long ih_expires; |
62 | __u32 ih_id; | 76 | __u32 ih_id; |
@@ -70,7 +84,6 @@ struct idmap_hashtable { | |||
70 | }; | 84 | }; |
71 | 85 | ||
72 | struct idmap { | 86 | struct idmap { |
73 | char idmap_path[48]; | ||
74 | struct dentry *idmap_dentry; | 87 | struct dentry *idmap_dentry; |
75 | wait_queue_head_t idmap_wq; | 88 | wait_queue_head_t idmap_wq; |
76 | struct idmap_msg idmap_im; | 89 | struct idmap_msg idmap_im; |
@@ -94,24 +107,23 @@ static struct rpc_pipe_ops idmap_upcall_ops = { | |||
94 | .destroy_msg = idmap_pipe_destroy_msg, | 107 | .destroy_msg = idmap_pipe_destroy_msg, |
95 | }; | 108 | }; |
96 | 109 | ||
97 | void | 110 | int |
98 | nfs_idmap_new(struct nfs4_client *clp) | 111 | nfs_idmap_new(struct nfs_client *clp) |
99 | { | 112 | { |
100 | struct idmap *idmap; | 113 | struct idmap *idmap; |
114 | int error; | ||
101 | 115 | ||
102 | if (clp->cl_idmap != NULL) | 116 | BUG_ON(clp->cl_idmap != NULL); |
103 | return; | ||
104 | if ((idmap = kzalloc(sizeof(*idmap), GFP_KERNEL)) == NULL) | ||
105 | return; | ||
106 | 117 | ||
107 | snprintf(idmap->idmap_path, sizeof(idmap->idmap_path), | 118 | if ((idmap = kzalloc(sizeof(*idmap), GFP_KERNEL)) == NULL) |
108 | "%s/idmap", clp->cl_rpcclient->cl_pathname); | 119 | return -ENOMEM; |
109 | 120 | ||
110 | idmap->idmap_dentry = rpc_mkpipe(idmap->idmap_path, | 121 | idmap->idmap_dentry = rpc_mkpipe(clp->cl_rpcclient->cl_dentry, "idmap", |
111 | idmap, &idmap_upcall_ops, 0); | 122 | idmap, &idmap_upcall_ops, 0); |
112 | if (IS_ERR(idmap->idmap_dentry)) { | 123 | if (IS_ERR(idmap->idmap_dentry)) { |
124 | error = PTR_ERR(idmap->idmap_dentry); | ||
113 | kfree(idmap); | 125 | kfree(idmap); |
114 | return; | 126 | return error; |
115 | } | 127 | } |
116 | 128 | ||
117 | mutex_init(&idmap->idmap_lock); | 129 | mutex_init(&idmap->idmap_lock); |
@@ -121,10 +133,11 @@ nfs_idmap_new(struct nfs4_client *clp) | |||
121 | idmap->idmap_group_hash.h_type = IDMAP_TYPE_GROUP; | 133 | idmap->idmap_group_hash.h_type = IDMAP_TYPE_GROUP; |
122 | 134 | ||
123 | clp->cl_idmap = idmap; | 135 | clp->cl_idmap = idmap; |
136 | return 0; | ||
124 | } | 137 | } |
125 | 138 | ||
126 | void | 139 | void |
127 | nfs_idmap_delete(struct nfs4_client *clp) | 140 | nfs_idmap_delete(struct nfs_client *clp) |
128 | { | 141 | { |
129 | struct idmap *idmap = clp->cl_idmap; | 142 | struct idmap *idmap = clp->cl_idmap; |
130 | 143 | ||
@@ -477,27 +490,27 @@ static unsigned int fnvhash32(const void *buf, size_t buflen) | |||
477 | return (hash); | 490 | return (hash); |
478 | } | 491 | } |
479 | 492 | ||
480 | int nfs_map_name_to_uid(struct nfs4_client *clp, const char *name, size_t namelen, __u32 *uid) | 493 | int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid) |
481 | { | 494 | { |
482 | struct idmap *idmap = clp->cl_idmap; | 495 | struct idmap *idmap = clp->cl_idmap; |
483 | 496 | ||
484 | return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid); | 497 | return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid); |
485 | } | 498 | } |
486 | 499 | ||
487 | int nfs_map_group_to_gid(struct nfs4_client *clp, const char *name, size_t namelen, __u32 *uid) | 500 | int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid) |
488 | { | 501 | { |
489 | struct idmap *idmap = clp->cl_idmap; | 502 | struct idmap *idmap = clp->cl_idmap; |
490 | 503 | ||
491 | return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid); | 504 | return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid); |
492 | } | 505 | } |
493 | 506 | ||
494 | int nfs_map_uid_to_name(struct nfs4_client *clp, __u32 uid, char *buf) | 507 | int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf) |
495 | { | 508 | { |
496 | struct idmap *idmap = clp->cl_idmap; | 509 | struct idmap *idmap = clp->cl_idmap; |
497 | 510 | ||
498 | return nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf); | 511 | return nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf); |
499 | } | 512 | } |
500 | int nfs_map_gid_to_group(struct nfs4_client *clp, __u32 uid, char *buf) | 513 | int nfs_map_gid_to_group(struct nfs_client *clp, __u32 uid, char *buf) |
501 | { | 514 | { |
502 | struct idmap *idmap = clp->cl_idmap; | 515 | struct idmap *idmap = clp->cl_idmap; |
503 | 516 | ||