[PATCH] sem2mutex: fs/
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Eric Van Hensbergen <ericvh@ericvh.myip.org> Cc: Robert Love <rml@tech9.net> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Neil Brown <neilb@cse.unsw.edu.au> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Cc: Dave Kleikamp <shaggy@austin.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
		
							parent
							
								
									e655a250d5
								
							
						
					
					
						commit
						353ab6e97b
					
				| @ -22,6 +22,7 @@ | ||||
| #include <linux/cramfs_fs_sb.h> | ||||
| #include <linux/buffer_head.h> | ||||
| #include <linux/vfs.h> | ||||
| #include <linux/mutex.h> | ||||
| #include <asm/semaphore.h> | ||||
| 
 | ||||
| #include <asm/uaccess.h> | ||||
| @ -31,7 +32,7 @@ static struct inode_operations cramfs_dir_inode_operations; | ||||
| static struct file_operations cramfs_directory_operations; | ||||
| static struct address_space_operations cramfs_aops; | ||||
| 
 | ||||
| static DECLARE_MUTEX(read_mutex); | ||||
| static DEFINE_MUTEX(read_mutex); | ||||
| 
 | ||||
| 
 | ||||
| /* These two macros may change in future, to provide better st_ino
 | ||||
| @ -250,20 +251,20 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent) | ||||
| 	memset(sbi, 0, sizeof(struct cramfs_sb_info)); | ||||
| 
 | ||||
| 	/* Invalidate the read buffers on mount: think disk change.. */ | ||||
| 	down(&read_mutex); | ||||
| 	mutex_lock(&read_mutex); | ||||
| 	for (i = 0; i < READ_BUFFERS; i++) | ||||
| 		buffer_blocknr[i] = -1; | ||||
| 
 | ||||
| 	/* Read the first block and get the superblock from it */ | ||||
| 	memcpy(&super, cramfs_read(sb, 0, sizeof(super)), sizeof(super)); | ||||
| 	up(&read_mutex); | ||||
| 	mutex_unlock(&read_mutex); | ||||
| 
 | ||||
| 	/* Do sanity checks on the superblock */ | ||||
| 	if (super.magic != CRAMFS_MAGIC) { | ||||
| 		/* check at 512 byte offset */ | ||||
| 		down(&read_mutex); | ||||
| 		mutex_lock(&read_mutex); | ||||
| 		memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super)); | ||||
| 		up(&read_mutex); | ||||
| 		mutex_unlock(&read_mutex); | ||||
| 		if (super.magic != CRAMFS_MAGIC) { | ||||
| 			if (!silent) | ||||
| 				printk(KERN_ERR "cramfs: wrong magic\n"); | ||||
| @ -366,7 +367,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | ||||
| 		mode_t mode; | ||||
| 		int namelen, error; | ||||
| 
 | ||||
| 		down(&read_mutex); | ||||
| 		mutex_lock(&read_mutex); | ||||
| 		de = cramfs_read(sb, OFFSET(inode) + offset, sizeof(*de)+256); | ||||
| 		name = (char *)(de+1); | ||||
| 
 | ||||
| @ -379,7 +380,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | ||||
| 		memcpy(buf, name, namelen); | ||||
| 		ino = CRAMINO(de); | ||||
| 		mode = de->mode; | ||||
| 		up(&read_mutex); | ||||
| 		mutex_unlock(&read_mutex); | ||||
| 		nextoffset = offset + sizeof(*de) + namelen; | ||||
| 		for (;;) { | ||||
| 			if (!namelen) { | ||||
| @ -410,7 +411,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s | ||||
| 	unsigned int offset = 0; | ||||
| 	int sorted; | ||||
| 
 | ||||
| 	down(&read_mutex); | ||||
| 	mutex_lock(&read_mutex); | ||||
| 	sorted = CRAMFS_SB(dir->i_sb)->flags & CRAMFS_FLAG_SORTED_DIRS; | ||||
| 	while (offset < dir->i_size) { | ||||
| 		struct cramfs_inode *de; | ||||
| @ -433,7 +434,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s | ||||
| 
 | ||||
| 		for (;;) { | ||||
| 			if (!namelen) { | ||||
| 				up(&read_mutex); | ||||
| 				mutex_unlock(&read_mutex); | ||||
| 				return ERR_PTR(-EIO); | ||||
| 			} | ||||
| 			if (name[namelen-1]) | ||||
| @ -447,7 +448,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s | ||||
| 			continue; | ||||
| 		if (!retval) { | ||||
| 			struct cramfs_inode entry = *de; | ||||
| 			up(&read_mutex); | ||||
| 			mutex_unlock(&read_mutex); | ||||
| 			d_add(dentry, get_cramfs_inode(dir->i_sb, &entry)); | ||||
| 			return NULL; | ||||
| 		} | ||||
| @ -455,7 +456,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s | ||||
| 		if (sorted) | ||||
| 			break; | ||||
| 	} | ||||
| 	up(&read_mutex); | ||||
| 	mutex_unlock(&read_mutex); | ||||
| 	d_add(dentry, NULL); | ||||
| 	return NULL; | ||||
| } | ||||
| @ -474,21 +475,21 @@ static int cramfs_readpage(struct file *file, struct page * page) | ||||
| 		u32 start_offset, compr_len; | ||||
| 
 | ||||
| 		start_offset = OFFSET(inode) + maxblock*4; | ||||
| 		down(&read_mutex); | ||||
| 		mutex_lock(&read_mutex); | ||||
| 		if (page->index) | ||||
| 			start_offset = *(u32 *) cramfs_read(sb, blkptr_offset-4, 4); | ||||
| 		compr_len = (*(u32 *) cramfs_read(sb, blkptr_offset, 4) - start_offset); | ||||
| 		up(&read_mutex); | ||||
| 		mutex_unlock(&read_mutex); | ||||
| 		pgdata = kmap(page); | ||||
| 		if (compr_len == 0) | ||||
| 			; /* hole */ | ||||
| 		else { | ||||
| 			down(&read_mutex); | ||||
| 			mutex_lock(&read_mutex); | ||||
| 			bytes_filled = cramfs_uncompress_block(pgdata, | ||||
| 				 PAGE_CACHE_SIZE, | ||||
| 				 cramfs_read(sb, start_offset, compr_len), | ||||
| 				 compr_len); | ||||
| 			up(&read_mutex); | ||||
| 			mutex_unlock(&read_mutex); | ||||
| 		} | ||||
| 	} else | ||||
| 		pgdata = kmap(page); | ||||
|  | ||||
| @ -23,6 +23,7 @@ | ||||
| #include <linux/mm.h> | ||||
| #include <linux/errno.h> | ||||
| #include <linux/dcookies.h> | ||||
| #include <linux/mutex.h> | ||||
| #include <asm/uaccess.h> | ||||
| 
 | ||||
| /* The dcookies are allocated from a kmem_cache and
 | ||||
| @ -36,7 +37,7 @@ struct dcookie_struct { | ||||
| }; | ||||
| 
 | ||||
| static LIST_HEAD(dcookie_users); | ||||
| static DECLARE_MUTEX(dcookie_sem); | ||||
| static DEFINE_MUTEX(dcookie_mutex); | ||||
| static kmem_cache_t * dcookie_cache; | ||||
| static struct list_head * dcookie_hashtable; | ||||
| static size_t hash_size; | ||||
| @ -114,7 +115,7 @@ int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, | ||||
| 	int err = 0; | ||||
| 	struct dcookie_struct * dcs; | ||||
| 
 | ||||
| 	down(&dcookie_sem); | ||||
| 	mutex_lock(&dcookie_mutex); | ||||
| 
 | ||||
| 	if (!is_live()) { | ||||
| 		err = -EINVAL; | ||||
| @ -134,7 +135,7 @@ int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, | ||||
| 	*cookie = dcookie_value(dcs); | ||||
| 
 | ||||
| out: | ||||
| 	up(&dcookie_sem); | ||||
| 	mutex_unlock(&dcookie_mutex); | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| @ -157,7 +158,7 @@ asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len) | ||||
| 	if (!capable(CAP_SYS_ADMIN)) | ||||
| 		return -EPERM; | ||||
| 
 | ||||
| 	down(&dcookie_sem); | ||||
| 	mutex_lock(&dcookie_mutex); | ||||
| 
 | ||||
| 	if (!is_live()) { | ||||
| 		err = -EINVAL; | ||||
| @ -192,7 +193,7 @@ asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len) | ||||
| out_free: | ||||
| 	kfree(kbuf); | ||||
| out: | ||||
| 	up(&dcookie_sem); | ||||
| 	mutex_unlock(&dcookie_mutex); | ||||
| 	return err; | ||||
| } | ||||
| 
 | ||||
| @ -290,7 +291,7 @@ struct dcookie_user * dcookie_register(void) | ||||
| { | ||||
| 	struct dcookie_user * user; | ||||
| 
 | ||||
| 	down(&dcookie_sem); | ||||
| 	mutex_lock(&dcookie_mutex); | ||||
| 
 | ||||
| 	user = kmalloc(sizeof(struct dcookie_user), GFP_KERNEL); | ||||
| 	if (!user) | ||||
| @ -302,7 +303,7 @@ struct dcookie_user * dcookie_register(void) | ||||
| 	list_add(&user->next, &dcookie_users); | ||||
| 
 | ||||
| out: | ||||
| 	up(&dcookie_sem); | ||||
| 	mutex_unlock(&dcookie_mutex); | ||||
| 	return user; | ||||
| out_free: | ||||
| 	kfree(user); | ||||
| @ -313,7 +314,7 @@ out_free: | ||||
| 
 | ||||
| void dcookie_unregister(struct dcookie_user * user) | ||||
| { | ||||
| 	down(&dcookie_sem); | ||||
| 	mutex_lock(&dcookie_mutex); | ||||
| 
 | ||||
| 	list_del(&user->next); | ||||
| 	kfree(user); | ||||
| @ -321,7 +322,7 @@ void dcookie_unregister(struct dcookie_user * user) | ||||
| 	if (!is_live()) | ||||
| 		dcookie_exit(); | ||||
| 
 | ||||
| 	up(&dcookie_sem); | ||||
| 	mutex_unlock(&dcookie_mutex); | ||||
| } | ||||
| 
 | ||||
| EXPORT_SYMBOL_GPL(dcookie_register); | ||||
|  | ||||
| @ -33,13 +33,14 @@ | ||||
| 	*/ | ||||
| #define STREAM_END_SPACE 12 | ||||
| 
 | ||||
| static DECLARE_MUTEX(deflate_sem); | ||||
| static DECLARE_MUTEX(inflate_sem); | ||||
| static DEFINE_MUTEX(deflate_mutex); | ||||
| static DEFINE_MUTEX(inflate_mutex); | ||||
| static z_stream inf_strm, def_strm; | ||||
| 
 | ||||
| #ifdef __KERNEL__ /* Linux-only */ | ||||
| #include <linux/vmalloc.h> | ||||
| #include <linux/init.h> | ||||
| #include <linux/mutex.h> | ||||
| 
 | ||||
| static int __init alloc_workspaces(void) | ||||
| { | ||||
| @ -79,11 +80,11 @@ static int jffs2_zlib_compress(unsigned char *data_in, | ||||
| 	if (*dstlen <= STREAM_END_SPACE) | ||||
| 		return -1; | ||||
| 
 | ||||
| 	down(&deflate_sem); | ||||
| 	mutex_lock(&deflate_mutex); | ||||
| 
 | ||||
| 	if (Z_OK != zlib_deflateInit(&def_strm, 3)) { | ||||
| 		printk(KERN_WARNING "deflateInit failed\n"); | ||||
| 		up(&deflate_sem); | ||||
| 		mutex_unlock(&deflate_mutex); | ||||
| 		return -1; | ||||
| 	} | ||||
| 
 | ||||
| @ -104,7 +105,7 @@ static int jffs2_zlib_compress(unsigned char *data_in, | ||||
| 		if (ret != Z_OK) { | ||||
| 			D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret)); | ||||
| 			zlib_deflateEnd(&def_strm); | ||||
| 			up(&deflate_sem); | ||||
| 			mutex_unlock(&deflate_mutex); | ||||
| 			return -1; | ||||
| 		} | ||||
| 	} | ||||
| @ -133,7 +134,7 @@ static int jffs2_zlib_compress(unsigned char *data_in, | ||||
| 	*sourcelen = def_strm.total_in; | ||||
| 	ret = 0; | ||||
|  out: | ||||
| 	up(&deflate_sem); | ||||
| 	mutex_unlock(&deflate_mutex); | ||||
| 	return ret; | ||||
| } | ||||
| 
 | ||||
| @ -145,7 +146,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in, | ||||
| 	int ret; | ||||
| 	int wbits = MAX_WBITS; | ||||
| 
 | ||||
| 	down(&inflate_sem); | ||||
| 	mutex_lock(&inflate_mutex); | ||||
| 
 | ||||
| 	inf_strm.next_in = data_in; | ||||
| 	inf_strm.avail_in = srclen; | ||||
| @ -173,7 +174,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in, | ||||
| 
 | ||||
| 	if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) { | ||||
| 		printk(KERN_WARNING "inflateInit failed\n"); | ||||
| 		up(&inflate_sem); | ||||
| 		mutex_unlock(&inflate_mutex); | ||||
| 		return 1; | ||||
| 	} | ||||
| 
 | ||||
| @ -183,7 +184,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in, | ||||
| 		printk(KERN_NOTICE "inflate returned %d\n", ret); | ||||
| 	} | ||||
| 	zlib_inflateEnd(&inf_strm); | ||||
| 	up(&inflate_sem); | ||||
| 	mutex_unlock(&inflate_mutex); | ||||
|         return 0; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -69,6 +69,7 @@ | ||||
| #include <linux/bio.h> | ||||
| #include <linux/suspend.h> | ||||
| #include <linux/delay.h> | ||||
| #include <linux/mutex.h> | ||||
| #include "jfs_incore.h" | ||||
| #include "jfs_filsys.h" | ||||
| #include "jfs_metapage.h" | ||||
| @ -165,7 +166,7 @@ do {						\ | ||||
|  */ | ||||
| static LIST_HEAD(jfs_external_logs); | ||||
| static struct jfs_log *dummy_log = NULL; | ||||
| static DECLARE_MUTEX(jfs_log_sem); | ||||
| static DEFINE_MUTEX(jfs_log_mutex); | ||||
| 
 | ||||
| /*
 | ||||
|  * forward references | ||||
| @ -1085,20 +1086,20 @@ int lmLogOpen(struct super_block *sb) | ||||
| 	if (sbi->mntflag & JFS_INLINELOG) | ||||
| 		return open_inline_log(sb); | ||||
| 
 | ||||
| 	down(&jfs_log_sem); | ||||
| 	mutex_lock(&jfs_log_mutex); | ||||
| 	list_for_each_entry(log, &jfs_external_logs, journal_list) { | ||||
| 		if (log->bdev->bd_dev == sbi->logdev) { | ||||
| 			if (memcmp(log->uuid, sbi->loguuid, | ||||
| 				   sizeof(log->uuid))) { | ||||
| 				jfs_warn("wrong uuid on JFS journal\n"); | ||||
| 				up(&jfs_log_sem); | ||||
| 				mutex_unlock(&jfs_log_mutex); | ||||
| 				return -EINVAL; | ||||
| 			} | ||||
| 			/*
 | ||||
| 			 * add file system to log active file system list | ||||
| 			 */ | ||||
| 			if ((rc = lmLogFileSystem(log, sbi, 1))) { | ||||
| 				up(&jfs_log_sem); | ||||
| 				mutex_unlock(&jfs_log_mutex); | ||||
| 				return rc; | ||||
| 			} | ||||
| 			goto journal_found; | ||||
| @ -1106,7 +1107,7 @@ int lmLogOpen(struct super_block *sb) | ||||
| 	} | ||||
| 
 | ||||
| 	if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) { | ||||
| 		up(&jfs_log_sem); | ||||
| 		mutex_unlock(&jfs_log_mutex); | ||||
| 		return -ENOMEM; | ||||
| 	} | ||||
| 	INIT_LIST_HEAD(&log->sb_list); | ||||
| @ -1151,7 +1152,7 @@ journal_found: | ||||
| 	sbi->log = log; | ||||
| 	LOG_UNLOCK(log); | ||||
| 
 | ||||
| 	up(&jfs_log_sem); | ||||
| 	mutex_unlock(&jfs_log_mutex); | ||||
| 	return 0; | ||||
| 
 | ||||
| 	/*
 | ||||
| @ -1168,7 +1169,7 @@ journal_found: | ||||
| 	blkdev_put(bdev); | ||||
| 
 | ||||
|       free:		/* free log descriptor */ | ||||
| 	up(&jfs_log_sem); | ||||
| 	mutex_unlock(&jfs_log_mutex); | ||||
| 	kfree(log); | ||||
| 
 | ||||
| 	jfs_warn("lmLogOpen: exit(%d)", rc); | ||||
| @ -1212,11 +1213,11 @@ static int open_dummy_log(struct super_block *sb) | ||||
| { | ||||
| 	int rc; | ||||
| 
 | ||||
| 	down(&jfs_log_sem); | ||||
| 	mutex_lock(&jfs_log_mutex); | ||||
| 	if (!dummy_log) { | ||||
| 		dummy_log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL); | ||||
| 		if (!dummy_log) { | ||||
| 			up(&jfs_log_sem); | ||||
| 			mutex_unlock(&jfs_log_mutex); | ||||
| 			return -ENOMEM; | ||||
| 		} | ||||
| 		INIT_LIST_HEAD(&dummy_log->sb_list); | ||||
| @ -1229,7 +1230,7 @@ static int open_dummy_log(struct super_block *sb) | ||||
| 		if (rc) { | ||||
| 			kfree(dummy_log); | ||||
| 			dummy_log = NULL; | ||||
| 			up(&jfs_log_sem); | ||||
| 			mutex_unlock(&jfs_log_mutex); | ||||
| 			return rc; | ||||
| 		} | ||||
| 	} | ||||
| @ -1238,7 +1239,7 @@ static int open_dummy_log(struct super_block *sb) | ||||
| 	list_add(&JFS_SBI(sb)->log_list, &dummy_log->sb_list); | ||||
| 	JFS_SBI(sb)->log = dummy_log; | ||||
| 	LOG_UNLOCK(dummy_log); | ||||
| 	up(&jfs_log_sem); | ||||
| 	mutex_unlock(&jfs_log_mutex); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
| @ -1466,7 +1467,7 @@ int lmLogClose(struct super_block *sb) | ||||
| 
 | ||||
| 	jfs_info("lmLogClose: log:0x%p", log); | ||||
| 
 | ||||
| 	down(&jfs_log_sem); | ||||
| 	mutex_lock(&jfs_log_mutex); | ||||
| 	LOG_LOCK(log); | ||||
| 	list_del(&sbi->log_list); | ||||
| 	LOG_UNLOCK(log); | ||||
| @ -1516,7 +1517,7 @@ int lmLogClose(struct super_block *sb) | ||||
| 	kfree(log); | ||||
| 
 | ||||
|       out: | ||||
| 	up(&jfs_log_sem); | ||||
| 	mutex_unlock(&jfs_log_mutex); | ||||
| 	jfs_info("lmLogClose: exit(%d)", rc); | ||||
| 	return rc; | ||||
| } | ||||
|  | ||||
| @ -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) { | ||||
|  | ||||
| @ -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); | ||||
| 
 | ||||
|  | ||||
| @ -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); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  | ||||
| @ -14,6 +14,7 @@ | ||||
| #include <linux/sunrpc/svc.h> | ||||
| #include <linux/sunrpc/svcsock.h> | ||||
| #include <linux/nfs_fs.h> | ||||
| #include <linux/mutex.h> | ||||
| 
 | ||||
| #include <net/inet_sock.h> | ||||
| 
 | ||||
| @ -31,7 +32,7 @@ struct nfs_callback_data { | ||||
| }; | ||||
| 
 | ||||
| static struct nfs_callback_data nfs_callback_info; | ||||
| static DECLARE_MUTEX(nfs_callback_sema); | ||||
| static DEFINE_MUTEX(nfs_callback_mutex); | ||||
| static struct svc_program nfs4_callback_program; | ||||
| 
 | ||||
| unsigned int nfs_callback_set_tcpport; | ||||
| @ -95,7 +96,7 @@ int nfs_callback_up(void) | ||||
| 	int ret = 0; | ||||
| 
 | ||||
| 	lock_kernel(); | ||||
| 	down(&nfs_callback_sema); | ||||
| 	mutex_lock(&nfs_callback_mutex); | ||||
| 	if (nfs_callback_info.users++ || nfs_callback_info.pid != 0) | ||||
| 		goto out; | ||||
| 	init_completion(&nfs_callback_info.started); | ||||
| @ -121,7 +122,7 @@ int nfs_callback_up(void) | ||||
| 	nfs_callback_info.serv = serv; | ||||
| 	wait_for_completion(&nfs_callback_info.started); | ||||
| out: | ||||
| 	up(&nfs_callback_sema); | ||||
| 	mutex_unlock(&nfs_callback_mutex); | ||||
| 	unlock_kernel(); | ||||
| 	return ret; | ||||
| out_destroy: | ||||
| @ -139,7 +140,7 @@ int nfs_callback_down(void) | ||||
| 	int ret = 0; | ||||
| 
 | ||||
| 	lock_kernel(); | ||||
| 	down(&nfs_callback_sema); | ||||
| 	mutex_lock(&nfs_callback_mutex); | ||||
| 	nfs_callback_info.users--; | ||||
| 	do { | ||||
| 		if (nfs_callback_info.users != 0 || nfs_callback_info.pid == 0) | ||||
| @ -147,7 +148,7 @@ int nfs_callback_down(void) | ||||
| 		if (kill_proc(nfs_callback_info.pid, SIGKILL, 1) < 0) | ||||
| 			break; | ||||
| 	} while (wait_for_completion_timeout(&nfs_callback_info.stopped, 5*HZ) == 0); | ||||
| 	up(&nfs_callback_sema); | ||||
| 	mutex_unlock(&nfs_callback_mutex); | ||||
| 	unlock_kernel(); | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| @ -49,6 +49,7 @@ | ||||
| #include <linux/nfsd/state.h> | ||||
| #include <linux/nfsd/xdr4.h> | ||||
| #include <linux/namei.h> | ||||
| #include <linux/mutex.h> | ||||
| 
 | ||||
| #define NFSDDBG_FACILITY                NFSDDBG_PROC | ||||
| 
 | ||||
| @ -77,11 +78,11 @@ static void nfs4_set_recdir(char *recdir); | ||||
| 
 | ||||
| /* Locking:
 | ||||
|  * | ||||
|  * client_sema:  | ||||
|  * client_mutex: | ||||
|  * 	protects clientid_hashtbl[], clientstr_hashtbl[], | ||||
|  * 	unconfstr_hashtbl[], uncofid_hashtbl[]. | ||||
|  */ | ||||
| static DECLARE_MUTEX(client_sema); | ||||
| static DEFINE_MUTEX(client_mutex); | ||||
| 
 | ||||
| static kmem_cache_t *stateowner_slab = NULL; | ||||
| static kmem_cache_t *file_slab = NULL; | ||||
| @ -91,13 +92,13 @@ static kmem_cache_t *deleg_slab = NULL; | ||||
| void | ||||
| nfs4_lock_state(void) | ||||
| { | ||||
| 	down(&client_sema); | ||||
| 	mutex_lock(&client_mutex); | ||||
| } | ||||
| 
 | ||||
| void | ||||
| nfs4_unlock_state(void) | ||||
| { | ||||
| 	up(&client_sema); | ||||
| 	mutex_unlock(&client_mutex); | ||||
| } | ||||
| 
 | ||||
| static inline u32 | ||||
|  | ||||
| @ -6,7 +6,7 @@ | ||||
| #include <linux/vmalloc.h> | ||||
| #include <linux/genhd.h> | ||||
| #include <linux/bitops.h> | ||||
| #include <asm/semaphore.h> | ||||
| #include <linux/mutex.h> | ||||
| 
 | ||||
| 
 | ||||
| struct unique_numspace { | ||||
| @ -16,7 +16,7 @@ struct unique_numspace { | ||||
| 	struct semaphore  mutex; | ||||
| }; | ||||
| 
 | ||||
| static DECLARE_MUTEX(numspace_mutex); | ||||
| static DEFINE_MUTEX(numspace_mutex); | ||||
| 
 | ||||
| static int expand_numspace(struct unique_numspace *s) | ||||
| { | ||||
| @ -48,7 +48,7 @@ static int alloc_unique_number(struct unique_numspace *s) | ||||
| { | ||||
| 	int rval = 0; | ||||
| 
 | ||||
| 	down(&numspace_mutex); | ||||
| 	mutex_lock(&numspace_mutex); | ||||
| 	if (s->num_free < 1) | ||||
| 		rval = expand_numspace(s); | ||||
| 	if (!rval) { | ||||
| @ -56,7 +56,7 @@ static int alloc_unique_number(struct unique_numspace *s) | ||||
| 		--s->num_free; | ||||
| 		__set_bit(rval, s->bits); | ||||
| 	} | ||||
| 	up(&numspace_mutex); | ||||
| 	mutex_unlock(&numspace_mutex); | ||||
| 
 | ||||
| 	return rval; | ||||
| } | ||||
| @ -66,11 +66,11 @@ static void dealloc_unique_number(struct unique_numspace *s, int number) | ||||
| 	int old_val; | ||||
| 
 | ||||
| 	if (number >= 0) { | ||||
| 		down(&numspace_mutex); | ||||
| 		mutex_lock(&numspace_mutex); | ||||
| 		old_val = __test_and_clear_bit(number, s->bits); | ||||
| 		if (old_val) | ||||
| 			++s->num_free; | ||||
| 		up(&numspace_mutex); | ||||
| 		mutex_unlock(&numspace_mutex); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -37,6 +37,7 @@ | ||||
| #include <linux/writeback.h>		/* for the emergency remount stuff */ | ||||
| #include <linux/idr.h> | ||||
| #include <linux/kobject.h> | ||||
| #include <linux/mutex.h> | ||||
| #include <asm/uaccess.h> | ||||
| 
 | ||||
| 
 | ||||
| @ -380,9 +381,9 @@ restart: | ||||
| void sync_filesystems(int wait) | ||||
| { | ||||
| 	struct super_block *sb; | ||||
| 	static DECLARE_MUTEX(mutex); | ||||
| 	static DEFINE_MUTEX(mutex); | ||||
| 
 | ||||
| 	down(&mutex);		/* Could be down_interruptible */ | ||||
| 	mutex_lock(&mutex);		/* Could be down_interruptible */ | ||||
| 	spin_lock(&sb_lock); | ||||
| 	list_for_each_entry(sb, &super_blocks, s_list) { | ||||
| 		if (!sb->s_op->sync_fs) | ||||
| @ -411,7 +412,7 @@ restart: | ||||
| 			goto restart; | ||||
| 	} | ||||
| 	spin_unlock(&sb_lock); | ||||
| 	up(&mutex); | ||||
| 	mutex_unlock(&mutex); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user