提交 6d1616b2 编写于 作者: T Trond Myklebust 提交者: J. Bruce Fields

SUNRPC: Lockless server RPCSEC_GSS context lookup

Use RCU protection for looking up the RPCSEC_GSS context.
Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 9ceddd9d
...@@ -76,6 +76,7 @@ struct rsi { ...@@ -76,6 +76,7 @@ struct rsi {
struct xdr_netobj in_handle, in_token; struct xdr_netobj in_handle, in_token;
struct xdr_netobj out_handle, out_token; struct xdr_netobj out_handle, out_token;
int major_status, minor_status; int major_status, minor_status;
struct rcu_head rcu_head;
}; };
static struct rsi *rsi_update(struct cache_detail *cd, struct rsi *new, struct rsi *old); static struct rsi *rsi_update(struct cache_detail *cd, struct rsi *new, struct rsi *old);
...@@ -89,13 +90,21 @@ static void rsi_free(struct rsi *rsii) ...@@ -89,13 +90,21 @@ static void rsi_free(struct rsi *rsii)
kfree(rsii->out_token.data); kfree(rsii->out_token.data);
} }
static void rsi_put(struct kref *ref) static void rsi_free_rcu(struct rcu_head *head)
{ {
struct rsi *rsii = container_of(ref, struct rsi, h.ref); struct rsi *rsii = container_of(head, struct rsi, rcu_head);
rsi_free(rsii); rsi_free(rsii);
kfree(rsii); kfree(rsii);
} }
static void rsi_put(struct kref *ref)
{
struct rsi *rsii = container_of(ref, struct rsi, h.ref);
call_rcu(&rsii->rcu_head, rsi_free_rcu);
}
static inline int rsi_hash(struct rsi *item) static inline int rsi_hash(struct rsi *item)
{ {
return hash_mem(item->in_handle.data, item->in_handle.len, RSI_HASHBITS) return hash_mem(item->in_handle.data, item->in_handle.len, RSI_HASHBITS)
...@@ -282,7 +291,7 @@ static struct rsi *rsi_lookup(struct cache_detail *cd, struct rsi *item) ...@@ -282,7 +291,7 @@ static struct rsi *rsi_lookup(struct cache_detail *cd, struct rsi *item)
struct cache_head *ch; struct cache_head *ch;
int hash = rsi_hash(item); int hash = rsi_hash(item);
ch = sunrpc_cache_lookup(cd, &item->h, hash); ch = sunrpc_cache_lookup_rcu(cd, &item->h, hash);
if (ch) if (ch)
return container_of(ch, struct rsi, h); return container_of(ch, struct rsi, h);
else else
...@@ -330,6 +339,7 @@ struct rsc { ...@@ -330,6 +339,7 @@ struct rsc {
struct svc_cred cred; struct svc_cred cred;
struct gss_svc_seq_data seqdata; struct gss_svc_seq_data seqdata;
struct gss_ctx *mechctx; struct gss_ctx *mechctx;
struct rcu_head rcu_head;
}; };
static struct rsc *rsc_update(struct cache_detail *cd, struct rsc *new, struct rsc *old); static struct rsc *rsc_update(struct cache_detail *cd, struct rsc *new, struct rsc *old);
...@@ -343,12 +353,22 @@ static void rsc_free(struct rsc *rsci) ...@@ -343,12 +353,22 @@ static void rsc_free(struct rsc *rsci)
free_svc_cred(&rsci->cred); free_svc_cred(&rsci->cred);
} }
static void rsc_free_rcu(struct rcu_head *head)
{
struct rsc *rsci = container_of(head, struct rsc, rcu_head);
kfree(rsci->handle.data);
kfree(rsci);
}
static void rsc_put(struct kref *ref) static void rsc_put(struct kref *ref)
{ {
struct rsc *rsci = container_of(ref, struct rsc, h.ref); struct rsc *rsci = container_of(ref, struct rsc, h.ref);
rsc_free(rsci); if (rsci->mechctx)
kfree(rsci); gss_delete_sec_context(&rsci->mechctx);
free_svc_cred(&rsci->cred);
call_rcu(&rsci->rcu_head, rsc_free_rcu);
} }
static inline int static inline int
...@@ -542,7 +562,7 @@ static struct rsc *rsc_lookup(struct cache_detail *cd, struct rsc *item) ...@@ -542,7 +562,7 @@ static struct rsc *rsc_lookup(struct cache_detail *cd, struct rsc *item)
struct cache_head *ch; struct cache_head *ch;
int hash = rsc_hash(item); int hash = rsc_hash(item);
ch = sunrpc_cache_lookup(cd, &item->h, hash); ch = sunrpc_cache_lookup_rcu(cd, &item->h, hash);
if (ch) if (ch)
return container_of(ch, struct rsc, h); return container_of(ch, struct rsc, h);
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册