knfsd: Introduction
Subsystems (3)
PATCH 1/1 knfsd: Introduction
The following series of patches changes the code for lookup up authentication/authorisation caches in sunrpc as used by nfsd. That than having a delightful macro that defines a function of a particular type of cache, the functions are coded on a more traditional manner using library routines.
This will hopefully make the code more maintainable.
This series should not effect the functionality at all -- except maybe to fix some very minor bugs
This is against 2.6.16-rc5-mm2 and is NOT suitable for 2.6.16, but maybe for .17 (though holding it back to .18 wouldn't be a big problem if any issues came up).
Thanks,
NeilBrown
[PATCH 000 of 14] knfsd: Introduction
[PATCH 001 of 14] knfsd: Change the store of auth_domains to not be a 'cache'. [PATCH 002 of 14] knfsd: Break the hard linkage from svc_expkey to svc_export [PATCH 003 of 14] knfsd: Get rid of 'inplace' sunrpc caches
[PATCH 004 of 14] knfsd: Create cache_lookup function instead of using a macro to declare one. [PATCH 005 of 14] knfsd: Convert ip_map cache to use the new lookup routine. [PATCH 006 of 14] knfsd: Use new cache_lookup for svc_export
[PATCH 007 of 14] knfsd: Use new cache_lookup for svc_expkey cache.
[PATCH 008 of 14] knfsd: Use new sunrpc cache for rsi cache
[PATCH 009 of 14] knfsd: Use new cache code for rsc cache
[PATCH 010 of 14] knfsd: Use new cache code for name/id lookup caches
[PATCH 011 of 14] knfsd: An assortment of little fixes to the sunrpc cache code. [PATCH 012 of 14] knfsd: Remove DefineCacheLookup
[PATCH 013 of 14] knfsd: Unexport cache_fresh and fix a small race.
[PATCH 014 of 14] knfsd: Convert sunrpc_cache to use krefs
PATCH 1/1 knfsd: Change the store of auth_domains to not be a 'cache'.
The 'auth_domain's are simply handles on internal data structures. They do not cache information from user-space, and forcing them into the mold of a 'cache' misrepresents their true nature and causes confusion.
### Diffstat output
./fs/nfsd/export.c | 5 +- ./include/linux/sunrpc/svcauth.h | 10 +++-- ./net/sunrpc/auth_gss/svcauth_gss.c | 14 +++---- ./net/sunrpc/svcauth_unix.c | 66 ++++++++++++++++-------------------- 4 files changed, 46 insertions(+), 49 deletions(-)
fs/nfsd/export.c renamed from fs/nfsd/export.c~current~ +2 -3
@@ -242,7 +242,7 @@ static inline int svc_expkey_match (strustatic inline void svc_expkey_init (struct svc_expkey *new,struct svc_expkey *item) { -cache_get (&item->ek_client->h); +kref_get (&item->ek_client->ref); new->ek_client = item->ek_client; new->ek_fsidtype = item->ek_fsidtype; new->ek_fsid[0 ] = item->ek_fsid[0 ];
@@ -474,7 +474,7 @@ static inline int svc_export_match(struc }static inline void svc_export_init (struct svc_export *new,struct svc_export *item) { -cache_get (&item->ex_client->h); +kref_get (&item->ex_client->ref); new->ex_client = item->ex_client; new->ex_dentry =dget (item->ex_dentry); new->ex_mnt =mntget (item->ex_mnt);
@@ -1129,7 +1129,6 @@ exp_delclient(struct nfsctl_client *ncp)*/ if (dom) { err =auth_unix_forget_old (dom); - dom->h.expiry_time =get_seconds ();auth_domain_put (dom); }
include/linux/sunrpc/svcauth.h renamed from include/linux/sunrpc/svcauth.h~current~ +7 -3
@@ -45,9 +45,10 @@ struct svc_rqst; /* forward decl */* of ip addresses to the given client. */ struct auth_domain { -struct cache_head h; +struct kref ref; +struct hlist_node hash;char *name; -int flavour; +struct auth_ops *flavour; };/*
@@ -86,6 +87,9 @@ struct auth_domain {* * domain_release() * This call releases a domain. +* set_client() +* Givens a pending request (struct svc_rqst), finds and assigns +* an appropriate 'auth_domain' as the client. */ struct auth_ops {char * name;
@@ -117,7 +121,7 @@ extern void svc_auth_unregister(rpc_authextern struct auth_domain *unix_domain_find (char *name);extern void auth_domain_put (struct auth_domain *item);extern int auth_unix_add_addr (struct in_addr addr,struct auth_domain *dom); -extern struct auth_domain *auth_domain_lookup (struct auth_domain *item,int set); +extern struct auth_domain *auth_domain_lookup (char *name,struct auth_domain *new);extern struct auth_domain *auth_domain_find (char *name);extern struct auth_domain *auth_unix_lookup (struct in_addr addr);extern int auth_unix_forget_old (struct auth_domain *dom);
net/sunrpc/auth_gss/svcauth_gss.c renamed from net/sunrpc/auth_gss/svcauth_gss.c~current~ +7 -7
@@ -645,6 +645,8 @@ find_gss_auth_domain(struct gss_ctx *ctxreturn auth_domain_find (name); } +static struct auth_ops svcauthops_gss; +int svcauth_gss_register_pseudoflavor (u32 pseudoflavor,char * name) {
@@ -655,20 +657,18 @@ svcauth_gss_register_pseudoflavor(u32 ps new =kmalloc (sizeof (*new),GFP_KERNEL );if (!new) goto out; -cache_init (&new->h.h); +kref_init (&new->h.ref); new->h.name =kmalloc (strlen (name) +1 ,GFP_KERNEL );if (!new->h.name) goto out_free_dom;strcpy (new->h.name, name); - new->h.flavour =RPC_AUTH_GSS ; + new->h.flavour = &svcauthops_gss; new->pseudoflavor = pseudoflavor; - new->h.h.expiry_time =NEVER ; - test =auth_domain_lookup (&new->h,1 ); -if (test == &new->h) { -BUG_ON (atomic_dec_and_test (&new->h.h.refcnt)); - }else {/* XXX Duplicate registration? */ + test =auth_domain_lookup (name, &new->h); +if (test != &new->h) {/* XXX Duplicate registration? */ auth_domain_put (&new->h); +/* dangling ref-count... */ goto out; }return 0 ;
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +30 -36
106 lines not on this page · raw message
Re: [PATCH 001 of 14] knfsd: Change the store of auth_domains to not be a 'cache'.
Quoted 7 lines · NeilBrown
struct
auth_domain*unix_domain_find(char *name)
{
- [code deletions removed]net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +2
-1+struct auth_domain *rv; +struct unix_domain *new =NULL ; - [code deletions removed]
net/sunrpc/svcauth_unix.c struct unix_domain {
Quoted 10 lines
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +9
-0+ rv =auth_domain_lookup (name,NULL ); +while (1 ) { +if (rv != &new->h) { +if (new)auth_domain_put (&new->h); +return rv; + } + new =kmalloc (sizeof (*new),GFP_KERNEL ); +if (new ==NULL ) +return NULL ;
My C skills are a bit rusty, but is seems the value of new is offsetted while still NULL. I could not find any further updates in the patch series.
-Paul
PATCH 1/1 knfsd: Break the hard linkage from svc_expkey to svc_export
In reply to NeilBrownCurrent svc_expkey holds a pointer to the svc_export structure, so updates to that structure have to be in-place, which is a wart on the whole cache infrastruct.
So we break that linkage and just do a second lookup.
If this became a performance issue, it would be possible to put a direct link back in which was only used conditionally.
i.e. when an object is replaced in the cache, we set a flag in the old object. When dereferencing the link from svc_expkey, if the flag is set, we drop the reference and do a fresh lookup.
### Diffstat output
./fs/nfsd/export.c | 60 ++++++++++++++++++++++++++++-------------- ./include/linux/nfsd/export.h | 20 ++------------ 2 files changed, 44 insertions(+), 36 deletions(-)
fs/nfsd/export.c renamed from fs/nfsd/export.c~current~ +40 -20
@@ -73,8 +73,10 @@ void expkey_put(struct cache_head *item,if (cache_put (item, cd)) { struct svc_expkey *key = container_of(item, struct svc_expkey, h);if (test_bit (CACHE_VALID , &item->flags) && - !test_bit (CACHE_NEGATIVE , &item->flags)) -exp_put (key->ek_export); + !test_bit (CACHE_NEGATIVE , &item->flags)) { +dput (key->ek_dentry); +mntput (key->ek_mnt); + }auth_domain_put (key->ek_client);kfree (key); }
@@ -164,26 +166,18 @@ static int expkey_parse(struct cache_det }else {struct nameidata nd;struct svc_expkey *ek; -struct svc_export *exp; err =path_lookup (buf,0 , &nd);if (err) goto out;dprintk ("Found the path %s\n" , buf); - exp =exp_get_by_name (dom, nd.mnt, nd.dentry,NULL ); - - err = -ENOENT ; -if (!exp) - goto out_nd; - key.ek_export = exp; -dprintk ("And found export\n" ); + key.ek_mnt = nd.mnt; + key.ek_dentry = nd.dentry; ek =svc_expkey_lookup (&key,1 );if (ek)expkey_put (&ek->h, &svc_expkey_cache); -exp_put (exp); err =0 ; - out_nd:path_release (&nd); }cache_flush ();
@@ -214,7 +208,7 @@ static int expkey_show(struct seq_file *if (test_bit (CACHE_VALID , &h->flags) && !test_bit (CACHE_NEGATIVE , &h->flags)) {seq_printf (m," " ); -seq_path (m, ek->ek_export->ex_mnt, ek->ek_export->ex_dentry,"\\ \t\n" ); +seq_path (m, ek->ek_mnt, ek->ek_dentry,"\\ \t\n" ); }seq_printf (m,"\n" );return 0 ;
@@ -252,8 +246,8 @@ static inline void svc_expkey_init(strucstatic inline void svc_expkey_update (struct svc_expkey *new,struct svc_expkey *item) { -cache_get (&item->ek_export->h); - new->ek_export = item->ek_export; + new->ek_mnt =mntget (item->ek_mnt); + new->ek_dentry =dget (item->ek_dentry); } static DefineSimpleCacheLookup(svc_expkey,0) /* no inplace updates */
@@ -519,7 +513,8 @@ static int exp_set_key(svc_client *clp, key.ek_client = clp; key.ek_fsidtype = fsid_type;memcpy (key.ek_fsid, fsidv,key_len (fsid_type)); - key.ek_export = exp; + key.ek_mnt = exp->ex_mnt; + key.ek_dentry = exp->ex_dentry; key.h.expiry_time =NEVER ; key.h.flags =0 ;
@@ -741,8 +736,8 @@ exp_export(struct nfsctl_export *nxp)if ((nxp->ex_flags &NFSEXP_FSID ) && (fsid_key =exp_get_fsid_key (clp, nxp->ex_dev)) && !IS_ERR (fsid_key) && - fsid_key->ek_export && - fsid_key->ek_export != exp) + fsid_key->ek_mnt && + (fsid_key->ek_mnt != nd.mnt || fsid_key->ek_dentry != nd.dentry) ) goto finish;if (exp) {
@@ -912,6 +907,24 @@ out:return err; } +struct svc_export * +exp_find (struct auth_domain *clp,int fsid_type,u32 *fsidv, +struct cache_req *reqp) +{ +struct svc_export *exp; +struct svc_expkey *ek =exp_find_key (clp, fsid_type, fsidv, reqp); +if (!ek ||IS_ERR (ek)) +return ERR_PTR (PTR_ERR (ek)); + + exp =exp_get_by_name (clp, ek->ek_mnt, ek->ek_dentry, reqp); +expkey_put (&ek->h, &svc_expkey_cache); + +if (!exp ||IS_ERR (exp)) +return ERR_PTR (PTR_ERR (exp)); +return exp; +} + +/* * Called when we need the filehandle for the root of the pseudofs, * for a given NFSv4 client. The root is defined to be the
@@ -922,6 +935,7 @@ exp_pseudoroot(struct auth_domain *clp, struct cache_req *creq) {struct svc_expkey *fsid_key; +struct svc_export *exp;int rv;u32 fsidv[2 ];
@@ -933,8 +947,14 @@ exp_pseudoroot(struct auth_domain *clp,if (!fsid_key ||IS_ERR (fsid_key))return nfserr_perm; - rv =fh_compose (fhp, fsid_key->ek_export, - fsid_key->ek_export->ex_dentry,NULL ); + exp =exp_get_by_name (clp, fsid_key->ek_mnt, fsid_key->ek_dentry, creq); +if (exp ==NULL ) + rv = nfserr_perm; +else if (IS_ERR (exp)) + rv =nfserrno (PTR_ERR (exp)); +else + rv =fh_compose (fhp, exp, + fsid_key->ek_dentry,NULL );expkey_put (&fsid_key->h, &svc_expkey_cache);return rv; }
include/linux/nfsd/export.h renamed from include/linux/nfsd/export.h~current~ +4 -16
@@ -67,7 +67,8 @@ struct svc_expkey {int ek_fsidtype;u32 ek_fsid[3 ]; -struct svc_export * ek_export; +struct vfsmount * ek_mnt; +struct dentry * ek_dentry; };#define EX_SECURE (exp) (!((exp)->ex_flags & NFSEXP_INSECURE_PORT))
@@ -114,22 +115,9 @@ static inline void exp_get(struct svc_ex {cache_get (&exp->h); } -static inline struct svc_export * +extern struct svc_export *exp_find (struct auth_domain *clp,int fsid_type,u32 *fsidv, -struct cache_req *reqp) -{ -struct svc_expkey *ek =exp_find_key (clp, fsid_type, fsidv, reqp); -if (ek && !IS_ERR (ek)) { -struct svc_export *exp = ek->ek_export; -int err; -exp_get (exp); -expkey_put (&ek->h, &svc_expkey_cache); -if ((err =cache_check (&svc_export_cache, &exp->h, reqp))) - exp =ERR_PTR (err); -return exp; - }else -return ERR_PTR (PTR_ERR (ek)); -} +struct cache_req *reqp);#endif /* __KERNEL__ */
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Get rid of 'inplace' sunrpc caches
In reply to NeilBrownThese were an unnecessary wart.
Also only have one 'DefineSimpleCache..' instead of two.
### Diffstat output
./fs/nfsd/export.c | 4 ++-- ./fs/nfsd/nfs4idmap.c | 10 ++-------- ./include/linux/sunrpc/cache.h | 28 +++++++++++----------------- ./net/sunrpc/auth_gss/svcauth_gss.c | 4 ++-- ./net/sunrpc/svcauth_unix.c | 2 +- 5 files changed, 18 insertions(+), 30 deletions(-)
fs/nfsd/export.c renamed from fs/nfsd/export.c~current~ +2 -2
@@ -250,7 +250,7 @@ static inline void svc_expkey_update(str new->ek_dentry =dget (item->ek_dentry); } -static DefineSimpleCacheLookup(svc_expkey,0) /* no inplace updates */ +static DefineSimpleCacheLookup(svc_expkey, svc_expkey)#define EXPORT_HASHBITS 8#define EXPORT_HASHMAX (1<< EXPORT_HASHBITS)
@@ -482,7 +482,7 @@ static inline void svc_export_update(str new->ex_fsid = item->ex_fsid; } -static DefineSimpleCacheLookup(svc_export,1) /* allow inplace updates */ +static DefineSimpleCacheLookup(svc_export, svc_export) struct svc_expkey *
fs/nfsd/nfs4idmap.c renamed from fs/nfsd/nfs4idmap.c~current~ +2 -8
@@ -76,12 +76,6 @@ struct ent {char authname[IDMAP_NAMESZ ]; }; -#define DefineSimpleCacheLookupMap(STRUCT, FUNC) \ - DefineCacheLookup(struct STRUCT, h, FUNC##_lookup, \ - (struct STRUCT *item, int set), /*no setup */, \ - & FUNC##_cache, FUNC##_hash(item), FUNC##_match(item, tmp), \ - STRUCT##_init(new, item), STRUCT##_update(tmp, item), 0) -/* Common entry handling */ #define ENT_HASHBITS 8
@@ -264,7 +258,7 @@ out:return error; } -static DefineSimpleCacheLookupMap(ent, idtoname); +static DefineSimpleCacheLookup(ent, idtoname);/* * Name -> ID cache
@@ -390,7 +384,7 @@ out:return (error); } -static DefineSimpleCacheLookupMap(ent, nametoid); +static DefineSimpleCacheLookup(ent, nametoid);/* * Exported API
include/linux/sunrpc/cache.h renamed from include/linux/sunrpc/cache.h~current~ +11 -17
@@ -133,14 +133,11 @@ struct cache_deferred_req {* If "set" == 0 : * If an entry is found, it is returned * If no entry is found, a new non-VALID entry is created. -* If "set" == 1 and INPLACE == 0 : +* If "set" == 1 : * If no entry is found a new one is inserted with data from "template" * If a non-CACHE_VALID entry is found, it is updated from template using UPDATE * If a CACHE_VALID entry is found, a new entry is swapped in with data * from "template" -* If set == 1, and INPLACE == 1 : -* As above, except that if a CACHE_VALID entry is found, we UPDATE in place -* instead of swapping in a new entry. * * If the passed handle has the CACHE_NEGATIVE flag set, then UPDATE is not * run but insteead CACHE_NEGATIVE is set in any new item.
@@ -159,13 +156,8 @@ struct cache_deferred_req {* TEST tests if "tmp" matches "item" * INIT copies key information from "item" to "new" * UPDATE copies content information from "item" to "tmp" -* INPLACE is true if updates can happen inplace rather than allocating a new structure -* -* WARNING: any substantial changes to this must be reflected in -* net/sunrpc/svcauth.c(auth_domain_lookup) -* which is a similar routine that is open-coded. */ -#define DefineCacheLookup (RTN ,MEMBER ,FNAME ,ARGS ,SETUP ,DETAIL ,HASHFN ,TEST ,INIT ,UPDATE ,INPLACE ) \ +#define DefineCacheLookup (RTN ,MEMBER ,FNAME ,ARGS ,SETUP ,DETAIL ,HASHFN ,TEST ,INIT ,UPDATE ) \ RTN *FNAME ARGS \ { \ RTN *tmp, *new=NULL; \
@@ -179,13 +171,13 @@ RTN *FNAME ARGS \ tmp =container_of (*hp,RTN ,MEMBER ); \if (TEST ) {/* found a match */ \ \ -if (set && !INPLACE &&test_bit (CACHE_VALID , &tmp->MEMBER.flags) && !new) \ +if (set &&test_bit (CACHE_VALID , &tmp->MEMBER.flags) && !new) \break ; \ \if (new) \ {INIT ;} \if (set) { \ -if (!INPLACE &&test_bit (CACHE_VALID , &tmp->MEMBER.flags))\ +if (test_bit (CACHE_VALID , &tmp->MEMBER.flags))\ {/* need to swap in new */ \RTN *t2; \ \
@@ -206,7 +198,7 @@ RTN *FNAME ARGS \else read_unlock (&(DETAIL )->hash_lock); \if (set) \cache_fresh (DETAIL , &tmp->MEMBER, item->MEMBER.expiry_time); \ -if (set && !INPLACE && new)cache_fresh (DETAIL , &new->MEMBER,0 ); \ +if (set && new)cache_fresh (DETAIL , &new->MEMBER,0 ); \if (new) (DETAIL )->cache_put (&new->MEMBER,DETAIL ); \return tmp; \ } \
@@ -239,10 +231,12 @@ RTN *FNAME ARGS \return NULL ; \ } -#define DefineSimpleCacheLookup(STRUCT,INPLACE) \ - DefineCacheLookup(struct STRUCT, h, STRUCT##_lookup, (struct STRUCT *item, int set), /*no setup */, \ - & STRUCT##_cache, STRUCT##_hash(item), STRUCT##_match(item, tmp),\ - STRUCT##_init(new, item), STRUCT##_update(tmp, item),INPLACE) +#define DefineSimpleCacheLookup(STRUCT, FUNC) \ + DefineCacheLookup(struct STRUCT, h, FUNC##_lookup, \ + (struct STRUCT *item, int set), /*no setup */, \ + & FUNC##_cache, FUNC##_hash(item), FUNC##_match(item, tmp), \ + STRUCT##_init(new, item), STRUCT##_update(tmp, item)) +#define cache_for_each (pos, detail, index, member) \ for (({read_lock(&(detail)->hash_lock); index = (detail)->hash_size;}) ; \
net/sunrpc/auth_gss/svcauth_gss.c renamed from net/sunrpc/auth_gss/svcauth_gss.c~current~ +2 -2
@@ -259,7 +259,7 @@ static struct cache_detail rsi_cache = { .cache_parse = rsi_parse, }; -static DefineSimpleCacheLookup(rsi, 0) +static DefineSimpleCacheLookup(rsi, rsi)/* * The rpcsec_context cache is used to store a context that is
@@ -446,7 +446,7 @@ static struct cache_detail rsc_cache = { .cache_parse = rsc_parse, }; -static DefineSimpleCacheLookup(rsc, 0); +static DefineSimpleCacheLookup(rsc, rsc);static struct rsc *gss_svc_searchbyctx (struct xdr_netobj *handle)
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +1 -1
@@ -258,7 +258,7 @@ struct cache_detail ip_map_cache = { .cache_show = ip_map_show, }; -static DefineSimpleCacheLookup(ip_map, 0) +static DefineSimpleCacheLookup(ip_map, ip_map) int auth_unix_add_addr(struct in_addr addr, struct auth_domain *dom)
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Create cache_lookup function instead of using a macro to declare one.
In reply to NeilBrownThe C++-like 'template' approach proves to be too ugly and hard to work with.
The old 'template' won't go away until all users are updated.
### Diffstat output
./include/linux/sunrpc/cache.h | 12 +++++ ./net/sunrpc/cache.c | 98 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+)
include/linux/sunrpc/cache.h renamed from include/linux/sunrpc/cache.h~current~ +12 -0
@@ -81,6 +81,11 @@ struct cache_detail {struct cache_detail *cd, struct cache_head *h); +struct cache_head * (*alloc)(void ); +int (*match)(struct cache_head *orig,struct cache_head *new); +void (*init)(struct cache_head *orig,struct cache_head *new); +void (*update)(struct cache_head *orig,struct cache_head *new); +/* fields below this comment are for internal use * and should not be touched by cache owners */
@@ -237,6 +242,13 @@ RTN *FNAME ARGS \ & FUNC##_cache, FUNC##_hash(item), FUNC##_match(item, tmp), \ STRUCT##_init(new, item), STRUCT##_update(tmp, item)) +extern struct cache_head * +sunrpc_cache_lookup (struct cache_detail *detail, +struct cache_head *key,int hash); +extern struct cache_head * +sunrpc_cache_update (struct cache_detail *detail, +struct cache_head *new,struct cache_head *old,int hash); +#define cache_for_each (pos, detail, index, member) \ for (({read_lock(&(detail)->hash_lock); index = (detail)->hash_size;}) ; \
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~current~ +98 -0
104 lines not on this page · raw message
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Convert ip_map cache to use the new lookup routine.
In reply to NeilBrown### Diffstat output
./net/sunrpc/svcauth_unix.c | 143 +++++++++++++++++++++++++++++--------------- 1 file changed, 95 insertions(+), 48 deletions(-)
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +95 -48
@@ -106,28 +106,38 @@ static inline int hash_ip(unsigned longreturn (hash ^ (hash>>8 )) &0xff ; }#endif - -static inline int ip_map_hash (struct ip_map *item) -{ -return hash_str (item->m_class,IP_HASHBITS ) ^ -hash_ip ((unsigned long )item->m_addr.s_addr); -} -static inline int ip_map_match (struct ip_map *item,struct ip_map *tmp) +static int ip_map_match (struct cache_head *corig,struct cache_head *cnew) { -return strcmp (tmp->m_class, item->m_class) ==0 - && tmp->m_addr.s_addr == item->m_addr.s_addr; + struct ip_map *orig = container_of(corig, struct ip_map, h); + struct ip_map *new = container_of(cnew, struct ip_map, h); +return strcmp (orig->m_class, new->m_class) ==0 + && orig->m_addr.s_addr == new->m_addr.s_addr; } -static inline void ip_map_init (struct ip_map *new,struct ip_map *item) +static void ip_map_init (struct cache_head *cnew,struct cache_head *citem) { + struct ip_map *new = container_of(cnew, struct ip_map, h); + struct ip_map *item = container_of(citem, struct ip_map, h); +strcpy (new->m_class, item->m_class); new->m_addr.s_addr = item->m_addr.s_addr; } -static inline void ip_map_update (struct ip_map *new,struct ip_map *item) +static void update (struct cache_head *cnew,struct cache_head *citem) { + struct ip_map *new = container_of(cnew, struct ip_map, h); + struct ip_map *item = container_of(citem, struct ip_map, h); +kref_get (&item->m_client->h.ref); new->m_client = item->m_client; new->m_add_change = item->m_add_change; } +static struct cache_head *ip_map_alloc (void ) +{ +struct ip_map *i =kmalloc (sizeof (*i),GFP_KERNEL ); +if (i) +return &i->h; +else +return NULL ; +} static void ip_map_request(struct cache_detail *cd, struct cache_head *h,
@@ -148,7 +158,8 @@ static void ip_map_request(struct cache_ (*bpp)[-1 ] ='\n' ; } -static struct ip_map *ip_map_lookup (struct ip_map *,int ); +static struct ip_map *ip_map_lookup (char *class,struct in_addr addr); +static int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry);static int ip_map_parse (struct cache_detail *cd,char *mesg,int mlen)
@@ -160,7 +171,11 @@ static int ip_map_parse(struct cache_detint len;int b1,b2,b3,b4;char c; -struct ip_map ipm, *ipmp; +char class[8 ]; +struct in_addr addr; +int err; + +struct ip_map *ipmp;struct auth_domain *dom;time_t expiry;
@@ -169,7 +184,7 @@ static int ip_map_parse(struct cache_det mesg[mlen-1 ] =0 ;/* class */ - len =qword_get (&mesg, ipm.m_class,sizeof (ipm.m_class)); + len =qword_get (&mesg, class,sizeof (class));if (len <=0 )return -EINVAL ;/* ip address */
@@ -194,25 +209,22 @@ static int ip_map_parse(struct cache_det }else dom =NULL ; - ipm.m_addr.s_addr = + addr.s_addr =htonl ((((((b1<<8 )|b2)<<8 )|b3)<<8 )|b4); - ipm.h.flags =0 ; -if (dom) { - ipm.m_client = container_of(dom, struct unix_domain, h); - ipm.m_add_change = ipm.m_client->addr_changes; + + ipmp =ip_map_lookup (class,addr); +if (ipmp) { + err =ip_map_update (ipmp, + container_of(dom, struct unix_domain, h), + expiry); }else -set_bit (CACHE_NEGATIVE , &ipm.h.flags); - ipm.h.expiry_time = expiry; + err = -ENOMEM ; - ipmp =ip_map_lookup (&ipm,1 ); -if (ipmp) -ip_map_put (&ipmp->h, &ip_map_cache);if (dom)auth_domain_put (dom); -if (!ipmp) -return -ENOMEM ; +cache_flush (); -return 0 ; +return err; } static int ip_map_show(struct seq_file *m,
@@ -256,32 +268,70 @@ struct cache_detail ip_map_cache = { .cache_request = ip_map_request, .cache_parse = ip_map_parse, .cache_show = ip_map_show, + .match = ip_map_match, + .init = ip_map_init, + .update = update, + .alloc = ip_map_alloc, }; -static DefineSimpleCacheLookup(ip_map, ip_map) +static struct ip_map *ip_map_lookup (char *class,struct in_addr addr) +{ +struct ip_map ip; +struct cache_head *ch; +strcpy (ip.m_class, class); + ip.m_addr = addr; + ch =sunrpc_cache_lookup (&ip_map_cache, &ip.h, +hash_str (class,IP_HASHBITS ) ^ +hash_ip ((unsigned long )addr.s_addr)); + +if (ch) + return container_of(ch, struct ip_map, h); +else +return NULL ; +} + +static int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry) +{ +struct ip_map ip; +struct cache_head *ch; + + ip.m_client = udom; + ip.h.flags =0 ; +if (!udom) +set_bit (CACHE_NEGATIVE , &ip.h.flags); +else { + ip.m_add_change = udom->addr_changes; +/* if this is from the legacy set_client system call, +* we need m_add_change to be one higher +*/ +if (expiry ==NEVER ) + ip.m_add_change++; + } + ip.h.expiry_time = expiry; + ch =sunrpc_cache_update (&ip_map_cache, + &ip.h, &ipm->h, +hash_str (ipm->m_class,IP_HASHBITS ) ^ +hash_ip ((unsigned long )ipm->m_addr.s_addr)); +if (!ch) +return -ENOMEM ; +ip_map_put (ch, &ip_map_cache); +return 0 ; +}int auth_unix_add_addr (struct in_addr addr,struct auth_domain *dom) {struct unix_domain *udom; -struct ip_map ip, *ipmp; +struct ip_map *ipmp;if (dom->flavour != &svcauth_unix)return -EINVAL ; udom = container_of(dom, struct unix_domain, h); -strcpy (ip.m_class,"nfsd" ); - ip.m_addr = addr; - ip.m_client = udom; - ip.m_add_change = udom->addr_changes+1 ; - ip.h.flags =0 ; - ip.h.expiry_time =NEVER ; - - ipmp =ip_map_lookup (&ip,1 ); + ipmp =ip_map_lookup ("nfsd" , addr); -if (ipmp) { -ip_map_put (&ipmp->h, &ip_map_cache); -return 0 ; - }else +if (ipmp) +return ip_map_update (ipmp, udom,NEVER ); +else return -ENOMEM ; }
@@ -304,7 +354,7 @@ struct auth_domain *auth_unix_lookup(strstrcpy (key.m_class,"nfsd" ); key.m_addr = addr; - ipm =ip_map_lookup (&key,0 ); + ipm =ip_map_lookup ("nfsd" , addr);if (!ipm)return NULL ;
@@ -326,22 +376,19 @@ struct auth_domain *auth_unix_lookup(strvoid svcauth_unix_purge (void ) {cache_purge (&ip_map_cache); -cache_purge (&auth_domain_cache); }static int svcauth_unix_set_client (struct svc_rqst *rqstp) { -struct ip_map key, *ipm; +struct ip_map *ipm; rqstp->rq_client =NULL ;if (rqstp->rq_proc ==0 )return SVC_OK ; -strcpy (key.m_class, rqstp->rq_server->sv_program->pg_class); - key.m_addr = rqstp->rq_addr.sin_addr; - - ipm =ip_map_lookup (&key,0 ); + ipm =ip_map_lookup (rqstp->rq_server->sv_program->pg_class, + rqstp->rq_addr.sin_addr);if (ipm ==NULL )return SVC_DENIED ;
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Use new cache_lookup for svc_export
In reply to NeilBrown### Diffstat output
./fs/nfsd/export.c | 125 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 37 deletions(-)
fs/nfsd/export.c renamed from fs/nfsd/export.c~current~ +88 -37
@@ -258,16 +258,6 @@ static DefineSimpleCacheLookup(svc_expkestatic struct cache_head *export_table[EXPORT_HASHMAX ]; -static inline int svc_export_hash (struct svc_export *item) -{ -int rv; - - rv =hash_ptr (item->ex_client,EXPORT_HASHBITS ); - rv ^=hash_ptr (item->ex_dentry,EXPORT_HASHBITS ); - rv ^=hash_ptr (item->ex_mnt,EXPORT_HASHBITS ); -return rv; -} -void svc_export_put (struct cache_head *item,struct cache_detail *cd) {if (cache_put (item, cd)) {
@@ -298,7 +288,8 @@ static void svc_export_request(struct ca (*bpp)[-1 ] ='\n' ; } -static struct svc_export *svc_export_lookup (struct svc_export *,int ); +struct svc_export *svc_export_update (struct svc_export *new,struct svc_export *old); +static struct svc_export *svc_export_lookup (struct svc_export *);static int check_export (struct inode *inode,int flags) {
@@ -411,11 +402,16 @@ static int svc_export_parse(struct cacheif (err) goto out; } - expp =svc_export_lookup (&exp,1 ); + expp =svc_export_lookup (&exp);if (expp) -exp_put (expp); - err =0 ; + expp =svc_export_update (&exp, expp); +else + err = -ENOMEM ;cache_flush (); +if (expp ==NULL ) + err = -ENOMEM ; +else +exp_put (expp); out:if (nd.dentry)path_release (&nd);
@@ -449,40 +445,95 @@ static int svc_export_show(struct seq_fiseq_puts (m,")\n" );return 0 ; } -struct cache_detail svc_export_cache = { - .owner =THIS_MODULE , - .hash_size =EXPORT_HASHMAX , - .hash_table = export_table, - .name ="nfsd.export" , - .cache_put = svc_export_put, - .cache_request = svc_export_request, - .cache_parse = svc_export_parse, - .cache_show = svc_export_show, -}; - -static inline int svc_export_match (struct svc_export *a,struct svc_export *b) +static int svc_export_match (struct cache_head *a,struct cache_head *b) { -return a->ex_client == b->ex_client && - a->ex_dentry == b->ex_dentry && - a->ex_mnt == b->ex_mnt; + struct svc_export *orig = container_of(a, struct svc_export, h); + struct svc_export *new = container_of(b, struct svc_export, h); +return orig->ex_client == new->ex_client && + orig->ex_dentry == new->ex_dentry && + orig->ex_mnt == new->ex_mnt; } -static inline void svc_export_init (struct svc_export *new,struct svc_export *item) + +static void svc_export_init (struct cache_head *cnew,struct cache_head *citem) { + struct svc_export *new = container_of(cnew, struct svc_export, h); + struct svc_export *item = container_of(citem, struct svc_export, h); +kref_get (&item->ex_client->ref); new->ex_client = item->ex_client; new->ex_dentry =dget (item->ex_dentry); new->ex_mnt =mntget (item->ex_mnt); } -static inline void svc_export_update (struct svc_export *new,struct svc_export *item) +static void export_update (struct cache_head *cnew,struct cache_head *citem) { + struct svc_export *new = container_of(cnew, struct svc_export, h); + struct svc_export *item = container_of(citem, struct svc_export, h); + new->ex_flags = item->ex_flags; new->ex_anon_uid = item->ex_anon_uid; new->ex_anon_gid = item->ex_anon_gid; new->ex_fsid = item->ex_fsid; } -static DefineSimpleCacheLookup(svc_export, svc_export) +static struct cache_head *svc_export_alloc (void ) +{ +struct svc_export *i =kmalloc (sizeof (*i),GFP_KERNEL ); +if (i) +return &i->h; +else +return NULL ; +} + +struct cache_detail svc_export_cache = { + .owner =THIS_MODULE , + .hash_size =EXPORT_HASHMAX , + .hash_table = export_table, + .name ="nfsd.export" , + .cache_put = svc_export_put, + .cache_request = svc_export_request, + .cache_parse = svc_export_parse, + .cache_show = svc_export_show, + .match = svc_export_match, + .init = svc_export_init, + .update = export_update, + .alloc = svc_export_alloc, +}; + +static struct svc_export * +svc_export_lookup (struct svc_export *exp) +{ +struct cache_head *ch; +int hash; + hash =hash_ptr (exp->ex_client,EXPORT_HASHBITS ); + hash ^=hash_ptr (exp->ex_dentry,EXPORT_HASHBITS ); + hash ^=hash_ptr (exp->ex_mnt,EXPORT_HASHBITS ); + + ch =sunrpc_cache_lookup (&svc_export_cache, &exp->h, + hash); +if (ch) + return container_of(ch, struct svc_export, h); +else +return NULL ; +} + +struct svc_export * +svc_export_update (struct svc_export *new,struct svc_export *old) +{ +struct cache_head *ch; +int hash; + hash =hash_ptr (old->ex_client,EXPORT_HASHBITS ); + hash ^=hash_ptr (old->ex_dentry,EXPORT_HASHBITS ); + hash ^=hash_ptr (old->ex_mnt,EXPORT_HASHBITS ); + + ch =sunrpc_cache_update (&svc_export_cache, &new->h, + &old->h, + hash); +if (ch) + return container_of(ch, struct svc_export, h); +else +return NULL ; +} struct svc_expkey *
@@ -568,7 +619,7 @@ exp_get_by_name(svc_client *clp, struct key.ex_mnt = mnt; key.ex_dentry = dentry; - exp =svc_export_lookup (&key,0 ); + exp =svc_export_lookup (&key);if (exp !=NULL )switch (cache_check (&svc_export_cache, &exp->h, reqp)) {case 0 :break ;
@@ -770,13 +821,13 @@ exp_export(struct nfsctl_export *nxp) new.ex_anon_gid = nxp->ex_anon_gid; new.ex_fsid = nxp->ex_dev; - exp =svc_export_lookup (&new,1 ); + exp =svc_export_lookup (&new); +if (exp) + exp =svc_export_update (&new, exp); -if (exp ==NULL ) +if (!exp) goto finish; - err =0 ; -if (exp_hash (clp, exp) ||exp_fsid_hash (clp, exp)) {/* failed to create at least one index */
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Use new cache_lookup for svc_expkey cache.
In reply to NeilBrown### Diffstat output
./fs/nfsd/export.c | 136 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 99 insertions(+), 37 deletions(-)
fs/nfsd/export.c renamed from fs/nfsd/export.c~current~ +99 -37
@@ -57,17 +57,6 @@ static int exp_verify_string(char *cp,#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1)static struct cache_head *expkey_table[EXPKEY_HASHMAX ]; -static inline int svc_expkey_hash (struct svc_expkey *item) -{ -int hash = item->ek_fsidtype; -char * cp = (char *)item->ek_fsid; -int len =key_len (item->ek_fsidtype); - - hash ^=hash_mem (cp, len,EXPKEY_HASHBITS ); - hash ^=hash_ptr (item->ek_client,EXPKEY_HASHBITS ); -return hash &EXPKEY_HASHMASK ; -} -void expkey_put (struct cache_head *item,struct cache_detail *cd) {if (cache_put (item, cd)) {
@@ -97,7 +86,8 @@ static void expkey_request(struct cache_ (*bpp)[-1 ] ='\n' ; } -static struct svc_expkey *svc_expkey_lookup (struct svc_expkey *,int ); +static struct svc_expkey *svc_expkey_update (struct svc_expkey *new,struct svc_expkey *old); +static struct svc_expkey *svc_expkey_lookup (struct svc_expkey *);static int expkey_parse (struct cache_detail *cd,char *mesg,int mlen) {/* client fsidtype fsid [path] */
@@ -108,6 +98,7 @@ static int expkey_parse(struct cache_detint fsidtype;char *ep;struct svc_expkey key; +struct svc_expkey *ek;if (mesg[mlen-1 ] !='\n' )return -EINVAL ;
@@ -152,20 +143,25 @@ static int expkey_parse(struct cache_det key.ek_fsidtype = fsidtype;memcpy (key.ek_fsid, buf, len); + ek =svc_expkey_lookup (&key); + err = -ENOMEM ; +if (!ek) + goto out; +/* now we want a pathname, or empty meaning NEGATIVE */ + err = -EINVAL ;if ((len=qword_get (&mesg, buf,PAGE_SIZE )) <0 ) goto out;dprintk ("Path seems to be <%s>\n" , buf); err =0 ;if (len ==0 ) { -struct svc_expkey *ek;set_bit (CACHE_NEGATIVE , &key.h.flags); - ek =svc_expkey_lookup (&key,1 ); + ek =svc_expkey_update (&key, ek);if (ek)expkey_put (&ek->h, &svc_expkey_cache); +else err = -ENOMEM ; }else {struct nameidata nd; -struct svc_expkey *ek; err =path_lookup (buf,0 , &nd);if (err) goto out;
@@ -174,10 +170,11 @@ static int expkey_parse(struct cache_det key.ek_mnt = nd.mnt; key.ek_dentry = nd.dentry; - ek =svc_expkey_lookup (&key,1 ); + ek =svc_expkey_update (&key, ek);if (ek)expkey_put (&ek->h, &svc_expkey_cache); - err =0 ; +else + err = -ENOMEM ;path_release (&nd); }cache_flush ();
@@ -213,29 +210,25 @@ static int expkey_show(struct seq_file *seq_printf (m,"\n" );return 0 ; } - -struct cache_detail svc_expkey_cache = { - .owner =THIS_MODULE , - .hash_size =EXPKEY_HASHMAX , - .hash_table = expkey_table, - .name ="nfsd.fh" , - .cache_put = expkey_put, - .cache_request = expkey_request, - .cache_parse = expkey_parse, - .cache_show = expkey_show, -}; -static inline int svc_expkey_match (struct svc_expkey *a,struct svc_expkey *b) +static inline int expkey_match (struct cache_head *a,struct cache_head *b) { -if (a->ek_fsidtype != b->ek_fsidtype || - a->ek_client != b->ek_client || -memcmp (a->ek_fsid, b->ek_fsid,key_len (a->ek_fsidtype)) !=0 ) + struct svc_expkey *orig = container_of(a, struct svc_expkey, h); + struct svc_expkey *new = container_of(b, struct svc_expkey, h); + +if (orig->ek_fsidtype != new->ek_fsidtype || + orig->ek_client != new->ek_client || +memcmp (orig->ek_fsid, new->ek_fsid,key_len (orig->ek_fsidtype)) !=0 )return 0 ;return 1 ; } -static inline void svc_expkey_init (struct svc_expkey *new,struct svc_expkey *item) +static inline void expkey_init (struct cache_head *cnew, +struct cache_head *citem) { + struct svc_expkey *new = container_of(cnew, struct svc_expkey, h); + struct svc_expkey *item = container_of(citem, struct svc_expkey, h); +kref_get (&item->ek_client->ref); new->ek_client = item->ek_client; new->ek_fsidtype = item->ek_fsidtype;
@@ -244,13 +237,80 @@ static inline void svc_expkey_init(struc new->ek_fsid[2 ] = item->ek_fsid[2 ]; } -static inline void svc_expkey_update (struct svc_expkey *new,struct svc_expkey *item) +static inline void expkey_update (struct cache_head *cnew, +struct cache_head *citem) { + struct svc_expkey *new = container_of(cnew, struct svc_expkey, h); + struct svc_expkey *item = container_of(citem, struct svc_expkey, h); + new->ek_mnt =mntget (item->ek_mnt); new->ek_dentry =dget (item->ek_dentry); } -static DefineSimpleCacheLookup(svc_expkey, svc_expkey) +static struct cache_head *expkey_alloc (void ) +{ +struct svc_expkey *i =kmalloc (sizeof (*i),GFP_KERNEL ); +if (i) +return &i->h; +else +return NULL ; +} + +struct cache_detail svc_expkey_cache = { + .owner =THIS_MODULE , + .hash_size =EXPKEY_HASHMAX , + .hash_table = expkey_table, + .name ="nfsd.fh" , + .cache_put = expkey_put, + .cache_request = expkey_request, + .cache_parse = expkey_parse, + .cache_show = expkey_show, + .match = expkey_match, + .init = expkey_init, + .update = expkey_update, + .alloc = expkey_alloc, +}; + +static struct svc_expkey * +svc_expkey_lookup (struct svc_expkey *item) +{ +struct cache_head *ch; +int hash = item->ek_fsidtype; +char * cp = (char *)item->ek_fsid; +int len =key_len (item->ek_fsidtype); + + hash ^=hash_mem (cp, len,EXPKEY_HASHBITS ); + hash ^=hash_ptr (item->ek_client,EXPKEY_HASHBITS ); + hash &=EXPKEY_HASHMASK ; + + ch =sunrpc_cache_lookup (&svc_expkey_cache, &item->h, + hash); +if (ch) + return container_of(ch, struct svc_expkey, h); +else +return NULL ; +} + +static struct svc_expkey * +svc_expkey_update (struct svc_expkey *new,struct svc_expkey *old) +{ +struct cache_head *ch; +int hash = new->ek_fsidtype; +char * cp = (char *)new->ek_fsid; +int len =key_len (new->ek_fsidtype); + + hash ^=hash_mem (cp, len,EXPKEY_HASHBITS ); + hash ^=hash_ptr (new->ek_client,EXPKEY_HASHBITS ); + hash &=EXPKEY_HASHMASK ; + + ch =sunrpc_cache_update (&svc_expkey_cache, &new->h, + &old->h, hash); +if (ch) + return container_of(ch, struct svc_expkey, h); +else +return NULL ; +} +#define EXPORT_HASHBITS 8#define EXPORT_HASHMAX (1<< EXPORT_HASHBITS)
@@ -549,7 +609,7 @@ exp_find_key(svc_client *clp, int fsid_t key.ek_fsidtype = fsid_type;memcpy (key.ek_fsid, fsidv,key_len (fsid_type)); - ek =svc_expkey_lookup (&key,0 ); + ek =svc_expkey_lookup (&key);if (ek !=NULL )if ((err =cache_check (&svc_expkey_cache, &ek->h, reqp))) ek =ERR_PTR (err);
@@ -569,7 +629,9 @@ static int exp_set_key(svc_client *clp, key.h.expiry_time =NEVER ; key.h.flags =0 ; - ek =svc_expkey_lookup (&key,1 ); + ek =svc_expkey_lookup (&key); +if (ek) + ek =svc_expkey_update (&key,ek);if (ek) {expkey_put (&ek->h, &svc_expkey_cache);return 0 ;
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Use new sunrpc cache for rsi cache
In reply to NeilBrown### Diffstat output
./net/sunrpc/auth_gss/svcauth_gss.c | 66 ++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-)
net/sunrpc/auth_gss/svcauth_gss.c renamed from net/sunrpc/auth_gss/svcauth_gss.c~current~ +59 -7
@@ -78,7 +78,8 @@ struct rsi {static struct cache_head *rsi_table[RSI_HASHMAX ];static struct cache_detail rsi_cache; -static struct rsi *rsi_lookup (struct rsi *item,int set); +static struct rsi *rsi_update (struct rsi *new,struct rsi *old); +static struct rsi *rsi_lookup (struct rsi *item);static void rsi_free (struct rsi *rsii) {
@@ -103,8 +104,10 @@ static inline int rsi_hash(struct rsi *i ^ hash_mem(item->in_token.data, item->in_token.len, RSI_HASHBITS); } -static inline int rsi_match (struct rsi *item,struct rsi *tmp) +static int rsi_match (struct cache_head *a,struct cache_head *b) { + struct rsi *item = container_of(a, struct rsi, h); + struct rsi *tmp = container_of(b, struct rsi, h);return netobj_equal (&item->in_handle, &tmp->in_handle) &&netobj_equal (&item->in_token, &tmp->in_token); }
@@ -125,8 +128,11 @@ static inline int dup_netobj(struct xdr_return dup_to_netobj (dst, src->data, src->len); } -static inline void rsi_init (struct rsi *new,struct rsi *item) +static void rsi_init (struct cache_head *cnew,struct cache_head *citem) { + struct rsi *new = container_of(cnew, struct rsi, h); + struct rsi *item = container_of(citem, struct rsi, h); + new->out_handle.data =NULL ; new->out_handle.len =0 ; new->out_token.data =NULL ;
@@ -141,8 +147,11 @@ static inline void rsi_init(struct rsi * item->in_token.data =NULL ; } -static inline void rsi_update (struct rsi *new,struct rsi *item) +static void update_rsi (struct cache_head *cnew,struct cache_head *citem) { + struct rsi *new = container_of(cnew, struct rsi, h); + struct rsi *item = container_of(citem, struct rsi, h); +BUG_ON (new->out_handle.data || new->out_token.data); new->out_handle.len = item->out_handle.len; item->out_handle.len =0 ;
@@ -157,6 +166,15 @@ static inline void rsi_update(struct rsi new->minor_status = item->minor_status; } +static struct cache_head *rsi_alloc (void ) +{ +struct rsi *rsii =kmalloc (sizeof (*rsii),GFP_KERNEL ); +if (rsii) +return &rsii->h; +else +return NULL ; +} +static void rsi_request (struct cache_detail *cd,struct cache_head *h,char **bpp,int *blen)
@@ -198,6 +216,10 @@ static int rsi_parse(struct cache_detailif (dup_to_netobj (&rsii.in_token, buf, len)) goto out; + rsip =rsi_lookup (&rsii); +if (!rsip) + goto out; + rsii.h.flags =0 ;/* expiry */ expiry =get_expiry (&mesg);
@@ -240,12 +262,14 @@ static int rsi_parse(struct cache_detail goto out; } rsii.h.expiry_time = expiry; - rsip =rsi_lookup (&rsii,1 ); + rsip =rsi_update (&rsii, rsip); status =0 ; out:rsi_free (&rsii);if (rsip)rsi_put (&rsip->h, &rsi_cache); +else + status = -ENOMEM ;return status; }
@@ -257,9 +281,37 @@ static struct cache_detail rsi_cache = { .cache_put = rsi_put, .cache_request = rsi_request, .cache_parse = rsi_parse, + .match = rsi_match, + .init = rsi_init, + .update = update_rsi, + .alloc = rsi_alloc, }; -static DefineSimpleCacheLookup(rsi, rsi) +static struct rsi *rsi_lookup (struct rsi *item) +{ +struct cache_head *ch; +int hash =rsi_hash (item); + + ch =sunrpc_cache_lookup (&rsi_cache, &item->h, hash); +if (ch) + return container_of(ch, struct rsi, h); +else +return NULL ; +} + +static struct rsi *rsi_update (struct rsi *new,struct rsi *old) +{ +struct cache_head *ch; +int hash =rsi_hash (new); + + ch =sunrpc_cache_update (&rsi_cache, &new->h, + &old->h, hash); +if (ch) + return container_of(ch, struct rsi, h); +else +return NULL ; +} +/* * The rpcsec_context cache is used to store a context that is
@@ -895,7 +947,7 @@ svcauth_gss_accept(struct svc_rqst *rqst goto drop; } - rsip =rsi_lookup (&rsikey,0 ); + rsip =rsi_lookup (&rsikey);rsi_free (&rsikey);if (!rsip) { goto drop;
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Use new cache code for rsc cache
In reply to NeilBrown### Diffstat output
./net/sunrpc/auth_gss/svcauth_gss.c | 74 +++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 10 deletions(-)
net/sunrpc/auth_gss/svcauth_gss.c renamed from net/sunrpc/auth_gss/svcauth_gss.c~current~ +64 -10
@@ -345,7 +345,8 @@ struct rsc {static struct cache_head *rsc_table[RSC_HASHMAX ];static struct cache_detail rsc_cache; -static struct rsc *rsc_lookup (struct rsc *item,int set); +static struct rsc *rsc_update (struct rsc *new,struct rsc *old); +static struct rsc *rsc_lookup (struct rsc *item);static void rsc_free (struct rsc *rsci) {
@@ -372,15 +373,21 @@ rsc_hash(struct rsc *rsci)return hash_mem (rsci->handle.data, rsci->handle.len,RSC_HASHBITS ); } -static inline int -rsc_match (struct rsc *new,struct rsc *tmp) +static int +rsc_match (struct cache_head *a,struct cache_head *b) { + struct rsc *new = container_of(a, struct rsc, h); + struct rsc *tmp = container_of(b, struct rsc, h); +return netobj_equal (&new->handle, &tmp->handle); } -static inline void -rsc_init (struct rsc *new,struct rsc *tmp) +static void +rsc_init (struct cache_head *cnew,struct cache_head *ctmp) { + struct rsc *new = container_of(cnew, struct rsc, h); + struct rsc *tmp = container_of(ctmp, struct rsc, h); + new->handle.len = tmp->handle.len; tmp->handle.len =0 ; new->handle.data = tmp->handle.data;
@@ -389,9 +396,12 @@ rsc_init(struct rsc *new, struct rsc *tm new->cred.cr_group_info =NULL ; } -static inline void -rsc_update (struct rsc *new,struct rsc *tmp) +static void +update_rsc (struct cache_head *cnew,struct cache_head *ctmp) { + struct rsc *new = container_of(cnew, struct rsc, h); + struct rsc *tmp = container_of(ctmp, struct rsc, h); + new->mechctx = tmp->mechctx; tmp->mechctx =NULL ;memset (&new->seqdata,0 ,sizeof (new->seqdata));
@@ -400,6 +410,16 @@ rsc_update(struct rsc *new, struct rsc * tmp->cred.cr_group_info =NULL ; } +static struct cache_head * +rsc_alloc (void ) +{ +struct rsc *rsci =kmalloc (sizeof (*rsci),GFP_KERNEL ); +if (rsci) +return &rsci->h; +else +return NULL ; +} +static int rsc_parse (struct cache_detail *cd,char *mesg,int mlen) {
@@ -425,6 +445,10 @@ static int rsc_parse(struct cache_detailif (expiry ==0 ) goto out; + rscp =rsc_lookup (&rsci); +if (!rscp) + goto out; +/* uid, or NEGATIVE */ rv =get_int (&mesg, &rsci.cred.cr_uid);if (rv == -EINVAL )
@@ -480,12 +504,14 @@ static int rsc_parse(struct cache_detailgss_mech_put (gm); } rsci.h.expiry_time = expiry; - rscp =rsc_lookup (&rsci,1 ); + rscp =rsc_update (&rsci, rscp); status =0 ; out:rsc_free (&rsci);if (rscp)rsc_put (&rscp->h, &rsc_cache); +else + status = -ENOMEM ;return status; }
@@ -496,9 +522,37 @@ static struct cache_detail rsc_cache = { .name = "auth.rpcsec.context", .cache_put = rsc_put, .cache_parse = rsc_parse, + .match = rsc_match, + .init = rsc_init, + .update = update_rsc, + .alloc = rsc_alloc, }; -static DefineSimpleCacheLookup(rsc, rsc); +static struct rsc *rsc_lookup (struct rsc *item) +{ +struct cache_head *ch; +int hash =rsc_hash (item); + + ch =sunrpc_cache_lookup (&rsc_cache, &item->h, hash); +if (ch) + return container_of(ch, struct rsc, h); +else +return NULL ; +} + +static struct rsc *rsc_update (struct rsc *new,struct rsc *old) +{ +struct cache_head *ch; +int hash =rsc_hash (new); + + ch =sunrpc_cache_update (&rsc_cache, &new->h, + &old->h, hash); +if (ch) + return container_of(ch, struct rsc, h); +else +return NULL ; +} +static struct rsc *gss_svc_searchbyctx (struct xdr_netobj *handle)
@@ -509,7 +563,7 @@ gss_svc_searchbyctx(struct xdr_netobj *hmemset (&rsci,0 ,sizeof (rsci));if (dup_to_netobj (&rsci.handle, handle->data, handle->len))return NULL ; - found =rsc_lookup (&rsci,0 ); + found =rsc_lookup (&rsci);rsc_free (&rsci);if (!found)return NULL ;
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Use new cache code for name/id lookup caches
In reply to NeilBrown### Diffstat output
./fs/nfsd/nfs4idmap.c | 126 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 103 insertions(+), 23 deletions(-)
fs/nfsd/nfs4idmap.c renamed from fs/nfsd/nfs4idmap.c~current~ +103 -23
@@ -82,9 +82,12 @@ struct ent {#define ENT_HASHMAX (1 << ENT_HASHBITS)#define ENT_HASHMASK (ENT_HASHMAX - 1) -static inline void -ent_init (struct ent *new,struct ent *itm) +static void +ent_init (struct cache_head *cnew,struct cache_head *citm) { + struct ent *new = container_of(cnew, struct ent, h); + struct ent *itm = container_of(citm, struct ent, h); + new->id = itm->id; new->type = itm->type;
@@ -92,12 +95,6 @@ ent_init(struct ent *new, struct ent *itstrlcpy (new->authname, itm->authname,sizeof (new->name)); } -static inline void -ent_update (struct ent *new,struct ent *itm) -{ -ent_init (new, itm); -} -static void ent_put (struct cache_head *ch,struct cache_detail *cd) {
@@ -107,6 +104,16 @@ ent_put(struct cache_head *ch, struct ca } } +static struct cache_head * +ent_alloc (void ) +{ +struct ent *e =kmalloc (sizeof (*e),GFP_KERNEL ); +if (e) +return &e->h; +else +return NULL ; +} +/* * ID -> Name cache */
@@ -143,9 +150,12 @@ idtoname_request(struct cache_detail *cd (*bpp)[-1 ] ='\n' ; } -static inline int -idtoname_match (struct ent *a,struct ent *b) +static int +idtoname_match (struct cache_head *ca,struct cache_head *cb) { + struct ent *a = container_of(ca, struct ent, h); + struct ent *b = container_of(cb, struct ent, h); +return (a->id == b->id && a->type == b->type &&strcmp (a->authname, b->authname) ==0 ); }
@@ -178,7 +188,8 @@ warn_no_idmapd(struct cache_detail *detastatic int idtoname_parse (struct cache_detail *,char *,int ); -static struct ent *idtoname_lookup (struct ent *,int ); +static struct ent *idtoname_lookup (struct ent *); +static struct ent *idtoname_update (struct ent *,struct ent *);static struct cache_detail idtoname_cache = { .owner =THIS_MODULE ,
@@ -190,6 +201,10 @@ static struct cache_detail idtoname_cach .cache_parse = idtoname_parse, .cache_show = idtoname_show, .warn_no_listener = warn_no_idmapd, + .match = idtoname_match, + .init = ent_init, + .update = ent_init, + .alloc = ent_alloc, };int
@@ -232,6 +247,11 @@ idtoname_parse(struct cache_detail *cd,if (ent.h.expiry_time ==0 ) goto out; + error = -ENOMEM ; + res =idtoname_lookup (&ent); +if (!res) + goto out; +/* Name */ error =qword_get (&buf, buf1,PAGE_SIZE );if (error == -EINVAL )
@@ -246,7 +266,8 @@ idtoname_parse(struct cache_detail *cd,memcpy (ent.name, buf1,sizeof (ent.name)); } error = -ENOMEM ; -if ((res =idtoname_lookup (&ent,1 )) ==NULL ) + res =idtoname_update (&ent, res); +if (res ==NULL ) goto out;ent_put (&res->h, &idtoname_cache);
@@ -258,7 +279,31 @@ out:return error; } -static DefineSimpleCacheLookup(ent, idtoname); + +static struct ent * +idtoname_lookup (struct ent *item) +{ +struct cache_head *ch =sunrpc_cache_lookup (&idtoname_cache, + &item->h, +idtoname_hash (item)); +if (ch) + return container_of(ch, struct ent, h); +else +return NULL ; +} + +static struct ent * +idtoname_update (struct ent *new,struct ent *old) +{ +struct cache_head *ch =sunrpc_cache_update (&idtoname_cache, + &new->h, &old->h, +idtoname_hash (new)); +if (ch) + return container_of(ch, struct ent, h); +else +return NULL ; +} +/* * Name -> ID cache
@@ -285,9 +330,12 @@ nametoid_request(struct cache_detail *cd (*bpp)[-1 ] ='\n' ; } -static inline int -nametoid_match (struct ent *a,struct ent *b) +static int +nametoid_match (struct cache_head *ca,struct cache_head *cb) { + struct ent *a = container_of(ca, struct ent, h); + struct ent *b = container_of(cb, struct ent, h); +return (a->type == b->type &&strcmp (a->name, b->name) ==0 &&strcmp (a->authname, b->authname) ==0 ); }
@@ -311,7 +359,8 @@ nametoid_show(struct seq_file *m, structreturn 0 ; } -static struct ent *nametoid_lookup (struct ent *,int ); +static struct ent *nametoid_lookup (struct ent *); +static struct ent *nametoid_update (struct ent *,struct ent *);static int nametoid_parse (struct cache_detail *,char *,int );static struct cache_detail nametoid_cache = {
@@ -324,6 +373,10 @@ static struct cache_detail nametoid_cach .cache_parse = nametoid_parse, .cache_show = nametoid_show, .warn_no_listener = warn_no_idmapd, + .match = nametoid_match, + .init = ent_init, + .update = ent_init, + .alloc = ent_alloc, }; static int
@@ -373,7 +426,11 @@ nametoid_parse(struct cache_detail *cd,set_bit (CACHE_NEGATIVE , &ent.h.flags); error = -ENOMEM ; -if ((res =nametoid_lookup (&ent,1 )) ==NULL ) + res =nametoid_lookup (&ent); +if (res ==NULL ) + goto out; + res =nametoid_update (&ent, res); +if (res ==NULL ) goto out;ent_put (&res->h, &nametoid_cache);
@@ -384,7 +441,30 @@ out:return (error); } -static DefineSimpleCacheLookup(ent, nametoid); + +static struct ent * +nametoid_lookup (struct ent *item) +{ +struct cache_head *ch =sunrpc_cache_lookup (&nametoid_cache, + &item->h, +nametoid_hash (item)); +if (ch) + return container_of(ch, struct ent, h); +else +return NULL ; +} + +static struct ent * +nametoid_update (struct ent *new,struct ent *old) +{ +struct cache_head *ch =sunrpc_cache_update (&nametoid_cache, + &new->h, &old->h, +nametoid_hash (new)); +if (ch) + return container_of(ch, struct ent, h); +else +return NULL ; +}/* * Exported API
@@ -452,24 +532,24 @@ idmap_defer(struct cache_req *req) }static inline int -do_idmap_lookup (struct ent *(*lookup_fn)(struct ent *,int ),struct ent *key, +do_idmap_lookup (struct ent *(*lookup_fn)(struct ent *),struct ent *key,struct cache_detail *detail,struct ent **item,struct idmap_defer_req *mdr) { - *item =lookup_fn (key,0 ); + *item =lookup_fn (key);if (!*item)return -ENOMEM ;return cache_check (detail, &(*item)->h, &mdr->req); }static inline int -do_idmap_lookup_nowait (struct ent *(*lookup_fn)(struct ent *,int ), +do_idmap_lookup_nowait (struct ent *(*lookup_fn)(struct ent *),struct ent *key,struct cache_detail *detail,struct ent **item) {int ret = -ENOMEM ; - *item =lookup_fn (key,0 ); + *item =lookup_fn (key);if (!*item) goto out_err; ret = -ETIMEDOUT ;
@@ -490,7 +570,7 @@ out_err:static int idmap_lookup (struct svc_rqst *rqstp, -struct ent *(*lookup_fn)(struct ent *,int ),struct ent *key, +struct ent *(*lookup_fn)(struct ent *),struct ent *key,struct cache_detail *detail,struct ent **item) {struct idmap_defer_req *mdr;
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: An assortment of little fixes to the sunrpc cache code.
In reply to NeilBrown- in cache_check, h must be non-NULL as it has been de-referenced, so don't bother checking for NULL.
- When a cache-item is updated, we need to call cache_revisit_request to see if there is a pending request waiting for that item. We were using a transition to CACHE_VALID to see if that was needed, however that is wrong as an expired entry will still be marked 'valid' (as the data is valid and will need to be released). So instead use an off transition for CACHE_PENDING which is exactly the right thing to test.
- Add a little bit more debugging info.
### Diffstat output
./net/sunrpc/cache.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~current~ +8 -6
@@ -208,7 +208,7 @@ int cache_check(struct cache_detail *detif (rv == -EAGAIN )cache_defer_req (rqstp, h); -if (rv && h) +if (rv) detail->cache_put (h, detail);return rv; }
@@ -223,8 +223,10 @@ void cache_fresh(struct cache_detail *de head->last_refresh =get_seconds ();if (!test_and_set_bit (CACHE_VALID , &head->flags))cache_revisit_request (head); -if (test_and_clear_bit (CACHE_PENDING , &head->flags)) +if (test_and_clear_bit (CACHE_PENDING , &head->flags)) { +cache_revisit_request (head);queue_loose (detail, head); + } }/*
@@ -551,7 +553,7 @@ static void cache_defer_req(struct cache/* there was one too many */ dreq->revisit (dreq,1 ); } -if (test_bit (CACHE_VALID , &item->flags)) { +if (!test_bit (CACHE_PENDING , &item->flags)) {/* must have just been validated... */ cache_revisit_request (item); }
@@ -892,7 +894,7 @@ static void queue_loose(struct cache_detif (cr->item != ch)continue ;if (cr->readers !=0 ) -break ; +continue ;list_del (&cr->q.list);spin_unlock (&queue_lock); detail->cache_put (cr->item, detail);
@@ -1180,8 +1182,8 @@ static int c_show(struct seq_file *m, voreturn cd->cache_show (m, cd,NULL ); ifdebug(CACHE) - seq_printf(m, "# expiry=%ld refcnt=%d\n", - cp->expiry_time, atomic_read(&cp->refcnt)); + seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n", + cp->expiry_time, atomic_read(&cp->refcnt), cp->flags);cache_get (cp);if (cache_check (cd, cp,NULL ))/* cache_check does a cache_put on failure */
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Remove DefineCacheLookup
In reply to NeilBrownThis has been replaced by more traditional code.
### Diffstat output
./include/linux/sunrpc/cache.h | 113 ----------------------------------------- 1 file changed, 113 deletions(-)
include/linux/sunrpc/cache.h renamed from include/linux/sunrpc/cache.h~current~ +0 -113
@@ -128,119 +128,6 @@ struct cache_deferred_req { int too_many); }; -/* -* just like a template in C++, this macro does cache lookup -* for us. -* The function is passed some sort of HANDLE from which a cache_detail -* structure can be determined (via SETUP, DETAIL), a template -* cache entry (type RTN*), and a "set" flag. Using the HASHFN and the -* TEST, the function will try to find a matching cache entry in the cache. -* If "set" == 0 : -* If an entry is found, it is returned -* If no entry is found, a new non-VALID entry is created. -* If "set" == 1 : -* If no entry is found a new one is inserted with data from "template" -* If a non-CACHE_VALID entry is found, it is updated from template using UPDATE -* If a CACHE_VALID entry is found, a new entry is swapped in with data -* from "template" -* -* If the passed handle has the CACHE_NEGATIVE flag set, then UPDATE is not -* run but insteead CACHE_NEGATIVE is set in any new item. - -* In any case, the new entry is returned with a reference count. -* -* -* RTN is a struct type for a cache entry -* MEMBER is the member of the cache which is cache_head, which must be first -* FNAME is the name for the function -* ARGS are arguments to function and must contain RTN *item, int set. May -* also contain something to be usedby SETUP or DETAIL to find cache_detail. -* SETUP locates the cache detail and makes it available as... -* DETAIL identifies the cache detail, possibly set up by SETUP -* HASHFN returns a hash value of the cache entry "item" -* TEST tests if "tmp" matches "item" -* INIT copies key information from "item" to "new" -* UPDATE copies content information from "item" to "tmp" -*/ -#define DefineCacheLookup (RTN ,MEMBER ,FNAME ,ARGS ,SETUP ,DETAIL ,HASHFN ,TEST ,INIT ,UPDATE ) \ -RTN *FNAME ARGS \ -{ \ - RTN *tmp, *new=NULL; \ - struct cache_head **hp, **head; \ - SETUP; \ - head = &(DETAIL)->hash_table[HASHFN]; \ - retry: \ - if (set||new) write_lock(&(DETAIL)->hash_lock); \ - else read_lock(&(DETAIL)->hash_lock); \ - for(hp=head; *hp != NULL; hp = &tmp->MEMBER.next) { \ - tmp = container_of(*hp, RTN, MEMBER); \ - if (TEST) {/* found a match */ \ - \ -if (set &&test_bit (CACHE_VALID , &tmp->MEMBER.flags) && !new) \ -break ; \ - \ -if (new) \ - {INIT ;} \ -if (set) { \ -if (test_bit (CACHE_VALID , &tmp->MEMBER.flags))\ - {/* need to swap in new */ \ -RTN *t2; \ - \ - new->MEMBER.next = tmp->MEMBER.next; \ - *hp = &new->MEMBER; \ - tmp->MEMBER.next =NULL ; \ - t2 = tmp; tmp = new; new = t2; \ - } \ -if (test_bit (CACHE_NEGATIVE , &item->MEMBER.flags)) \ -set_bit (CACHE_NEGATIVE , &tmp->MEMBER.flags); \ -else { \ -UPDATE ; \ -clear_bit (CACHE_NEGATIVE , &tmp->MEMBER.flags); \ - } \ - } \ -cache_get (&tmp->MEMBER); \ -if (set||new)write_unlock (&(DETAIL )->hash_lock); \ -else read_unlock (&(DETAIL )->hash_lock); \ -if (set) \ -cache_fresh (DETAIL , &tmp->MEMBER, item->MEMBER.expiry_time); \ -if (set && new)cache_fresh (DETAIL , &new->MEMBER,0 ); \ -if (new) (DETAIL )->cache_put (&new->MEMBER,DETAIL ); \ -return tmp; \ - } \ - } \ -/* Didn't find anything */ \ -if (new) { \ -INIT ; \ - new->MEMBER.next = *head; \ - *head = &new->MEMBER; \ - (DETAIL )->entries ++; \ -cache_get (&new->MEMBER); \ -if (set) { \ - tmp = new; \ -if (test_bit (CACHE_NEGATIVE , &item->MEMBER.flags)) \ -set_bit (CACHE_NEGATIVE , &tmp->MEMBER.flags); \ -else {UPDATE ;} \ - } \ - } \ -if (set||new)write_unlock (&(DETAIL )->hash_lock); \ -else read_unlock (&(DETAIL )->hash_lock); \ -if (new && set) \ -cache_fresh (DETAIL , &new->MEMBER, item->MEMBER.expiry_time); \ -if (new) \ -return new; \ - new =kmalloc (sizeof (*new),GFP_KERNEL ); \ -if (new) { \ -cache_init (&new->MEMBER); \ - goto retry; \ - } \ -return NULL ; \ -} - -#define DefineSimpleCacheLookup(STRUCT, FUNC) \ - DefineCacheLookup(struct STRUCT, h, FUNC##_lookup, \ - (struct STRUCT *item, int set), /*no setup */, \ - & FUNC##_cache, FUNC##_hash(item), FUNC##_match(item, tmp), \ - STRUCT##_init(new, item), STRUCT##_update(tmp, item))extern struct cache_head * sunrpc_cache_lookup(struct cache_detail *detail,
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Unexport cache_fresh and fix a small race.
In reply to NeilBrownCache_fresh is now only used in cache.c, so unexport it.
Part of cache_fresh (setting CACHE_VALID) should really be done under the lock, while part (calling cache_revisit_request etc) must be done outside the lock. So we split it up appropriately.
### Diffstat output
./include/linux/sunrpc/cache.h | 2 - ./net/sunrpc/cache.c | 51 ++++++++++++++++++++++++----------------- ./net/sunrpc/sunrpc_syms.c | 1 3 files changed, 30 insertions(+), 24 deletions(-)
include/linux/sunrpc/cache.h renamed from include/linux/sunrpc/cache.h~current~ +0 -2
@@ -165,8 +165,6 @@ static inline int cache_put(struct cache }extern void cache_init (struct cache_head *h); -extern void cache_fresh (struct cache_detail *detail, -struct cache_head *head,time_t expiry);extern int cache_check (struct cache_detail *detail,struct cache_head *h,struct cache_req *rqstp);extern void cache_flush (void );
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~current~ +30 -21
89 lines not on this page · raw message
net/sunrpc/sunrpc_syms.c renamed from net/sunrpc/sunrpc_syms.c~current~ +0 -1
@@ -105,7 +105,6 @@ EXPORT_SYMBOL(auth_unix_lookup);EXPORT_SYMBOL (cache_check);EXPORT_SYMBOL (cache_flush);EXPORT_SYMBOL (cache_purge); -EXPORT_SYMBOL (cache_fresh);EXPORT_SYMBOL (cache_init);EXPORT_SYMBOL (cache_register);EXPORT_SYMBOL (cache_unregister);
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
PATCH 1/1 knfsd: Convert sunrpc_cache to use krefs
In reply to NeilBrown.. it makes some of the code nicer.
### Diffstat output
./fs/nfsd/export.c | 51 ++++++++++++++++-------------------- ./fs/nfsd/nfs4idmap.c | 18 +++++------- ./include/linux/nfsd/export.h | 4 -- ./include/linux/sunrpc/cache.h | 13 ++++----- ./net/sunrpc/auth_gss/svcauth_gss.c | 28 ++++++++----------- ./net/sunrpc/cache.c | 20 +++++++------- ./net/sunrpc/svcauth_unix.c | 20 +++++++------- 7 files changed, 71 insertions(+), 83 deletions(-)
fs/nfsd/export.c renamed from fs/nfsd/export.c~current~ +24 -27
@@ -57,18 +57,17 @@ static int exp_verify_string(char *cp,#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1)static struct cache_head *expkey_table[EXPKEY_HASHMAX ]; -void expkey_put (struct cache_head *item,struct cache_detail *cd) +void expkey_put (struct kref *ref) { -if (cache_put (item, cd)) { - struct svc_expkey *key = container_of(item, struct svc_expkey, h); -if (test_bit (CACHE_VALID , &item->flags) && - !test_bit (CACHE_NEGATIVE , &item->flags)) { -dput (key->ek_dentry); -mntput (key->ek_mnt); - } -auth_domain_put (key->ek_client); -kfree (key); + struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref); + +if (test_bit (CACHE_VALID , &key->h.flags) && + !test_bit (CACHE_NEGATIVE , &key->h.flags)) { +dput (key->ek_dentry); +mntput (key->ek_mnt); } +auth_domain_put (key->ek_client); +kfree (key); } static void expkey_request(struct cache_detail *cd,
@@ -158,7 +157,7 @@ static int expkey_parse(struct cache_detset_bit (CACHE_NEGATIVE , &key.h.flags); ek =svc_expkey_update (&key, ek);if (ek) -expkey_put (&ek->h, &svc_expkey_cache); +cache_put (&ek->h, &svc_expkey_cache);else err = -ENOMEM ; }else {struct nameidata nd;
@@ -172,7 +171,7 @@ static int expkey_parse(struct cache_det ek =svc_expkey_update (&key, ek);if (ek) -expkey_put (&ek->h, &svc_expkey_cache); +cache_put (&ek->h, &svc_expkey_cache);else err = -ENOMEM ;path_release (&nd);
@@ -318,15 +317,13 @@ svc_expkey_update(struct svc_expkey *newstatic struct cache_head *export_table[EXPORT_HASHMAX ]; -void svc_export_put (struct cache_head *item,struct cache_detail *cd) +void svc_export_put (struct kref *ref) { -if (cache_put (item, cd)) { - struct svc_export *exp = container_of(item, struct svc_export, h); -dput (exp->ex_dentry); -mntput (exp->ex_mnt); -auth_domain_put (exp->ex_client); -kfree (exp); - } + struct svc_export *exp = container_of(ref, struct svc_export, h.ref); +dput (exp->ex_dentry); +mntput (exp->ex_mnt); +auth_domain_put (exp->ex_client); +kfree (exp); } static void svc_export_request(struct cache_detail *cd,
@@ -633,7 +630,7 @@ static int exp_set_key(svc_client *clp,if (ek) ek =svc_expkey_update (&key,ek);if (ek) { -expkey_put (&ek->h, &svc_expkey_cache); +cache_put (&ek->h, &svc_expkey_cache);return 0 ; }return -ENOMEM ;
@@ -762,7 +759,7 @@ static void exp_fsid_unhash(struct svc_e ek =exp_get_fsid_key (exp->ex_client, exp->ex_fsid);if (ek && !IS_ERR (ek)) { ek->h.expiry_time =get_seconds ()-1 ; -expkey_put (&ek->h, &svc_expkey_cache); +cache_put (&ek->h, &svc_expkey_cache); } svc_expkey_cache.nextcheck =get_seconds (); }
@@ -800,7 +797,7 @@ static void exp_unhash(struct svc_export ek =exp_get_key (exp->ex_client, inode->i_sb->s_dev, inode->i_ino);if (ek && !IS_ERR (ek)) { ek->h.expiry_time =get_seconds ()-1 ; -expkey_put (&ek->h, &svc_expkey_cache); +cache_put (&ek->h, &svc_expkey_cache); } svc_expkey_cache.nextcheck =get_seconds (); }
@@ -902,7 +899,7 @@ finish:if (exp)exp_put (exp);if (fsid_key && !IS_ERR (fsid_key)) -expkey_put (&fsid_key->h, &svc_expkey_cache); +cache_put (&fsid_key->h, &svc_expkey_cache);if (clp)auth_domain_put (clp);path_release (&nd);
@@ -1030,7 +1027,7 @@ exp_find(struct auth_domain *clp, int fsreturn ERR_PTR (PTR_ERR (ek)); exp =exp_get_by_name (clp, ek->ek_mnt, ek->ek_dentry, reqp); -expkey_put (&ek->h, &svc_expkey_cache); +cache_put (&ek->h, &svc_expkey_cache);if (!exp ||IS_ERR (exp))return ERR_PTR (PTR_ERR (exp));
@@ -1068,7 +1065,7 @@ exp_pseudoroot(struct auth_domain *clp,else rv =fh_compose (fhp, exp, fsid_key->ek_dentry,NULL ); -expkey_put (&fsid_key->h, &svc_expkey_cache); +cache_put (&fsid_key->h, &svc_expkey_cache);return rv; }
@@ -1187,7 +1184,7 @@ static int e_show(struct seq_file *m, vocache_get (&exp->h);if (cache_check (&svc_export_cache, &exp->h,NULL ))return 0 ; -if (cache_put (&exp->h, &svc_export_cache))BUG (); +cache_put (&exp->h, &svc_export_cache);return svc_export_show (m, &svc_export_cache, cp); }
fs/nfsd/nfs4idmap.c renamed from fs/nfsd/nfs4idmap.c~current~ +8 -10
@@ -96,12 +96,10 @@ ent_init(struct cache_head *cnew, struct }static void -ent_put (struct cache_head *ch,struct cache_detail *cd) +ent_put (struct kref *ref) { -if (cache_put (ch, cd)) { - struct ent *map = container_of(ch, struct ent, h); -kfree (map); - } + struct ent *map = container_of(ref, struct ent, h.ref); +kfree (map); } static struct cache_head *
@@ -270,7 +268,7 @@ idtoname_parse(struct cache_detail *cd,if (res ==NULL ) goto out; -ent_put (&res->h, &idtoname_cache); +cache_put (&res->h, &idtoname_cache); error =0 ; out:
@@ -433,7 +431,7 @@ nametoid_parse(struct cache_detail *cd,if (res ==NULL ) goto out; -ent_put (&res->h, &nametoid_cache); +cache_put (&res->h, &nametoid_cache); error =0 ; out:kfree (buf1);
@@ -562,7 +560,7 @@ do_idmap_lookup_nowait(struct ent *(*loo goto out_put;return 0 ; out_put: -ent_put (&(*item)->h, detail); +cache_put (&(*item)->h, detail); out_err: *item =NULL ;return ret;
@@ -613,7 +611,7 @@ idmap_name_to_id(struct svc_rqst *rqstp,if (ret)return ret; *id = item->id; -ent_put (&item->h, &nametoid_cache); +cache_put (&item->h, &nametoid_cache);return 0 ; }
@@ -635,7 +633,7 @@ idmap_id_to_name(struct svc_rqst *rqstp, ret =strlen (item->name);BUG_ON (ret >IDMAP_NAMESZ );memcpy (name, item->name, ret); -ent_put (&item->h, &idtoname_cache); +cache_put (&item->h, &idtoname_cache);return ret; }
include/linux/nfsd/export.h renamed from include/linux/nfsd/export.h~current~ +1 -3
@@ -102,13 +102,11 @@ int exp_rootfh(struct auth_domain *,int exp_pseudoroot (struct auth_domain *,struct svc_fh *fhp,struct cache_req *creq);int nfserrno (int errno); -extern void expkey_put (struct cache_head *item,struct cache_detail *cd); -extern void svc_export_put (struct cache_head *item,struct cache_detail *cd);extern struct cache_detail svc_export_cache, svc_expkey_cache;static inline void exp_put (struct svc_export *exp) { -svc_export_put (&exp->h, &svc_export_cache); +cache_put (&exp->h, &svc_export_cache); }static inline void exp_get (struct svc_export *exp)
include/linux/sunrpc/cache.h renamed from include/linux/sunrpc/cache.h~current~ +6 -7
@@ -50,7 +50,7 @@ struct cache_head {time_t last_refresh;/* If CACHE_PENDING, this is when upcall * was sent, else this is when update was received */ -atomic_t refcnt; +struct kref ref;unsigned long flags; };#define CACHE_VALID 0/* Entry contains valid data */
@@ -68,8 +68,7 @@ struct cache_detail {atomic_t inuse;/* active user-space update or lookup */ char *name; -void (*cache_put)(struct cache_head *, -struct cache_detail *); +void (*cache_put)(struct kref *); void (*cache_request)(struct cache_detail *cd, struct cache_head *h,
@@ -151,17 +150,17 @@ extern void cache_clean_deferred(void *ostatic inline struct cache_head *cache_get (struct cache_head *h) { -atomic_inc (&h->refcnt); +kref_get (&h->ref);return h; } -static inline int cache_put (struct cache_head *h,struct cache_detail *cd) +static inline void cache_put (struct cache_head *h,struct cache_detail *cd) { -if (atomic_read (&h->refcnt) <=2 && +if (atomic_read (&h->ref.refcount) <=2 && h->expiry_time < cd->nextcheck) cd->nextcheck = h->expiry_time; -return atomic_dec_and_test (&h->refcnt); +kref_put (&h->ref, cd->cache_put); }extern void cache_init (struct cache_head *h);
net/sunrpc/auth_gss/svcauth_gss.c renamed from net/sunrpc/auth_gss/svcauth_gss.c~current~ +12 -16
@@ -89,13 +89,11 @@ static void rsi_free(struct rsi *rsii)kfree (rsii->out_token.data); } -static void rsi_put (struct cache_head *item,struct cache_detail *cd) +static void rsi_put (struct kref *ref) { - struct rsi *rsii = container_of(item, struct rsi, h); -if (cache_put (item, cd)) { -rsi_free (rsii); -kfree (rsii); - } + struct rsi *rsii = container_of(ref, struct rsi, h.ref); +rsi_free (rsii); +kfree (rsii); }static inline int rsi_hash (struct rsi *item)
@@ -267,7 +265,7 @@ static int rsi_parse(struct cache_detail out:rsi_free (&rsii);if (rsip) -rsi_put (&rsip->h, &rsi_cache); +cache_put (&rsip->h, &rsi_cache);else status = -ENOMEM ;return status;
@@ -357,14 +355,12 @@ static void rsc_free(struct rsc *rsci)put_group_info (rsci->cred.cr_group_info); } -static void rsc_put (struct cache_head *item,struct cache_detail *cd) +static void rsc_put (struct kref *ref) { - struct rsc *rsci = container_of(item, struct rsc, h); + struct rsc *rsci = container_of(ref, struct rsc, h.ref); -if (cache_put (item, cd)) { -rsc_free (rsci); -kfree (rsci); - } +rsc_free (rsci); +kfree (rsci); } static inline int
@@ -509,7 +505,7 @@ static int rsc_parse(struct cache_detail out:rsc_free (&rsci);if (rscp) -rsc_put (&rscp->h, &rsc_cache); +cache_put (&rscp->h, &rsc_cache);else status = -ENOMEM ;return status;
@@ -1076,7 +1072,7 @@ drop: ret =SVC_DROP ; out:if (rsci) -rsc_put (&rsci->h, &rsc_cache); +cache_put (&rsci->h, &rsc_cache);return ret; }
@@ -1168,7 +1164,7 @@ out_err:put_group_info (rqstp->rq_cred.cr_group_info); rqstp->rq_cred.cr_group_info =NULL ;if (gsd->rsci) -rsc_put (&gsd->rsci->h, &rsc_cache); +cache_put (&gsd->rsci->h, &rsc_cache); gsd->rsci =NULL ;return stat;
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~current~ +10 -10
@@ -42,7 +42,7 @@ void cache_init(struct cache_head *h)time_t now =get_seconds (); h->next =NULL ; h->flags =0 ; -atomic_set (&h->refcnt,1 ); +kref_init (&h->ref); h->expiry_time = now +CACHE_NEW_EXPIRY ; h->last_refresh = now; }
@@ -81,7 +81,7 @@ struct cache_head *sunrpc_cache_lookup(sif (detail->match (tmp, key)) {cache_get (tmp);write_unlock (&detail->hash_lock); - detail->cache_put (new, detail); +cache_put (new, detail);return tmp; } }
@@ -145,7 +145,7 @@ struct cache_head *sunrpc_cache_update(s/* We need to insert a new entry */ tmp = detail->alloc ();if (!tmp) { - detail->cache_put (old, detail); +cache_put (old, detail);return NULL ; }cache_init (tmp);
@@ -165,7 +165,7 @@ struct cache_head *sunrpc_cache_update(swrite_unlock (&detail->hash_lock);cache_fresh_unlocked (tmp, detail, is_new);cache_fresh_unlocked (old, detail,0 ); - detail->cache_put (old, detail); +cache_put (old, detail);return tmp; }EXPORT_SYMBOL (sunrpc_cache_update);
@@ -234,7 +234,7 @@ int cache_check(struct cache_detail *detcache_defer_req (rqstp, h);if (rv) - detail->cache_put (h, detail); +cache_put (h, detail);return rv; }
@@ -431,7 +431,7 @@ static int cache_clean(void)if (test_and_clear_bit (CACHE_PENDING , &ch->flags))queue_loose (current_detail, ch); -if (atomic_read (&ch->refcnt) ==1 ) +if (atomic_read (&ch->ref.refcount) ==1 )break ; }if (ch) {
@@ -446,7 +446,7 @@ static int cache_clean(void) current_index ++;spin_unlock (&cache_list_lock);if (ch) - d->cache_put (ch, d); +cache_put (ch, d); }else spin_unlock (&cache_list_lock);
@@ -723,7 +723,7 @@ cache_read(struct file *filp, char __use !test_bit(CACHE_PENDING, &rq->item->flags)) {list_del (&rq->q.list);spin_unlock (&queue_lock); - cd->cache_put (rq->item, cd); +cache_put (rq->item, cd);kfree (rq->buf);kfree (rq); } else
@@ -906,7 +906,7 @@ static void queue_loose(struct cache_detcontinue ;list_del (&cr->q.list);spin_unlock (&queue_lock); - detail->cache_put (cr->item, detail); +cache_put (cr->item, detail);kfree (cr->buf);kfree (cr);return ;
@@ -1192,7 +1192,7 @@ static int c_show(struct seq_file *m, vo ifdebug(CACHE) seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n", - cp->expiry_time, atomic_read(&cp->refcnt), cp->flags); + cp->expiry_time, atomic_read(&cp->ref.refcount), cp->flags);cache_get (cp);if (cache_check (cd, cp,NULL ))/* cache_check does a cache_put on failure */
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +10 -10
@@ -84,15 +84,15 @@ struct ip_map { };static struct cache_head *ip_table[IP_HASHMAX ]; -static void ip_map_put (struct cache_head *item,struct cache_detail *cd) +static void ip_map_put (struct kref *kref) { + struct cache_head *item = container_of(kref, struct cache_head, ref); struct ip_map *im = container_of(item, struct ip_map,h); -if (cache_put (item, cd)) { -if (test_bit (CACHE_VALID , &item->flags) && - !test_bit (CACHE_NEGATIVE , &item->flags)) -auth_domain_put (&im->m_client->h); -kfree (im); - } + +if (test_bit (CACHE_VALID , &item->flags) && + !test_bit (CACHE_NEGATIVE , &item->flags)) +auth_domain_put (&im->m_client->h); +kfree (im); }#if IP_HASHBITS ==8
@@ -315,7 +315,7 @@ static int ip_map_update(struct ip_map * hash_ip((unsigned long)ipm->m_addr.s_addr));if (!ch)return -ENOMEM ; -ip_map_put (ch, &ip_map_cache); +cache_put (ch, &ip_map_cache);return 0 ; }
@@ -369,7 +369,7 @@ struct auth_domain *auth_unix_lookup(str rv = &ipm->m_client->h;kref_get (&rv->ref); } -ip_map_put (&ipm->h, &ip_map_cache); +cache_put (&ipm->h, &ip_map_cache);return rv; }
@@ -403,7 +403,7 @@ svcauth_unix_set_client(struct svc_rqstcase 0 : rqstp->rq_client = &ipm->m_client->h;kref_get (&rqstp->rq_client->ref); -ip_map_put (&ipm->h, &ip_map_cache); +cache_put (&ipm->h, &ip_map_cache);break ; }return SVC_OK ;
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 7 lines · NeilBrown
[PATCH 000 of 14] knfsd: Introduction
[PATCH 001 of 14] knfsd: Change the store ofauth_domainsto not be a 'cache'. [PATCH 002 of 14] knfsd: Break the hard linkage fromsvc_expkeytosvc_export[PATCH 003 of 14] knfsd: Get rid of 'inplace' sunrpc caches
[PATCH 004 of 14] knfsd: Createcache_lookupfunction instead of using a macro to declare one. [PATCH 005 of 14] knfsd: Convertip_mapcache to use the new lookup routine. [PATCH 006 of 14] knfsd: Use newcache_lookupforsvc_export
Quoted 8 lines
[PATCH 007 of 14] knfsd: Use new
cache_lookupforsvc_expkeycache. [PATCH 008 of 14] knfsd: Use new sunrpc cache for rsi cache
[PATCH 009 of 14] knfsd: Use new cache code for rsc cache
[PATCH 010 of 14] knfsd: Use new cache code for name/id lookup caches [PATCH 011 of 14] knfsd: An assortment of little fixes to the sunrpc cache code. [PATCH 012 of 14] knfsd: Remove DefineCacheLookup
[PATCH 013 of 14] knfsd: Unexportcache_freshand fix a small race. [PATCH 014 of 14] knfsd: Convertsunrpc_cacheto use krefs
Any plans to update Documentation/rpc-cache.txt?
Cheers,
Trond
Quoted 17 lines · On Thursday March 9, [email protected] wrote:
Quoted 7 lines · NeilBrown
[PATCH 000 of 14] knfsd: Introduction
[PATCH 001 of 14] knfsd: Change the store ofauth_domainsto not be a 'cache'. [PATCH 002 of 14] knfsd: Break the hard linkage fromsvc_expkeytosvc_export[PATCH 003 of 14] knfsd: Get rid of 'inplace' sunrpc caches
[PATCH 004 of 14] knfsd: Createcache_lookupfunction instead of using a macro to declare one. [PATCH 005 of 14] knfsd: Convertip_mapcache to use the new lookup routine. [PATCH 006 of 14] knfsd: Use newcache_lookupforsvc_exportQuoted 8 lines
[PATCH 007 of 14] knfsd: Use new
cache_lookupforsvc_expkeycache. [PATCH 008 of 14] knfsd: Use new sunrpc cache for rsi cache
[PATCH 009 of 14] knfsd: Use new cache code for rsc cache
[PATCH 010 of 14] knfsd: Use new cache code for name/id lookup caches [PATCH 011 of 14] knfsd: An assortment of little fixes to the sunrpc cache code. [PATCH 012 of 14] knfsd: Remove DefineCacheLookup
[PATCH 013 of 14] knfsd: Unexportcache_freshand fix a small race. [PATCH 014 of 14] knfsd: Convertsunrpc_cacheto use krefs
Quoted 1 line
Any plans to update
Documentation/rpc-cache.txt?
What a good idea! I'll put it on my todo list, thanks.
NeilBrown
Quoted 7 lines · NeilBrown
The following series of patches changes the code for lookup up authentication/authorisation caches in sunrpc as used by nfsd. That than having a delightful macro that defines a function of a particular type of cache, the functions are coded on a more traditional manner using library routines.
This will hopefully make the code more maintainable.
After looking over these patches, it appears there two 'minor' things missing... comments and dprintk statements... :-) Maybe I missed them, but out of all these 14 patches (i.e. basically rewriting a critical part of kNFSD) not one comment or dprintk as added....
Now I'm sure this is a much better design that the previous one, (i.e. hide sight is always 20/20) and I'm looking forward to help iron out the nits... But without meaningful comments and a way to turn on a _few_ well placed "I failed here" type of debug messages, the design really doesn't matter since the maintainable has not improved... imho...
Secondly, In a number of places, mostly in the alloc routines and in patch 006 there are if statements like:
+ if (ch)
+ return container_of(ch, struct svc_export, h);
+ else
+ return NULL;
the else is simply not needed... Plus adding a dprintk like:
+ if (ch)
+ return container_of(ch, struct svc_export, h);
+
+ dprintk("svc_export_update: returns NULL\n");
+ return NULL;
might make sense... assuming svc_export_update does not return NULL 99% of the time...
steved.