diff options
Diffstat (limited to 'fs/lockd')
-rw-r--r-- | fs/lockd/host.c | 19 | ||||
-rw-r--r-- | fs/lockd/svc.c | 17 | ||||
-rw-r--r-- | fs/lockd/svcsubs.c | 17 |
3 files changed, 28 insertions, 25 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 112ebf8b8df..729ac427d35 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -16,6 +16,7 @@ #include <linux/sunrpc/svc.h> #include <linux/lockd/lockd.h> #include <linux/lockd/sm_inter.h> +#include <linux/mutex.h> #define NLMDBG_FACILITY NLMDBG_HOSTCACHE @@ -30,7 +31,7 @@ static struct nlm_host * nlm_hosts[NLM_HOST_NRHASH]; static unsigned long next_gc; static int nrhosts; -static DECLARE_MUTEX(nlm_host_sema); +static DEFINE_MUTEX(nlm_host_mutex); static void nlm_gc_hosts(void); @@ -71,7 +72,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, hash = NLM_ADDRHASH(sin->sin_addr.s_addr); /* Lock hash table */ - down(&nlm_host_sema); + mutex_lock(&nlm_host_mutex); if (time_after_eq(jiffies, next_gc)) nlm_gc_hosts(); @@ -91,7 +92,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, nlm_hosts[hash] = host; } nlm_get_host(host); - up(&nlm_host_sema); + mutex_unlock(&nlm_host_mutex); return host; } } @@ -130,7 +131,7 @@ nlm_lookup_host(int server, struct sockaddr_in *sin, next_gc = 0; nohost: - up(&nlm_host_sema); + mutex_unlock(&nlm_host_mutex); return host; } @@ -141,19 +142,19 @@ nlm_find_client(void) * and return it */ int hash; - down(&nlm_host_sema); + mutex_lock(&nlm_host_mutex); for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) { struct nlm_host *host, **hp; for (hp = &nlm_hosts[hash]; (host = *hp) != 0; hp = &host->h_next) { if (host->h_server && host->h_killed == 0) { nlm_get_host(host); - up(&nlm_host_sema); + mutex_unlock(&nlm_host_mutex); return host; } } } - up(&nlm_host_sema); + mutex_unlock(&nlm_host_mutex); return NULL; } @@ -265,7 +266,7 @@ nlm_shutdown_hosts(void) int i; dprintk("lockd: shutting down host module\n"); - down(&nlm_host_sema); + mutex_lock(&nlm_host_mutex); /* First, make all hosts eligible for gc */ dprintk("lockd: nuking all hosts...\n"); @@ -276,7 +277,7 @@ nlm_shutdown_hosts(void) /* Then, perform a garbage collection pass */ nlm_gc_hosts(); - up(&nlm_host_sema); + mutex_unlock(&nlm_host_mutex); /* complain if any hosts are left */ if (nrhosts) { diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 5e85bde6c12..fd56c8872f3 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -25,6 +25,7 @@ #include <linux/slab.h> #include <linux/smp.h> #include <linux/smp_lock.h> +#include <linux/mutex.h> #include <linux/sunrpc/types.h> #include <linux/sunrpc/stats.h> @@ -43,13 +44,13 @@ static struct svc_program nlmsvc_program; struct nlmsvc_binding * nlmsvc_ops; EXPORT_SYMBOL(nlmsvc_ops); -static DECLARE_MUTEX(nlmsvc_sema); +static DEFINE_MUTEX(nlmsvc_mutex); static unsigned int nlmsvc_users; static pid_t nlmsvc_pid; int nlmsvc_grace_period; unsigned long nlmsvc_timeout; -static DECLARE_MUTEX_LOCKED(lockd_start); +static DECLARE_COMPLETION(lockd_start_done); static DECLARE_WAIT_QUEUE_HEAD(lockd_exit); /* @@ -112,7 +113,7 @@ lockd(struct svc_rqst *rqstp) * Let our maker know we're running. */ nlmsvc_pid = current->pid; - up(&lockd_start); + complete(&lockd_start_done); daemonize("lockd"); @@ -215,7 +216,7 @@ lockd_up(void) struct svc_serv * serv; int error = 0; - down(&nlmsvc_sema); + mutex_lock(&nlmsvc_mutex); /* * Unconditionally increment the user count ... this is * the number of clients who _want_ a lockd process. @@ -263,7 +264,7 @@ lockd_up(void) "lockd_up: create thread failed, error=%d\n", error); goto destroy_and_out; } - down(&lockd_start); + wait_for_completion(&lockd_start_done); /* * Note: svc_serv structures have an initial use count of 1, @@ -272,7 +273,7 @@ lockd_up(void) destroy_and_out: svc_destroy(serv); out: - up(&nlmsvc_sema); + mutex_unlock(&nlmsvc_mutex); return error; } EXPORT_SYMBOL(lockd_up); @@ -285,7 +286,7 @@ lockd_down(void) { static int warned; - down(&nlmsvc_sema); + mutex_lock(&nlmsvc_mutex); if (nlmsvc_users) { if (--nlmsvc_users) goto out; @@ -315,7 +316,7 @@ lockd_down(void) recalc_sigpending(); spin_unlock_irq(¤t->sighand->siglock); out: - up(&nlmsvc_sema); + mutex_unlock(&nlmsvc_mutex); } EXPORT_SYMBOL(lockd_down); diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index c7a6e3ae44d..a570e5c8a93 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -11,6 +11,7 @@ #include <linux/string.h> #include <linux/time.h> #include <linux/in.h> +#include <linux/mutex.h> #include <linux/sunrpc/svc.h> #include <linux/sunrpc/clnt.h> #include <linux/nfsd/nfsfh.h> @@ -28,7 +29,7 @@ #define FILE_HASH_BITS 5 #define FILE_NRHASH (1<<FILE_HASH_BITS) static struct nlm_file * nlm_files[FILE_NRHASH]; -static DECLARE_MUTEX(nlm_file_sema); +static DEFINE_MUTEX(nlm_file_mutex); #ifdef NFSD_DEBUG static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f) @@ -91,7 +92,7 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, hash = file_hash(f); /* Lock file table */ - down(&nlm_file_sema); + mutex_lock(&nlm_file_mutex); for (file = nlm_files[hash]; file; file = file->f_next) if (!nfs_compare_fh(&file->f_handle, f)) @@ -130,7 +131,7 @@ found: nfserr = 0; out_unlock: - up(&nlm_file_sema); + mutex_unlock(&nlm_file_mutex); return nfserr; out_free: @@ -239,14 +240,14 @@ nlm_traverse_files(struct nlm_host *host, int action) struct nlm_file *file, **fp; int i; - down(&nlm_file_sema); + mutex_lock(&nlm_file_mutex); for (i = 0; i < FILE_NRHASH; i++) { fp = nlm_files + i; while ((file = *fp) != NULL) { /* Traverse locks, blocks and shares of this file * and update file->f_locks count */ if (nlm_inspect_file(host, file, action)) { - up(&nlm_file_sema); + mutex_unlock(&nlm_file_mutex); return 1; } @@ -261,7 +262,7 @@ nlm_traverse_files(struct nlm_host *host, int action) } } } - up(&nlm_file_sema); + mutex_unlock(&nlm_file_mutex); return 0; } @@ -281,7 +282,7 @@ nlm_release_file(struct nlm_file *file) file, file->f_count); /* Lock file table */ - down(&nlm_file_sema); + mutex_lock(&nlm_file_mutex); /* If there are no more locks etc, delete the file */ if(--file->f_count == 0) { @@ -289,7 +290,7 @@ nlm_release_file(struct nlm_file *file) nlm_delete_file(file); } - up(&nlm_file_sema); + mutex_unlock(&nlm_file_mutex); } /* |