kNFSd - 2 of 8 - Assorted fixed for NFS export cache
Subsystems (3)
PATCH 1/1 kNFSd - 2 of 8 - Assorted fixed for NFS export cache
### Comments for ChangeSet
Most significant fix is cleaning up properly when nfs service is stopped.
Also fix some refcounting problems and other little bits.
----------- Diffstat output ------------
./fs/nfsd/export.c | 8 ++++++-- ./fs/nfsd/nfsproc.c | 1 + ./fs/nfsd/vfs.c | 2 +- ./include/linux/sunrpc/cache.h | 9 +++++++-- ./include/linux/sunrpc/svc.h | 1 - ./net/sunrpc/cache.c | 40 ++++++++++++++++++++++++++++++++++------ ./net/sunrpc/svc.c | 2 ++ ./net/sunrpc/svcauth_unix.c | 6 +++--- ./net/sunrpc/svcsock.c | 4 ++-- 9 files changed, 56 insertions(+), 17 deletions(-)
fs/nfsd/export.c renamed from fs/nfsd/export.c~current~ +6 -2
@@ -153,9 +153,13 @@ int expkey_parse(struct cache_detail *cd goto out;dprintk ("Path seems to be <%s>\n" , buf); err =0 ; -if (len ==0 ) +if (len ==0 ) { +struct svc_expkey *ek;set_bit (CACHE_NEGATIVE , &key.h.flags); -else { + ek =svc_expkey_lookup (&key,2 ); +if (ek) +expkey_put (&ek->h, &svc_expkey_cache); + }else {struct nameidata nd;struct svc_expkey *ek;struct svc_export *exp;
fs/nfsd/nfsproc.c renamed from fs/nfsd/nfsproc.c~current~ +1 -0
@@ -591,6 +591,7 @@ nfserrno (int errno) { nfserr_dquot, -EDQUOT }, #endif { nfserr_stale, -ESTALE }, + { nfserr_dropit, -EAGAIN }, { nfserr_dropit, -ENOMEM }, { -1, -EIO } };
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c~current~ +1 -1
@@ -167,7 +167,7 @@ nfsd_lookup(struct svc_rqst *rqstp, strudput (mounts);dput (dentry);mntput (mnt); - goto out; + goto out_nfserr; } if (exp2 && ((exp->ex_flags & NFSEXP_CROSSMNT)
include/linux/sunrpc/cache.h renamed from include/linux/sunrpc/cache.h~current~ +7 -2
@@ -115,6 +115,8 @@ struct cache_deferred_req {struct list_head recent;/* on fifo */ struct cache_head *item;/* cache item we wait on */ time_t recv_time; +void *owner;/* we might need to discard all defered requests +* owned by someone */ void (*revisit)(struct cache_deferred_req *req,int too_many); };
@@ -168,12 +170,14 @@ RTN *FNAME ARGS \ tmp =container_of (*hp,RTN ,MEMBER ); \if (TEST ) {/* found a match */ \ \ +if (set ==1 &&test_bit (CACHE_VALID , &tmp->MEMBER.flags) && !new) \ +break ; \ + \atomic_inc (&tmp->MEMBER.refcnt); \if (set) { \ -if (set!=2 &&test_bit (CACHE_VALID , &tmp->MEMBER.flags))\ +if (set ==1 &&test_bit (CACHE_VALID , &tmp->MEMBER.flags))\ {/* need to swap in new */ \RTN *t2; \ -if (!new)break ; \ \ new->MEMBER.next = tmp->MEMBER.next; \ *hp = &new->MEMBER; \
@@ -242,6 +246,7 @@ RTN *FNAME ARGS \extern void cache_defer_req (struct cache_req *req,struct cache_head *item);extern void cache_revisit_request (struct cache_head *item); +extern void cache_clean_deferred (void *owner);static inline struct cache_head *cache_get (struct cache_head *h) {
include/linux/sunrpc/svc.h renamed from include/linux/sunrpc/svc.h~current~ +0 -1
@@ -218,7 +218,6 @@ static inline void svc_free_allpages(str }struct svc_deferred_req { -struct svc_serv *serv;u32 prot;/* protocol (UDP or TCP) */ struct sockaddr_in addr;struct svc_sock *svsk;/* where reply must go */
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~current~ +34 -6
@@ -310,14 +310,17 @@ int cache_clean(void) cp = & current_detail->hash_table[current_index]; ch = *cp;for (; ch; cp= & ch->next, ch= *cp) { -if (atomic_read (&ch->refcnt)) -continue ; -if (ch->expiry_time <get_seconds () - || ch->last_refresh < current_detail->flush_time - ) -break ;if (current_detail->nextcheck > ch->expiry_time) current_detail->nextcheck = ch->expiry_time+1 ; +if (ch->expiry_time >=get_seconds () + && ch->last_refresh >= current_detail->flush_time + ) +continue ; +if (test_and_clear_bit (CACHE_PENDING , &ch->flags)) +queue_loose (current_detail, ch); + +if (atomic_read (&ch->refcnt)) +continue ; }if (ch) {cache_get (ch);
@@ -467,6 +470,31 @@ void cache_revisit_request(struct cache_ } } +void cache_clean_deferred (void *owner) +{ +struct cache_deferred_req *dreq, *tmp; +struct list_head pending; + + +INIT_LIST_HEAD (&pending); +spin_lock (&cache_defer_lock); + +list_for_each_entry_safe (dreq, tmp, &cache_defer_list, recent) { +if (dreq->owner == owner) { +list_del (&dreq->hash); +list_move (&dreq->recent, &pending); + cache_defer_cnt--; + } + } +spin_unlock (&cache_defer_lock); + +while (!list_empty (&pending)) { + dreq = list_entry(pending.next, struct cache_deferred_req, recent); +list_del_init (&dreq->recent); + dreq->revisit (dreq,1 ); + } +} +/* * communicate with user-space *
net/sunrpc/svc.c renamed from net/sunrpc/svc.c~current~ +2 -0
@@ -98,6 +98,8 @@ svc_destroy(struct svc_serv *serv) sk_list);svc_delete_socket (svsk); } + +cache_clean_deferred (serv);/* Unregister service with the portmapper */ svc_register (serv,0 ,0 );
net/sunrpc/svcauth_unix.c renamed from net/sunrpc/svcauth_unix.c~current~ +3 -3
@@ -195,12 +195,12 @@ static int ip_map_parse(struct cache_det ipm.m_addr.s_addr =htonl ((((((b1<<8 )|b2)<<8 )|b3)<<8 )|b4); ipm.h.flags =0 ; -if (dom) +if (dom) { ipm.m_client = container_of(dom, struct unix_domain, h); -else + ipm.m_add_change = ipm.m_client->addr_changes; + }else set_bit (CACHE_NEGATIVE , &ipm.h.flags); ipm.h.expiry_time = expiry; - ipm.m_add_change = ipm.m_client->addr_changes; ipmp =ip_map_lookup (&ipm,1 );if (ipmp)
net/sunrpc/svcsock.c renamed from net/sunrpc/svcsock.c~current~ +2 -2
@@ -1443,7 +1443,7 @@ svc_makesock(struct svc_serv *serv, intstatic void svc_revisit (struct cache_deferred_req *dreq,int too_many) { struct svc_deferred_req *dr = container_of(dreq, struct svc_deferred_req, handle); -struct svc_serv *serv = dr->serv; +struct svc_serv *serv = dreq->owner;struct svc_sock *svsk;if (too_many) {
@@ -1481,7 +1481,7 @@ svc_defer(struct cache_req *req)if (dr ==NULL )return NULL ; - dr->serv = rqstp->rq_server; + dr->handle.owner = rqstp->rq_server; dr->prot = rqstp->rq_prot; dr->addr = rqstp->rq_addr; dr->argslen = rqstp->rq_arg.len >>2 ;
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs