Commit 1a68d952 authored by Greg Banks's avatar Greg Banks Committed by Linus Torvalds

[PATCH] knfsd: use new lock for svc_sock deferred list

Protect the svc_sock->sk_deferred list with a new lock svc_sock->sk_defer_lock
instead of svc_serv->sv_lock.  Using the more fine-grained lock reduces the
number of places we need to take the svc_serv lock.
Signed-off-by: default avatarGreg Banks <gnb@melbourne.sgi.com>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c45c357d
...@@ -36,6 +36,7 @@ struct svc_sock { ...@@ -36,6 +36,7 @@ struct svc_sock {
int sk_reserved; /* space on outq that is reserved */ int sk_reserved; /* space on outq that is reserved */
spinlock_t sk_defer_lock; /* protects sk_deferred */
struct list_head sk_deferred; /* deferred requests that need to struct list_head sk_deferred; /* deferred requests that need to
* be revisted */ * be revisted */
struct mutex sk_mutex; /* to serialize sending data */ struct mutex sk_mutex; /* to serialize sending data */
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
/* SMP locking strategy: /* SMP locking strategy:
* *
* svc_serv->sv_lock protects most stuff for that service. * svc_serv->sv_lock protects most stuff for that service.
* svc_sock->sk_defer_lock protects the svc_sock->sk_deferred list
* *
* Some flags can be set to certain values at any time * Some flags can be set to certain values at any time
* providing that certain rules are followed: * providing that certain rules are followed:
...@@ -1416,6 +1417,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock, ...@@ -1416,6 +1417,7 @@ svc_setup_socket(struct svc_serv *serv, struct socket *sock,
svsk->sk_server = serv; svsk->sk_server = serv;
atomic_set(&svsk->sk_inuse, 0); atomic_set(&svsk->sk_inuse, 0);
svsk->sk_lastrecv = get_seconds(); svsk->sk_lastrecv = get_seconds();
spin_lock_init(&svsk->sk_defer_lock);
INIT_LIST_HEAD(&svsk->sk_deferred); INIT_LIST_HEAD(&svsk->sk_deferred);
INIT_LIST_HEAD(&svsk->sk_ready); INIT_LIST_HEAD(&svsk->sk_ready);
mutex_init(&svsk->sk_mutex); mutex_init(&svsk->sk_mutex);
...@@ -1594,7 +1596,6 @@ svc_makesock(struct svc_serv *serv, int protocol, unsigned short port) ...@@ -1594,7 +1596,6 @@ svc_makesock(struct svc_serv *serv, int protocol, unsigned short port)
static void svc_revisit(struct cache_deferred_req *dreq, int too_many) static 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_deferred_req *dr = container_of(dreq, struct svc_deferred_req, handle);
struct svc_serv *serv = dreq->owner;
struct svc_sock *svsk; struct svc_sock *svsk;
if (too_many) { if (too_many) {
...@@ -1605,9 +1606,9 @@ static void svc_revisit(struct cache_deferred_req *dreq, int too_many) ...@@ -1605,9 +1606,9 @@ static void svc_revisit(struct cache_deferred_req *dreq, int too_many)
dprintk("revisit queued\n"); dprintk("revisit queued\n");
svsk = dr->svsk; svsk = dr->svsk;
dr->svsk = NULL; dr->svsk = NULL;
spin_lock_bh(&serv->sv_lock); spin_lock_bh(&svsk->sk_defer_lock);
list_add(&dr->handle.recent, &svsk->sk_deferred); list_add(&dr->handle.recent, &svsk->sk_deferred);
spin_unlock_bh(&serv->sv_lock); spin_unlock_bh(&svsk->sk_defer_lock);
set_bit(SK_DEFERRED, &svsk->sk_flags); set_bit(SK_DEFERRED, &svsk->sk_flags);
svc_sock_enqueue(svsk); svc_sock_enqueue(svsk);
svc_sock_put(svsk); svc_sock_put(svsk);
...@@ -1667,11 +1668,10 @@ static int svc_deferred_recv(struct svc_rqst *rqstp) ...@@ -1667,11 +1668,10 @@ static int svc_deferred_recv(struct svc_rqst *rqstp)
static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk) static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk)
{ {
struct svc_deferred_req *dr = NULL; struct svc_deferred_req *dr = NULL;
struct svc_serv *serv = svsk->sk_server;
if (!test_bit(SK_DEFERRED, &svsk->sk_flags)) if (!test_bit(SK_DEFERRED, &svsk->sk_flags))
return NULL; return NULL;
spin_lock_bh(&serv->sv_lock); spin_lock_bh(&svsk->sk_defer_lock);
clear_bit(SK_DEFERRED, &svsk->sk_flags); clear_bit(SK_DEFERRED, &svsk->sk_flags);
if (!list_empty(&svsk->sk_deferred)) { if (!list_empty(&svsk->sk_deferred)) {
dr = list_entry(svsk->sk_deferred.next, dr = list_entry(svsk->sk_deferred.next,
...@@ -1680,6 +1680,6 @@ static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk) ...@@ -1680,6 +1680,6 @@ static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk)
list_del_init(&dr->handle.recent); list_del_init(&dr->handle.recent);
set_bit(SK_DEFERRED, &svsk->sk_flags); set_bit(SK_DEFERRED, &svsk->sk_flags);
} }
spin_unlock_bh(&serv->sv_lock); spin_unlock_bh(&svsk->sk_defer_lock);
return dr; return dr;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment