diff options
-rw-r--r-- | fs/nfsd/export.c | 4 | ||||
-rw-r--r-- | fs/nfsd/nfs4idmap.c | 10 | ||||
-rw-r--r-- | include/linux/sunrpc/cache.h | 28 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/svcauth_gss.c | 4 | ||||
-rw-r--r-- | net/sunrpc/svcauth_unix.c | 2 |
5 files changed, 18 insertions, 30 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 587829ed651c..c591761a1ad6 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -250,7 +250,7 @@ static inline void svc_expkey_update(struct svc_expkey *new, struct svc_expkey * | |||
250 | new->ek_dentry = dget(item->ek_dentry); | 250 | new->ek_dentry = dget(item->ek_dentry); |
251 | } | 251 | } |
252 | 252 | ||
253 | static DefineSimpleCacheLookup(svc_expkey,0) /* no inplace updates */ | 253 | static DefineSimpleCacheLookup(svc_expkey, svc_expkey) |
254 | 254 | ||
255 | #define EXPORT_HASHBITS 8 | 255 | #define EXPORT_HASHBITS 8 |
256 | #define EXPORT_HASHMAX (1<< EXPORT_HASHBITS) | 256 | #define EXPORT_HASHMAX (1<< EXPORT_HASHBITS) |
@@ -482,7 +482,7 @@ static inline void svc_export_update(struct svc_export *new, struct svc_export * | |||
482 | new->ex_fsid = item->ex_fsid; | 482 | new->ex_fsid = item->ex_fsid; |
483 | } | 483 | } |
484 | 484 | ||
485 | static DefineSimpleCacheLookup(svc_export,1) /* allow inplace updates */ | 485 | static DefineSimpleCacheLookup(svc_export, svc_export) |
486 | 486 | ||
487 | 487 | ||
488 | struct svc_expkey * | 488 | struct svc_expkey * |
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c index 13369650cdf9..dea690aa8bb5 100644 --- a/fs/nfsd/nfs4idmap.c +++ b/fs/nfsd/nfs4idmap.c | |||
@@ -76,12 +76,6 @@ struct ent { | |||
76 | char authname[IDMAP_NAMESZ]; | 76 | char authname[IDMAP_NAMESZ]; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | #define DefineSimpleCacheLookupMap(STRUCT, FUNC) \ | ||
80 | DefineCacheLookup(struct STRUCT, h, FUNC##_lookup, \ | ||
81 | (struct STRUCT *item, int set), /*no setup */, \ | ||
82 | & FUNC##_cache, FUNC##_hash(item), FUNC##_match(item, tmp), \ | ||
83 | STRUCT##_init(new, item), STRUCT##_update(tmp, item), 0) | ||
84 | |||
85 | /* Common entry handling */ | 79 | /* Common entry handling */ |
86 | 80 | ||
87 | #define ENT_HASHBITS 8 | 81 | #define ENT_HASHBITS 8 |
@@ -264,7 +258,7 @@ out: | |||
264 | return error; | 258 | return error; |
265 | } | 259 | } |
266 | 260 | ||
267 | static DefineSimpleCacheLookupMap(ent, idtoname); | 261 | static DefineSimpleCacheLookup(ent, idtoname); |
268 | 262 | ||
269 | /* | 263 | /* |
270 | * Name -> ID cache | 264 | * Name -> ID cache |
@@ -390,7 +384,7 @@ out: | |||
390 | return (error); | 384 | return (error); |
391 | } | 385 | } |
392 | 386 | ||
393 | static DefineSimpleCacheLookupMap(ent, nametoid); | 387 | static DefineSimpleCacheLookup(ent, nametoid); |
394 | 388 | ||
395 | /* | 389 | /* |
396 | * Exported API | 390 | * Exported API |
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index c4e3ea7cf154..405ac14e509a 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -133,14 +133,11 @@ struct cache_deferred_req { | |||
133 | * If "set" == 0 : | 133 | * If "set" == 0 : |
134 | * If an entry is found, it is returned | 134 | * If an entry is found, it is returned |
135 | * If no entry is found, a new non-VALID entry is created. | 135 | * If no entry is found, a new non-VALID entry is created. |
136 | * If "set" == 1 and INPLACE == 0 : | 136 | * If "set" == 1 : |
137 | * If no entry is found a new one is inserted with data from "template" | 137 | * If no entry is found a new one is inserted with data from "template" |
138 | * If a non-CACHE_VALID entry is found, it is updated from template using UPDATE | 138 | * If a non-CACHE_VALID entry is found, it is updated from template using UPDATE |
139 | * If a CACHE_VALID entry is found, a new entry is swapped in with data | 139 | * If a CACHE_VALID entry is found, a new entry is swapped in with data |
140 | * from "template" | 140 | * from "template" |
141 | * If set == 1, and INPLACE == 1 : | ||
142 | * As above, except that if a CACHE_VALID entry is found, we UPDATE in place | ||
143 | * instead of swapping in a new entry. | ||
144 | * | 141 | * |
145 | * If the passed handle has the CACHE_NEGATIVE flag set, then UPDATE is not | 142 | * If the passed handle has the CACHE_NEGATIVE flag set, then UPDATE is not |
146 | * run but insteead CACHE_NEGATIVE is set in any new item. | 143 | * run but insteead CACHE_NEGATIVE is set in any new item. |
@@ -159,13 +156,8 @@ struct cache_deferred_req { | |||
159 | * TEST tests if "tmp" matches "item" | 156 | * TEST tests if "tmp" matches "item" |
160 | * INIT copies key information from "item" to "new" | 157 | * INIT copies key information from "item" to "new" |
161 | * UPDATE copies content information from "item" to "tmp" | 158 | * UPDATE copies content information from "item" to "tmp" |
162 | * INPLACE is true if updates can happen inplace rather than allocating a new structure | ||
163 | * | ||
164 | * WARNING: any substantial changes to this must be reflected in | ||
165 | * net/sunrpc/svcauth.c(auth_domain_lookup) | ||
166 | * which is a similar routine that is open-coded. | ||
167 | */ | 159 | */ |
168 | #define DefineCacheLookup(RTN,MEMBER,FNAME,ARGS,SETUP,DETAIL,HASHFN,TEST,INIT,UPDATE,INPLACE) \ | 160 | #define DefineCacheLookup(RTN,MEMBER,FNAME,ARGS,SETUP,DETAIL,HASHFN,TEST,INIT,UPDATE) \ |
169 | RTN *FNAME ARGS \ | 161 | RTN *FNAME ARGS \ |
170 | { \ | 162 | { \ |
171 | RTN *tmp, *new=NULL; \ | 163 | RTN *tmp, *new=NULL; \ |
@@ -179,13 +171,13 @@ RTN *FNAME ARGS \ | |||
179 | tmp = container_of(*hp, RTN, MEMBER); \ | 171 | tmp = container_of(*hp, RTN, MEMBER); \ |
180 | if (TEST) { /* found a match */ \ | 172 | if (TEST) { /* found a match */ \ |
181 | \ | 173 | \ |
182 | if (set && !INPLACE && test_bit(CACHE_VALID, &tmp->MEMBER.flags) && !new) \ | 174 | if (set && test_bit(CACHE_VALID, &tmp->MEMBER.flags) && !new) \ |
183 | break; \ | 175 | break; \ |
184 | \ | 176 | \ |
185 | if (new) \ | 177 | if (new) \ |
186 | {INIT;} \ | 178 | {INIT;} \ |
187 | if (set) { \ | 179 | if (set) { \ |
188 | if (!INPLACE && test_bit(CACHE_VALID, &tmp->MEMBER.flags))\ | 180 | if (test_bit(CACHE_VALID, &tmp->MEMBER.flags))\ |
189 | { /* need to swap in new */ \ | 181 | { /* need to swap in new */ \ |
190 | RTN *t2; \ | 182 | RTN *t2; \ |
191 | \ | 183 | \ |
@@ -206,7 +198,7 @@ RTN *FNAME ARGS \ | |||
206 | else read_unlock(&(DETAIL)->hash_lock); \ | 198 | else read_unlock(&(DETAIL)->hash_lock); \ |
207 | if (set) \ | 199 | if (set) \ |
208 | cache_fresh(DETAIL, &tmp->MEMBER, item->MEMBER.expiry_time); \ | 200 | cache_fresh(DETAIL, &tmp->MEMBER, item->MEMBER.expiry_time); \ |
209 | if (set && !INPLACE && new) cache_fresh(DETAIL, &new->MEMBER, 0); \ | 201 | if (set && new) cache_fresh(DETAIL, &new->MEMBER, 0); \ |
210 | if (new) (DETAIL)->cache_put(&new->MEMBER, DETAIL); \ | 202 | if (new) (DETAIL)->cache_put(&new->MEMBER, DETAIL); \ |
211 | return tmp; \ | 203 | return tmp; \ |
212 | } \ | 204 | } \ |
@@ -239,10 +231,12 @@ RTN *FNAME ARGS \ | |||
239 | return NULL; \ | 231 | return NULL; \ |
240 | } | 232 | } |
241 | 233 | ||
242 | #define DefineSimpleCacheLookup(STRUCT,INPLACE) \ | 234 | #define DefineSimpleCacheLookup(STRUCT, FUNC) \ |
243 | DefineCacheLookup(struct STRUCT, h, STRUCT##_lookup, (struct STRUCT *item, int set), /*no setup */, \ | 235 | DefineCacheLookup(struct STRUCT, h, FUNC##_lookup, \ |
244 | & STRUCT##_cache, STRUCT##_hash(item), STRUCT##_match(item, tmp),\ | 236 | (struct STRUCT *item, int set), /*no setup */, \ |
245 | STRUCT##_init(new, item), STRUCT##_update(tmp, item),INPLACE) | 237 | & FUNC##_cache, FUNC##_hash(item), FUNC##_match(item, tmp), \ |
238 | STRUCT##_init(new, item), STRUCT##_update(tmp, item)) | ||
239 | |||
246 | 240 | ||
247 | #define cache_for_each(pos, detail, index, member) \ | 241 | #define cache_for_each(pos, detail, index, member) \ |
248 | for (({read_lock(&(detail)->hash_lock); index = (detail)->hash_size;}) ; \ | 242 | for (({read_lock(&(detail)->hash_lock); index = (detail)->hash_size;}) ; \ |
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 6b073c2e6930..aadb4e8d6aa7 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c | |||
@@ -259,7 +259,7 @@ static struct cache_detail rsi_cache = { | |||
259 | .cache_parse = rsi_parse, | 259 | .cache_parse = rsi_parse, |
260 | }; | 260 | }; |
261 | 261 | ||
262 | static DefineSimpleCacheLookup(rsi, 0) | 262 | static DefineSimpleCacheLookup(rsi, rsi) |
263 | 263 | ||
264 | /* | 264 | /* |
265 | * The rpcsec_context cache is used to store a context that is | 265 | * The rpcsec_context cache is used to store a context that is |
@@ -446,7 +446,7 @@ static struct cache_detail rsc_cache = { | |||
446 | .cache_parse = rsc_parse, | 446 | .cache_parse = rsc_parse, |
447 | }; | 447 | }; |
448 | 448 | ||
449 | static DefineSimpleCacheLookup(rsc, 0); | 449 | static DefineSimpleCacheLookup(rsc, rsc); |
450 | 450 | ||
451 | static struct rsc * | 451 | static struct rsc * |
452 | gss_svc_searchbyctx(struct xdr_netobj *handle) | 452 | gss_svc_searchbyctx(struct xdr_netobj *handle) |
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 17e8b2a3130c..7ddf068b5b25 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c | |||
@@ -258,7 +258,7 @@ struct cache_detail ip_map_cache = { | |||
258 | .cache_show = ip_map_show, | 258 | .cache_show = ip_map_show, |
259 | }; | 259 | }; |
260 | 260 | ||
261 | static DefineSimpleCacheLookup(ip_map, 0) | 261 | static DefineSimpleCacheLookup(ip_map, ip_map) |
262 | 262 | ||
263 | 263 | ||
264 | int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom) | 264 | int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom) |