diff options
Diffstat (limited to 'fs/lockd/host.c')
| -rw-r--r-- | fs/lockd/host.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 112ebf8b8dfe..729ac427d359 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <linux/sunrpc/svc.h> | 16 | #include <linux/sunrpc/svc.h> |
| 17 | #include <linux/lockd/lockd.h> | 17 | #include <linux/lockd/lockd.h> |
| 18 | #include <linux/lockd/sm_inter.h> | 18 | #include <linux/lockd/sm_inter.h> |
| 19 | #include <linux/mutex.h> | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | #define NLMDBG_FACILITY NLMDBG_HOSTCACHE | 22 | #define NLMDBG_FACILITY NLMDBG_HOSTCACHE |
| @@ -30,7 +31,7 @@ | |||
| 30 | static struct nlm_host * nlm_hosts[NLM_HOST_NRHASH]; | 31 | static struct nlm_host * nlm_hosts[NLM_HOST_NRHASH]; |
| 31 | static unsigned long next_gc; | 32 | static unsigned long next_gc; |
| 32 | static int nrhosts; | 33 | static int nrhosts; |
| 33 | static DECLARE_MUTEX(nlm_host_sema); | 34 | static DEFINE_MUTEX(nlm_host_mutex); |
| 34 | 35 | ||
| 35 | 36 | ||
| 36 | static void nlm_gc_hosts(void); | 37 | static void nlm_gc_hosts(void); |
| @@ -71,7 +72,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, | |||
| 71 | hash = NLM_ADDRHASH(sin->sin_addr.s_addr); | 72 | hash = NLM_ADDRHASH(sin->sin_addr.s_addr); |
| 72 | 73 | ||
| 73 | /* Lock hash table */ | 74 | /* Lock hash table */ |
| 74 | down(&nlm_host_sema); | 75 | mutex_lock(&nlm_host_mutex); |
| 75 | 76 | ||
| 76 | if (time_after_eq(jiffies, next_gc)) | 77 | if (time_after_eq(jiffies, next_gc)) |
| 77 | nlm_gc_hosts(); | 78 | nlm_gc_hosts(); |
| @@ -91,7 +92,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, | |||
| 91 | nlm_hosts[hash] = host; | 92 | nlm_hosts[hash] = host; |
| 92 | } | 93 | } |
| 93 | nlm_get_host(host); | 94 | nlm_get_host(host); |
| 94 | up(&nlm_host_sema); | 95 | mutex_unlock(&nlm_host_mutex); |
| 95 | return host; | 96 | return host; |
| 96 | } | 97 | } |
| 97 | } | 98 | } |
| @@ -130,7 +131,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, | |||
| 130 | next_gc = 0; | 131 | next_gc = 0; |
| 131 | 132 | ||
| 132 | nohost: | 133 | nohost: |
| 133 | up(&nlm_host_sema); | 134 | mutex_unlock(&nlm_host_mutex); |
| 134 | return host; | 135 | return host; |
| 135 | } | 136 | } |
| 136 | 137 | ||
| @@ -141,19 +142,19 @@ nlm_find_client(void) | |||
| 141 | * and return it | 142 | * and return it |
| 142 | */ | 143 | */ |
| 143 | int hash; | 144 | int hash; |
| 144 | down(&nlm_host_sema); | 145 | mutex_lock(&nlm_host_mutex); |
| 145 | for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) { | 146 | for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) { |
| 146 | struct nlm_host *host, **hp; | 147 | struct nlm_host *host, **hp; |
| 147 | for (hp = &nlm_hosts[hash]; (host = *hp) != 0; hp = &host->h_next) { | 148 | for (hp = &nlm_hosts[hash]; (host = *hp) != 0; hp = &host->h_next) { |
| 148 | if (host->h_server && | 149 | if (host->h_server && |
| 149 | host->h_killed == 0) { | 150 | host->h_killed == 0) { |
| 150 | nlm_get_host(host); | 151 | nlm_get_host(host); |
| 151 | up(&nlm_host_sema); | 152 | mutex_unlock(&nlm_host_mutex); |
| 152 | return host; | 153 | return host; |
| 153 | } | 154 | } |
| 154 | } | 155 | } |
| 155 | } | 156 | } |
| 156 | up(&nlm_host_sema); | 157 | mutex_unlock(&nlm_host_mutex); |
| 157 | return NULL; | 158 | return NULL; |
| 158 | } | 159 | } |
| 159 | 160 | ||
| @@ -265,7 +266,7 @@ nlm_shutdown_hosts(void) | |||
| 265 | int i; | 266 | int i; |
| 266 | 267 | ||
| 267 | dprintk("lockd: shutting down host module\n"); | 268 | dprintk("lockd: shutting down host module\n"); |
| 268 | down(&nlm_host_sema); | 269 | mutex_lock(&nlm_host_mutex); |
| 269 | 270 | ||
| 270 | /* First, make all hosts eligible for gc */ | 271 | /* First, make all hosts eligible for gc */ |
| 271 | dprintk("lockd: nuking all hosts...\n"); | 272 | dprintk("lockd: nuking all hosts...\n"); |
| @@ -276,7 +277,7 @@ nlm_shutdown_hosts(void) | |||
| 276 | 277 | ||
| 277 | /* Then, perform a garbage collection pass */ | 278 | /* Then, perform a garbage collection pass */ |
| 278 | nlm_gc_hosts(); | 279 | nlm_gc_hosts(); |
| 279 | up(&nlm_host_sema); | 280 | mutex_unlock(&nlm_host_mutex); |
| 280 | 281 | ||
| 281 | /* complain if any hosts are left */ | 282 | /* complain if any hosts are left */ |
| 282 | if (nrhosts) { | 283 | if (nrhosts) { |
