Skip to content

Commit 2b477c0

Browse files
Neil BrownJ. Bruce Fields
authored andcommitted
svcrpc: free contexts immediately on PROC_DESTROY
We currently handle a client PROC_DESTROY request by turning it CACHE_NEGATIVE, setting the expired time to now, and then waiting for cache_clean to clean it up later. Since we forgot to set the cache's nextcheck value, that could take up to 30 minutes. Also, though there's probably no real bug in this case, setting CACHE_NEGATIVE directly like this probably isn't a great idea in general. So let's just remove the entry from the cache directly, and move this bit of cache manipulation to a helper function. Signed-off-by: Neil Brown <neilb@suse.com> Reported-by: Andy Adamson <andros@netapp.com> Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 034dd34 commit 2b477c0

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

include/linux/sunrpc/cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ extern void sunrpc_destroy_cache_detail(struct cache_detail *cd);
227227
extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *,
228228
umode_t, struct cache_detail *);
229229
extern void sunrpc_cache_unregister_pipefs(struct cache_detail *);
230+
extern void sunrpc_cache_unhash(struct cache_detail *, struct cache_head *);
230231

231232
/* Must store cache_detail in seq_file->private if using next three functions */
232233
extern void *cache_seq_start(struct seq_file *file, loff_t *pos);

net/sunrpc/auth_gss/svcauth_gss.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
14891489
case RPC_GSS_PROC_DESTROY:
14901490
if (gss_write_verf(rqstp, rsci->mechctx, gc->gc_seq))
14911491
goto auth_err;
1492-
rsci->h.expiry_time = seconds_since_boot();
1493-
set_bit(CACHE_NEGATIVE, &rsci->h.flags);
1492+
/* Delete the entry from the cache_list and call cache_put */
1493+
sunrpc_cache_unhash(sn->rsc_cache, &rsci->h);
14941494
if (resv->iov_len + 4 > PAGE_SIZE)
14951495
goto drop;
14961496
svc_putnl(resv, RPC_SUCCESS);

net/sunrpc/cache.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,3 +1855,15 @@ void sunrpc_cache_unregister_pipefs(struct cache_detail *cd)
18551855
}
18561856
EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs);
18571857

1858+
void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h)
1859+
{
1860+
write_lock(&cd->hash_lock);
1861+
if (!hlist_unhashed(&h->cache_list)){
1862+
hlist_del_init(&h->cache_list);
1863+
cd->entries--;
1864+
write_unlock(&cd->hash_lock);
1865+
cache_put(h, cd);
1866+
} else
1867+
write_unlock(&cd->hash_lock);
1868+
}
1869+
EXPORT_SYMBOL_GPL(sunrpc_cache_unhash);

0 commit comments

Comments
 (0)