Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Ingo Molnar and committed by
Linus Torvalds
353ab6e9 e655a250

+99 -89
+16 -15
fs/cramfs/inode.c
··· 22 22 #include <linux/cramfs_fs_sb.h> 23 23 #include <linux/buffer_head.h> 24 24 #include <linux/vfs.h> 25 + #include <linux/mutex.h> 25 26 #include <asm/semaphore.h> 26 27 27 28 #include <asm/uaccess.h> ··· 32 31 static struct file_operations cramfs_directory_operations; 33 32 static struct address_space_operations cramfs_aops; 34 33 35 - static DECLARE_MUTEX(read_mutex); 34 + static DEFINE_MUTEX(read_mutex); 36 35 37 36 38 37 /* These two macros may change in future, to provide better st_ino ··· 251 250 memset(sbi, 0, sizeof(struct cramfs_sb_info)); 252 251 253 252 /* Invalidate the read buffers on mount: think disk change.. */ 254 - down(&read_mutex); 253 + mutex_lock(&read_mutex); 255 254 for (i = 0; i < READ_BUFFERS; i++) 256 255 buffer_blocknr[i] = -1; 257 256 258 257 /* Read the first block and get the superblock from it */ 259 258 memcpy(&super, cramfs_read(sb, 0, sizeof(super)), sizeof(super)); 260 - up(&read_mutex); 259 + mutex_unlock(&read_mutex); 261 260 262 261 /* Do sanity checks on the superblock */ 263 262 if (super.magic != CRAMFS_MAGIC) { 264 263 /* check at 512 byte offset */ 265 - down(&read_mutex); 264 + mutex_lock(&read_mutex); 266 265 memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super)); 267 - up(&read_mutex); 266 + mutex_unlock(&read_mutex); 268 267 if (super.magic != CRAMFS_MAGIC) { 269 268 if (!silent) 270 269 printk(KERN_ERR "cramfs: wrong magic\n"); ··· 367 366 mode_t mode; 368 367 int namelen, error; 369 368 370 - down(&read_mutex); 369 + mutex_lock(&read_mutex); 371 370 de = cramfs_read(sb, OFFSET(inode) + offset, sizeof(*de)+256); 372 371 name = (char *)(de+1); 373 372 ··· 380 379 memcpy(buf, name, namelen); 381 380 ino = CRAMINO(de); 382 381 mode = de->mode; 383 - up(&read_mutex); 382 + mutex_unlock(&read_mutex); 384 383 nextoffset = offset + sizeof(*de) + namelen; 385 384 for (;;) { 386 385 if (!namelen) { ··· 411 410 unsigned int offset = 0; 412 411 int sorted; 413 412 414 - down(&read_mutex); 413 + mutex_lock(&read_mutex); 415 414 sorted = CRAMFS_SB(dir->i_sb)->flags & CRAMFS_FLAG_SORTED_DIRS; 416 415 while (offset < dir->i_size) { 417 416 struct cramfs_inode *de; ··· 434 433 435 434 for (;;) { 436 435 if (!namelen) { 437 - up(&read_mutex); 436 + mutex_unlock(&read_mutex); 438 437 return ERR_PTR(-EIO); 439 438 } 440 439 if (name[namelen-1]) ··· 448 447 continue; 449 448 if (!retval) { 450 449 struct cramfs_inode entry = *de; 451 - up(&read_mutex); 450 + mutex_unlock(&read_mutex); 452 451 d_add(dentry, get_cramfs_inode(dir->i_sb, &entry)); 453 452 return NULL; 454 453 } ··· 456 455 if (sorted) 457 456 break; 458 457 } 459 - up(&read_mutex); 458 + mutex_unlock(&read_mutex); 460 459 d_add(dentry, NULL); 461 460 return NULL; 462 461 } ··· 475 474 u32 start_offset, compr_len; 476 475 477 476 start_offset = OFFSET(inode) + maxblock*4; 478 - down(&read_mutex); 477 + mutex_lock(&read_mutex); 479 478 if (page->index) 480 479 start_offset = *(u32 *) cramfs_read(sb, blkptr_offset-4, 4); 481 480 compr_len = (*(u32 *) cramfs_read(sb, blkptr_offset, 4) - start_offset); 482 - up(&read_mutex); 481 + mutex_unlock(&read_mutex); 483 482 pgdata = kmap(page); 484 483 if (compr_len == 0) 485 484 ; /* hole */ 486 485 else { 487 - down(&read_mutex); 486 + mutex_lock(&read_mutex); 488 487 bytes_filled = cramfs_uncompress_block(pgdata, 489 488 PAGE_CACHE_SIZE, 490 489 cramfs_read(sb, start_offset, compr_len), 491 490 compr_len); 492 - up(&read_mutex); 491 + mutex_unlock(&read_mutex); 493 492 } 494 493 } else 495 494 pgdata = kmap(page);
+10 -9
fs/dcookies.c
··· 23 23 #include <linux/mm.h> 24 24 #include <linux/errno.h> 25 25 #include <linux/dcookies.h> 26 + #include <linux/mutex.h> 26 27 #include <asm/uaccess.h> 27 28 28 29 /* The dcookies are allocated from a kmem_cache and ··· 37 36 }; 38 37 39 38 static LIST_HEAD(dcookie_users); 40 - static DECLARE_MUTEX(dcookie_sem); 39 + static DEFINE_MUTEX(dcookie_mutex); 41 40 static kmem_cache_t * dcookie_cache; 42 41 static struct list_head * dcookie_hashtable; 43 42 static size_t hash_size; ··· 115 114 int err = 0; 116 115 struct dcookie_struct * dcs; 117 116 118 - down(&dcookie_sem); 117 + mutex_lock(&dcookie_mutex); 119 118 120 119 if (!is_live()) { 121 120 err = -EINVAL; ··· 135 134 *cookie = dcookie_value(dcs); 136 135 137 136 out: 138 - up(&dcookie_sem); 137 + mutex_unlock(&dcookie_mutex); 139 138 return err; 140 139 } 141 140 ··· 158 157 if (!capable(CAP_SYS_ADMIN)) 159 158 return -EPERM; 160 159 161 - down(&dcookie_sem); 160 + mutex_lock(&dcookie_mutex); 162 161 163 162 if (!is_live()) { 164 163 err = -EINVAL; ··· 193 192 out_free: 194 193 kfree(kbuf); 195 194 out: 196 - up(&dcookie_sem); 195 + mutex_unlock(&dcookie_mutex); 197 196 return err; 198 197 } 199 198 ··· 291 290 { 292 291 struct dcookie_user * user; 293 292 294 - down(&dcookie_sem); 293 + mutex_lock(&dcookie_mutex); 295 294 296 295 user = kmalloc(sizeof(struct dcookie_user), GFP_KERNEL); 297 296 if (!user) ··· 303 302 list_add(&user->next, &dcookie_users); 304 303 305 304 out: 306 - up(&dcookie_sem); 305 + mutex_unlock(&dcookie_mutex); 307 306 return user; 308 307 out_free: 309 308 kfree(user); ··· 314 313 315 314 void dcookie_unregister(struct dcookie_user * user) 316 315 { 317 - down(&dcookie_sem); 316 + mutex_lock(&dcookie_mutex); 318 317 319 318 list_del(&user->next); 320 319 kfree(user); ··· 322 321 if (!is_live()) 323 322 dcookie_exit(); 324 323 325 - up(&dcookie_sem); 324 + mutex_unlock(&dcookie_mutex); 326 325 } 327 326 328 327 EXPORT_SYMBOL_GPL(dcookie_register);
+10 -9
fs/jffs2/compr_zlib.c
··· 33 33 */ 34 34 #define STREAM_END_SPACE 12 35 35 36 - static DECLARE_MUTEX(deflate_sem); 37 - static DECLARE_MUTEX(inflate_sem); 36 + static DEFINE_MUTEX(deflate_mutex); 37 + static DEFINE_MUTEX(inflate_mutex); 38 38 static z_stream inf_strm, def_strm; 39 39 40 40 #ifdef __KERNEL__ /* Linux-only */ 41 41 #include <linux/vmalloc.h> 42 42 #include <linux/init.h> 43 + #include <linux/mutex.h> 43 44 44 45 static int __init alloc_workspaces(void) 45 46 { ··· 80 79 if (*dstlen <= STREAM_END_SPACE) 81 80 return -1; 82 81 83 - down(&deflate_sem); 82 + mutex_lock(&deflate_mutex); 84 83 85 84 if (Z_OK != zlib_deflateInit(&def_strm, 3)) { 86 85 printk(KERN_WARNING "deflateInit failed\n"); 87 - up(&deflate_sem); 86 + mutex_unlock(&deflate_mutex); 88 87 return -1; 89 88 } 90 89 ··· 105 104 if (ret != Z_OK) { 106 105 D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret)); 107 106 zlib_deflateEnd(&def_strm); 108 - up(&deflate_sem); 107 + mutex_unlock(&deflate_mutex); 109 108 return -1; 110 109 } 111 110 } ··· 134 133 *sourcelen = def_strm.total_in; 135 134 ret = 0; 136 135 out: 137 - up(&deflate_sem); 136 + mutex_unlock(&deflate_mutex); 138 137 return ret; 139 138 } 140 139 ··· 146 145 int ret; 147 146 int wbits = MAX_WBITS; 148 147 149 - down(&inflate_sem); 148 + mutex_lock(&inflate_mutex); 150 149 151 150 inf_strm.next_in = data_in; 152 151 inf_strm.avail_in = srclen; ··· 174 173 175 174 if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) { 176 175 printk(KERN_WARNING "inflateInit failed\n"); 177 - up(&inflate_sem); 176 + mutex_unlock(&inflate_mutex); 178 177 return 1; 179 178 } 180 179 ··· 184 183 printk(KERN_NOTICE "inflate returned %d\n", ret); 185 184 } 186 185 zlib_inflateEnd(&inf_strm); 187 - up(&inflate_sem); 186 + mutex_unlock(&inflate_mutex); 188 187 return 0; 189 188 } 190 189
+14 -13
fs/jfs/jfs_logmgr.c
··· 69 69 #include <linux/bio.h> 70 70 #include <linux/suspend.h> 71 71 #include <linux/delay.h> 72 + #include <linux/mutex.h> 72 73 #include "jfs_incore.h" 73 74 #include "jfs_filsys.h" 74 75 #include "jfs_metapage.h" ··· 166 165 */ 167 166 static LIST_HEAD(jfs_external_logs); 168 167 static struct jfs_log *dummy_log = NULL; 169 - static DECLARE_MUTEX(jfs_log_sem); 168 + static DEFINE_MUTEX(jfs_log_mutex); 170 169 171 170 /* 172 171 * forward references ··· 1086 1085 if (sbi->mntflag & JFS_INLINELOG) 1087 1086 return open_inline_log(sb); 1088 1087 1089 - down(&jfs_log_sem); 1088 + mutex_lock(&jfs_log_mutex); 1090 1089 list_for_each_entry(log, &jfs_external_logs, journal_list) { 1091 1090 if (log->bdev->bd_dev == sbi->logdev) { 1092 1091 if (memcmp(log->uuid, sbi->loguuid, 1093 1092 sizeof(log->uuid))) { 1094 1093 jfs_warn("wrong uuid on JFS journal\n"); 1095 - up(&jfs_log_sem); 1094 + mutex_unlock(&jfs_log_mutex); 1096 1095 return -EINVAL; 1097 1096 } 1098 1097 /* 1099 1098 * add file system to log active file system list 1100 1099 */ 1101 1100 if ((rc = lmLogFileSystem(log, sbi, 1))) { 1102 - up(&jfs_log_sem); 1101 + mutex_unlock(&jfs_log_mutex); 1103 1102 return rc; 1104 1103 } 1105 1104 goto journal_found; ··· 1107 1106 } 1108 1107 1109 1108 if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) { 1110 - up(&jfs_log_sem); 1109 + mutex_unlock(&jfs_log_mutex); 1111 1110 return -ENOMEM; 1112 1111 } 1113 1112 INIT_LIST_HEAD(&log->sb_list); ··· 1152 1151 sbi->log = log; 1153 1152 LOG_UNLOCK(log); 1154 1153 1155 - up(&jfs_log_sem); 1154 + mutex_unlock(&jfs_log_mutex); 1156 1155 return 0; 1157 1156 1158 1157 /* ··· 1169 1168 blkdev_put(bdev); 1170 1169 1171 1170 free: /* free log descriptor */ 1172 - up(&jfs_log_sem); 1171 + mutex_unlock(&jfs_log_mutex); 1173 1172 kfree(log); 1174 1173 1175 1174 jfs_warn("lmLogOpen: exit(%d)", rc); ··· 1213 1212 { 1214 1213 int rc; 1215 1214 1216 - down(&jfs_log_sem); 1215 + mutex_lock(&jfs_log_mutex); 1217 1216 if (!dummy_log) { 1218 1217 dummy_log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL); 1219 1218 if (!dummy_log) { 1220 - up(&jfs_log_sem); 1219 + mutex_unlock(&jfs_log_mutex); 1221 1220 return -ENOMEM; 1222 1221 } 1223 1222 INIT_LIST_HEAD(&dummy_log->sb_list); ··· 1230 1229 if (rc) { 1231 1230 kfree(dummy_log); 1232 1231 dummy_log = NULL; 1233 - up(&jfs_log_sem); 1232 + mutex_unlock(&jfs_log_mutex); 1234 1233 return rc; 1235 1234 } 1236 1235 } ··· 1239 1238 list_add(&JFS_SBI(sb)->log_list, &dummy_log->sb_list); 1240 1239 JFS_SBI(sb)->log = dummy_log; 1241 1240 LOG_UNLOCK(dummy_log); 1242 - up(&jfs_log_sem); 1241 + mutex_unlock(&jfs_log_mutex); 1243 1242 1244 1243 return 0; 1245 1244 } ··· 1467 1466 1468 1467 jfs_info("lmLogClose: log:0x%p", log); 1469 1468 1470 - down(&jfs_log_sem); 1469 + mutex_lock(&jfs_log_mutex); 1471 1470 LOG_LOCK(log); 1472 1471 list_del(&sbi->log_list); 1473 1472 LOG_UNLOCK(log); ··· 1517 1516 kfree(log); 1518 1517 1519 1518 out: 1520 - up(&jfs_log_sem); 1519 + mutex_unlock(&jfs_log_mutex); 1521 1520 jfs_info("lmLogClose: exit(%d)", rc); 1522 1521 return rc; 1523 1522 }
+10 -9
fs/lockd/host.c
··· 16 16 #include <linux/sunrpc/svc.h> 17 17 #include <linux/lockd/lockd.h> 18 18 #include <linux/lockd/sm_inter.h> 19 + #include <linux/mutex.h> 19 20 20 21 21 22 #define NLMDBG_FACILITY NLMDBG_HOSTCACHE ··· 31 30 static struct nlm_host * nlm_hosts[NLM_HOST_NRHASH]; 32 31 static unsigned long next_gc; 33 32 static int nrhosts; 34 - static DECLARE_MUTEX(nlm_host_sema); 33 + static DEFINE_MUTEX(nlm_host_mutex); 35 34 36 35 37 36 static void nlm_gc_hosts(void); ··· 72 71 hash = NLM_ADDRHASH(sin->sin_addr.s_addr); 73 72 74 73 /* Lock hash table */ 75 - down(&nlm_host_sema); 74 + mutex_lock(&nlm_host_mutex); 76 75 77 76 if (time_after_eq(jiffies, next_gc)) 78 77 nlm_gc_hosts(); ··· 92 91 nlm_hosts[hash] = host; 93 92 } 94 93 nlm_get_host(host); 95 - up(&nlm_host_sema); 94 + mutex_unlock(&nlm_host_mutex); 96 95 return host; 97 96 } 98 97 } ··· 131 130 next_gc = 0; 132 131 133 132 nohost: 134 - up(&nlm_host_sema); 133 + mutex_unlock(&nlm_host_mutex); 135 134 return host; 136 135 } 137 136 ··· 142 141 * and return it 143 142 */ 144 143 int hash; 145 - down(&nlm_host_sema); 144 + mutex_lock(&nlm_host_mutex); 146 145 for (hash = 0 ; hash < NLM_HOST_NRHASH; hash++) { 147 146 struct nlm_host *host, **hp; 148 147 for (hp = &nlm_hosts[hash]; (host = *hp) != 0; hp = &host->h_next) { 149 148 if (host->h_server && 150 149 host->h_killed == 0) { 151 150 nlm_get_host(host); 152 - up(&nlm_host_sema); 151 + mutex_unlock(&nlm_host_mutex); 153 152 return host; 154 153 } 155 154 } 156 155 } 157 - up(&nlm_host_sema); 156 + mutex_unlock(&nlm_host_mutex); 158 157 return NULL; 159 158 } 160 159 ··· 266 265 int i; 267 266 268 267 dprintk("lockd: shutting down host module\n"); 269 - down(&nlm_host_sema); 268 + mutex_lock(&nlm_host_mutex); 270 269 271 270 /* First, make all hosts eligible for gc */ 272 271 dprintk("lockd: nuking all hosts...\n"); ··· 277 276 278 277 /* Then, perform a garbage collection pass */ 279 278 nlm_gc_hosts(); 280 - up(&nlm_host_sema); 279 + mutex_unlock(&nlm_host_mutex); 281 280 282 281 /* complain if any hosts are left */ 283 282 if (nrhosts) {
+9 -8
fs/lockd/svc.c
··· 25 25 #include <linux/slab.h> 26 26 #include <linux/smp.h> 27 27 #include <linux/smp_lock.h> 28 + #include <linux/mutex.h> 28 29 29 30 #include <linux/sunrpc/types.h> 30 31 #include <linux/sunrpc/stats.h> ··· 44 43 struct nlmsvc_binding * nlmsvc_ops; 45 44 EXPORT_SYMBOL(nlmsvc_ops); 46 45 47 - static DECLARE_MUTEX(nlmsvc_sema); 46 + static DEFINE_MUTEX(nlmsvc_mutex); 48 47 static unsigned int nlmsvc_users; 49 48 static pid_t nlmsvc_pid; 50 49 int nlmsvc_grace_period; 51 50 unsigned long nlmsvc_timeout; 52 51 53 - static DECLARE_MUTEX_LOCKED(lockd_start); 52 + static DECLARE_COMPLETION(lockd_start_done); 54 53 static DECLARE_WAIT_QUEUE_HEAD(lockd_exit); 55 54 56 55 /* ··· 113 112 * Let our maker know we're running. 114 113 */ 115 114 nlmsvc_pid = current->pid; 116 - up(&lockd_start); 115 + complete(&lockd_start_done); 117 116 118 117 daemonize("lockd"); 119 118 ··· 216 215 struct svc_serv * serv; 217 216 int error = 0; 218 217 219 - down(&nlmsvc_sema); 218 + mutex_lock(&nlmsvc_mutex); 220 219 /* 221 220 * Unconditionally increment the user count ... this is 222 221 * the number of clients who _want_ a lockd process. ··· 264 263 "lockd_up: create thread failed, error=%d\n", error); 265 264 goto destroy_and_out; 266 265 } 267 - down(&lockd_start); 266 + wait_for_completion(&lockd_start_done); 268 267 269 268 /* 270 269 * Note: svc_serv structures have an initial use count of 1, ··· 273 272 destroy_and_out: 274 273 svc_destroy(serv); 275 274 out: 276 - up(&nlmsvc_sema); 275 + mutex_unlock(&nlmsvc_mutex); 277 276 return error; 278 277 } 279 278 EXPORT_SYMBOL(lockd_up); ··· 286 285 { 287 286 static int warned; 288 287 289 - down(&nlmsvc_sema); 288 + mutex_lock(&nlmsvc_mutex); 290 289 if (nlmsvc_users) { 291 290 if (--nlmsvc_users) 292 291 goto out; ··· 316 315 recalc_sigpending(); 317 316 spin_unlock_irq(&current->sighand->siglock); 318 317 out: 319 - up(&nlmsvc_sema); 318 + mutex_unlock(&nlmsvc_mutex); 320 319 } 321 320 EXPORT_SYMBOL(lockd_down); 322 321
+9 -8
fs/lockd/svcsubs.c
··· 11 11 #include <linux/string.h> 12 12 #include <linux/time.h> 13 13 #include <linux/in.h> 14 + #include <linux/mutex.h> 14 15 #include <linux/sunrpc/svc.h> 15 16 #include <linux/sunrpc/clnt.h> 16 17 #include <linux/nfsd/nfsfh.h> ··· 29 28 #define FILE_HASH_BITS 5 30 29 #define FILE_NRHASH (1<<FILE_HASH_BITS) 31 30 static struct nlm_file * nlm_files[FILE_NRHASH]; 32 - static DECLARE_MUTEX(nlm_file_sema); 31 + static DEFINE_MUTEX(nlm_file_mutex); 33 32 34 33 #ifdef NFSD_DEBUG 35 34 static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f) ··· 92 91 hash = file_hash(f); 93 92 94 93 /* Lock file table */ 95 - down(&nlm_file_sema); 94 + mutex_lock(&nlm_file_mutex); 96 95 97 96 for (file = nlm_files[hash]; file; file = file->f_next) 98 97 if (!nfs_compare_fh(&file->f_handle, f)) ··· 131 130 nfserr = 0; 132 131 133 132 out_unlock: 134 - up(&nlm_file_sema); 133 + mutex_unlock(&nlm_file_mutex); 135 134 return nfserr; 136 135 137 136 out_free: ··· 240 239 struct nlm_file *file, **fp; 241 240 int i; 242 241 243 - down(&nlm_file_sema); 242 + mutex_lock(&nlm_file_mutex); 244 243 for (i = 0; i < FILE_NRHASH; i++) { 245 244 fp = nlm_files + i; 246 245 while ((file = *fp) != NULL) { 247 246 /* Traverse locks, blocks and shares of this file 248 247 * and update file->f_locks count */ 249 248 if (nlm_inspect_file(host, file, action)) { 250 - up(&nlm_file_sema); 249 + mutex_unlock(&nlm_file_mutex); 251 250 return 1; 252 251 } 253 252 ··· 262 261 } 263 262 } 264 263 } 265 - up(&nlm_file_sema); 264 + mutex_unlock(&nlm_file_mutex); 266 265 return 0; 267 266 } 268 267 ··· 282 281 file, file->f_count); 283 282 284 283 /* Lock file table */ 285 - down(&nlm_file_sema); 284 + mutex_lock(&nlm_file_mutex); 286 285 287 286 /* If there are no more locks etc, delete the file */ 288 287 if(--file->f_count == 0) { ··· 290 289 nlm_delete_file(file); 291 290 } 292 291 293 - up(&nlm_file_sema); 292 + mutex_unlock(&nlm_file_mutex); 294 293 } 295 294 296 295 /*
+6 -5
fs/nfs/callback.c
··· 14 14 #include <linux/sunrpc/svc.h> 15 15 #include <linux/sunrpc/svcsock.h> 16 16 #include <linux/nfs_fs.h> 17 + #include <linux/mutex.h> 17 18 18 19 #include <net/inet_sock.h> 19 20 ··· 32 31 }; 33 32 34 33 static struct nfs_callback_data nfs_callback_info; 35 - static DECLARE_MUTEX(nfs_callback_sema); 34 + static DEFINE_MUTEX(nfs_callback_mutex); 36 35 static struct svc_program nfs4_callback_program; 37 36 38 37 unsigned int nfs_callback_set_tcpport; ··· 96 95 int ret = 0; 97 96 98 97 lock_kernel(); 99 - down(&nfs_callback_sema); 98 + mutex_lock(&nfs_callback_mutex); 100 99 if (nfs_callback_info.users++ || nfs_callback_info.pid != 0) 101 100 goto out; 102 101 init_completion(&nfs_callback_info.started); ··· 122 121 nfs_callback_info.serv = serv; 123 122 wait_for_completion(&nfs_callback_info.started); 124 123 out: 125 - up(&nfs_callback_sema); 124 + mutex_unlock(&nfs_callback_mutex); 126 125 unlock_kernel(); 127 126 return ret; 128 127 out_destroy: ··· 140 139 int ret = 0; 141 140 142 141 lock_kernel(); 143 - down(&nfs_callback_sema); 142 + mutex_lock(&nfs_callback_mutex); 144 143 nfs_callback_info.users--; 145 144 do { 146 145 if (nfs_callback_info.users != 0 || nfs_callback_info.pid == 0) ··· 148 147 if (kill_proc(nfs_callback_info.pid, SIGKILL, 1) < 0) 149 148 break; 150 149 } while (wait_for_completion_timeout(&nfs_callback_info.stopped, 5*HZ) == 0); 151 - up(&nfs_callback_sema); 150 + mutex_unlock(&nfs_callback_mutex); 152 151 unlock_kernel(); 153 152 return ret; 154 153 }
+5 -4
fs/nfsd/nfs4state.c
··· 49 49 #include <linux/nfsd/state.h> 50 50 #include <linux/nfsd/xdr4.h> 51 51 #include <linux/namei.h> 52 + #include <linux/mutex.h> 52 53 53 54 #define NFSDDBG_FACILITY NFSDDBG_PROC 54 55 ··· 78 77 79 78 /* Locking: 80 79 * 81 - * client_sema: 80 + * client_mutex: 82 81 * protects clientid_hashtbl[], clientstr_hashtbl[], 83 82 * unconfstr_hashtbl[], uncofid_hashtbl[]. 84 83 */ 85 - static DECLARE_MUTEX(client_sema); 84 + static DEFINE_MUTEX(client_mutex); 86 85 87 86 static kmem_cache_t *stateowner_slab = NULL; 88 87 static kmem_cache_t *file_slab = NULL; ··· 92 91 void 93 92 nfs4_lock_state(void) 94 93 { 95 - down(&client_sema); 94 + mutex_lock(&client_mutex); 96 95 } 97 96 98 97 void 99 98 nfs4_unlock_state(void) 100 99 { 101 - up(&client_sema); 100 + mutex_unlock(&client_mutex); 102 101 } 103 102 104 103 static inline u32
+6 -6
fs/partitions/devfs.c
··· 6 6 #include <linux/vmalloc.h> 7 7 #include <linux/genhd.h> 8 8 #include <linux/bitops.h> 9 - #include <asm/semaphore.h> 9 + #include <linux/mutex.h> 10 10 11 11 12 12 struct unique_numspace { ··· 16 16 struct semaphore mutex; 17 17 }; 18 18 19 - static DECLARE_MUTEX(numspace_mutex); 19 + static DEFINE_MUTEX(numspace_mutex); 20 20 21 21 static int expand_numspace(struct unique_numspace *s) 22 22 { ··· 48 48 { 49 49 int rval = 0; 50 50 51 - down(&numspace_mutex); 51 + mutex_lock(&numspace_mutex); 52 52 if (s->num_free < 1) 53 53 rval = expand_numspace(s); 54 54 if (!rval) { ··· 56 56 --s->num_free; 57 57 __set_bit(rval, s->bits); 58 58 } 59 - up(&numspace_mutex); 59 + mutex_unlock(&numspace_mutex); 60 60 61 61 return rval; 62 62 } ··· 66 66 int old_val; 67 67 68 68 if (number >= 0) { 69 - down(&numspace_mutex); 69 + mutex_lock(&numspace_mutex); 70 70 old_val = __test_and_clear_bit(number, s->bits); 71 71 if (old_val) 72 72 ++s->num_free; 73 - up(&numspace_mutex); 73 + mutex_unlock(&numspace_mutex); 74 74 } 75 75 } 76 76
+4 -3
fs/super.c
··· 37 37 #include <linux/writeback.h> /* for the emergency remount stuff */ 38 38 #include <linux/idr.h> 39 39 #include <linux/kobject.h> 40 + #include <linux/mutex.h> 40 41 #include <asm/uaccess.h> 41 42 42 43 ··· 381 380 void sync_filesystems(int wait) 382 381 { 383 382 struct super_block *sb; 384 - static DECLARE_MUTEX(mutex); 383 + static DEFINE_MUTEX(mutex); 385 384 386 - down(&mutex); /* Could be down_interruptible */ 385 + mutex_lock(&mutex); /* Could be down_interruptible */ 387 386 spin_lock(&sb_lock); 388 387 list_for_each_entry(sb, &super_blocks, s_list) { 389 388 if (!sb->s_op->sync_fs) ··· 412 411 goto restart; 413 412 } 414 413 spin_unlock(&sb_lock); 415 - up(&mutex); 414 + mutex_unlock(&mutex); 416 415 } 417 416 418 417 /**