aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2006-01-09 18:59:24 -0500
committerIngo Molnar <mingo@hera.kernel.org>2006-01-09 18:59:24 -0500
commit1b1dcc1b57a49136f118a0f16367256ff9994a69 (patch)
treeb0b36d4f41d28c9d6514fb309d33c1a084d6309b /fs
parent794ee1baee1c26be40410233e6c20bceb2b03c08 (diff)
[PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem
This patch converts the inode semaphore to a mutex. I have tested it on XFS and compiled as much as one can consider on an ia64. Anyway your luck with it might be different. Modified-by: Ingo Molnar <mingo@elte.hu> (finished the conversion) Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs')
-rw-r--r--fs/affs/inode.c4
-rw-r--r--fs/autofs/root.c4
-rw-r--r--fs/autofs4/root.c4
-rw-r--r--fs/binfmt_misc.c12
-rw-r--r--fs/block_dev.c4
-rw-r--r--fs/buffer.c6
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/cifs/inode.c8
-rw-r--r--fs/coda/dir.c4
-rw-r--r--fs/coda/file.c8
-rw-r--r--fs/configfs/dir.c54
-rw-r--r--fs/configfs/file.c4
-rw-r--r--fs/configfs/inode.c6
-rw-r--r--fs/debugfs/inode.c8
-rw-r--r--fs/devfs/base.c22
-rw-r--r--fs/devpts/inode.c8
-rw-r--r--fs/direct-io.c30
-rw-r--r--fs/dquot.c16
-rw-r--r--fs/exportfs/expfs.c12
-rw-r--r--fs/ext2/acl.c10
-rw-r--r--fs/ext2/ext2.h2
-rw-r--r--fs/ext2/super.c4
-rw-r--r--fs/ext2/xattr.c2
-rw-r--r--fs/ext3/acl.c10
-rw-r--r--fs/ext3/super.c4
-rw-r--r--fs/ext3/xattr.c2
-rw-r--r--fs/fat/dir.c4
-rw-r--r--fs/fat/file.c4
-rw-r--r--fs/fifo.c6
-rw-r--r--fs/fuse/file.c4
-rw-r--r--fs/hfs/inode.c4
-rw-r--r--fs/hfsplus/bitmap.c8
-rw-r--r--fs/hfsplus/inode.c4
-rw-r--r--fs/hpfs/dir.c6
-rw-r--r--fs/hppfs/hppfs_kern.c6
-rw-r--r--fs/hugetlbfs/inode.c4
-rw-r--r--fs/inode.c2
-rw-r--r--fs/jffs/inode-v23.c2
-rw-r--r--fs/jfs/jfs_incore.h4
-rw-r--r--fs/libfs.c8
-rw-r--r--fs/namei.c82
-rw-r--r--fs/namespace.c12
-rw-r--r--fs/nfs/dir.c10
-rw-r--r--fs/nfsd/nfs4recover.c20
-rw-r--r--fs/nfsd/vfs.c12
-rw-r--r--fs/ntfs/attrib.c4
-rw-r--r--fs/ntfs/dir.c8
-rw-r--r--fs/ntfs/file.c18
-rw-r--r--fs/ntfs/index.c6
-rw-r--r--fs/ntfs/inode.c8
-rw-r--r--fs/ntfs/namei.c6
-rw-r--r--fs/ntfs/quota.c6
-rw-r--r--fs/ntfs/super.c16
-rw-r--r--fs/ocfs2/alloc.c24
-rw-r--r--fs/ocfs2/cluster/nodemanager.c2
-rw-r--r--fs/ocfs2/dir.c4
-rw-r--r--fs/ocfs2/file.c8
-rw-r--r--fs/ocfs2/inode.c12
-rw-r--r--fs/ocfs2/journal.c14
-rw-r--r--fs/ocfs2/localalloc.c6
-rw-r--r--fs/open.c24
-rw-r--r--fs/pipe.c44
-rw-r--r--fs/quota.c6
-rw-r--r--fs/read_write.c4
-rw-r--r--fs/readdir.c4
-rw-r--r--fs/reiserfs/file.c10
-rw-r--r--fs/reiserfs/inode.c14
-rw-r--r--fs/reiserfs/ioctl.c4
-rw-r--r--fs/reiserfs/super.c4
-rw-r--r--fs/reiserfs/tail_conversion.c2
-rw-r--r--fs/reiserfs/xattr.c34
-rw-r--r--fs/reiserfs/xattr_acl.c6
-rw-r--r--fs/relayfs/inode.c12
-rw-r--r--fs/sysfs/dir.c31
-rw-r--r--fs/sysfs/file.c17
-rw-r--r--fs/sysfs/inode.c8
-rw-r--r--fs/sysfs/symlink.c5
-rw-r--r--fs/ufs/super.c6
-rw-r--r--fs/xattr.c8
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c18
-rw-r--r--fs/xfs/xfs_dmapi.h14
82 files changed, 435 insertions, 440 deletions
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 9ebe881c6786..44d439cb69f4 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -244,10 +244,10 @@ affs_put_inode(struct inode *inode)
244 pr_debug("AFFS: put_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink); 244 pr_debug("AFFS: put_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink);
245 affs_free_prealloc(inode); 245 affs_free_prealloc(inode);
246 if (atomic_read(&inode->i_count) == 1) { 246 if (atomic_read(&inode->i_count) == 1) {
247 down(&inode->i_sem); 247 mutex_lock(&inode->i_mutex);
248 if (inode->i_size != AFFS_I(inode)->mmu_private) 248 if (inode->i_size != AFFS_I(inode)->mmu_private)
249 affs_truncate(inode); 249 affs_truncate(inode);
250 up(&inode->i_sem); 250 mutex_unlock(&inode->i_mutex);
251 } 251 }
252} 252}
253 253
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index a1ab1c0ed215..808134a5a2fa 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -229,9 +229,9 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr
229 dentry->d_flags |= DCACHE_AUTOFS_PENDING; 229 dentry->d_flags |= DCACHE_AUTOFS_PENDING;
230 d_add(dentry, NULL); 230 d_add(dentry, NULL);
231 231
232 up(&dir->i_sem); 232 mutex_unlock(&dir->i_mutex);
233 autofs_revalidate(dentry, nd); 233 autofs_revalidate(dentry, nd);
234 down(&dir->i_sem); 234 mutex_lock(&dir->i_mutex);
235 235
236 /* 236 /*
237 * If we are still pending, check if we had to handle 237 * If we are still pending, check if we had to handle
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 2241405ffc41..541b19e6fec9 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -489,9 +489,9 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
489 d_add(dentry, NULL); 489 d_add(dentry, NULL);
490 490
491 if (dentry->d_op && dentry->d_op->d_revalidate) { 491 if (dentry->d_op && dentry->d_op->d_revalidate) {
492 up(&dir->i_sem); 492 mutex_unlock(&dir->i_mutex);
493 (dentry->d_op->d_revalidate)(dentry, nd); 493 (dentry->d_op->d_revalidate)(dentry, nd);
494 down(&dir->i_sem); 494 mutex_lock(&dir->i_mutex);
495 } 495 }
496 496
497 /* 497 /*
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 2568eb41cb3a..9ccc7d8275b8 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -588,11 +588,11 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
588 case 2: set_bit(Enabled, &e->flags); 588 case 2: set_bit(Enabled, &e->flags);
589 break; 589 break;
590 case 3: root = dget(file->f_vfsmnt->mnt_sb->s_root); 590 case 3: root = dget(file->f_vfsmnt->mnt_sb->s_root);
591 down(&root->d_inode->i_sem); 591 mutex_lock(&root->d_inode->i_mutex);
592 592
593 kill_node(e); 593 kill_node(e);
594 594
595 up(&root->d_inode->i_sem); 595 mutex_unlock(&root->d_inode->i_mutex);
596 dput(root); 596 dput(root);
597 break; 597 break;
598 default: return res; 598 default: return res;
@@ -622,7 +622,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
622 return PTR_ERR(e); 622 return PTR_ERR(e);
623 623
624 root = dget(sb->s_root); 624 root = dget(sb->s_root);
625 down(&root->d_inode->i_sem); 625 mutex_lock(&root->d_inode->i_mutex);
626 dentry = lookup_one_len(e->name, root, strlen(e->name)); 626 dentry = lookup_one_len(e->name, root, strlen(e->name));
627 err = PTR_ERR(dentry); 627 err = PTR_ERR(dentry);
628 if (IS_ERR(dentry)) 628 if (IS_ERR(dentry))
@@ -658,7 +658,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
658out2: 658out2:
659 dput(dentry); 659 dput(dentry);
660out: 660out:
661 up(&root->d_inode->i_sem); 661 mutex_unlock(&root->d_inode->i_mutex);
662 dput(root); 662 dput(root);
663 663
664 if (err) { 664 if (err) {
@@ -703,12 +703,12 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
703 case 1: enabled = 0; break; 703 case 1: enabled = 0; break;
704 case 2: enabled = 1; break; 704 case 2: enabled = 1; break;
705 case 3: root = dget(file->f_vfsmnt->mnt_sb->s_root); 705 case 3: root = dget(file->f_vfsmnt->mnt_sb->s_root);
706 down(&root->d_inode->i_sem); 706 mutex_lock(&root->d_inode->i_mutex);
707 707
708 while (!list_empty(&entries)) 708 while (!list_empty(&entries))
709 kill_node(list_entry(entries.next, Node, list)); 709 kill_node(list_entry(entries.next, Node, list));
710 710
711 up(&root->d_inode->i_sem); 711 mutex_unlock(&root->d_inode->i_mutex);
712 dput(root); 712 dput(root);
713 default: return res; 713 default: return res;
714 } 714 }
diff --git a/fs/block_dev.c b/fs/block_dev.c
index e0df94c37b7e..6e50346fb1ee 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -202,7 +202,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
202 loff_t size; 202 loff_t size;
203 loff_t retval; 203 loff_t retval;
204 204
205 down(&bd_inode->i_sem); 205 mutex_lock(&bd_inode->i_mutex);
206 size = i_size_read(bd_inode); 206 size = i_size_read(bd_inode);
207 207
208 switch (origin) { 208 switch (origin) {
@@ -219,7 +219,7 @@ static loff_t block_llseek(struct file *file, loff_t offset, int origin)
219 } 219 }
220 retval = offset; 220 retval = offset;
221 } 221 }
222 up(&bd_inode->i_sem); 222 mutex_unlock(&bd_inode->i_mutex);
223 return retval; 223 return retval;
224} 224}
225 225
diff --git a/fs/buffer.c b/fs/buffer.c
index 55f0975a9b15..6466bc8a3dc7 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -352,11 +352,11 @@ static long do_fsync(unsigned int fd, int datasync)
352 * We need to protect against concurrent writers, 352 * We need to protect against concurrent writers,
353 * which could cause livelocks in fsync_buffers_list 353 * which could cause livelocks in fsync_buffers_list
354 */ 354 */
355 down(&mapping->host->i_sem); 355 mutex_lock(&mapping->host->i_mutex);
356 err = file->f_op->fsync(file, file->f_dentry, datasync); 356 err = file->f_op->fsync(file, file->f_dentry, datasync);
357 if (!ret) 357 if (!ret)
358 ret = err; 358 ret = err;
359 up(&mapping->host->i_sem); 359 mutex_unlock(&mapping->host->i_mutex);
360 err = filemap_fdatawait(mapping); 360 err = filemap_fdatawait(mapping);
361 if (!ret) 361 if (!ret)
362 ret = err; 362 ret = err;
@@ -2338,7 +2338,7 @@ int generic_commit_write(struct file *file, struct page *page,
2338 __block_commit_write(inode,page,from,to); 2338 __block_commit_write(inode,page,from,to);
2339 /* 2339 /*
2340 * No need to use i_size_read() here, the i_size 2340 * No need to use i_size_read() here, the i_size
2341 * cannot change under us because we hold i_sem. 2341 * cannot change under us because we hold i_mutex.
2342 */ 2342 */
2343 if (pos > inode->i_size) { 2343 if (pos > inode->i_size) {
2344 i_size_write(inode, pos); 2344 i_size_write(inode, pos);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 2a13a2bac8f1..e10213b7541e 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -860,9 +860,9 @@ static int cifs_oplock_thread(void * dummyarg)
860 DeleteOplockQEntry(oplock_item); 860 DeleteOplockQEntry(oplock_item);
861 /* can not grab inode sem here since it would 861 /* can not grab inode sem here since it would
862 deadlock when oplock received on delete 862 deadlock when oplock received on delete
863 since vfs_unlink holds the i_sem across 863 since vfs_unlink holds the i_mutex across
864 the call */ 864 the call */
865 /* down(&inode->i_sem);*/ 865 /* mutex_lock(&inode->i_mutex);*/
866 if (S_ISREG(inode->i_mode)) { 866 if (S_ISREG(inode->i_mode)) {
867 rc = filemap_fdatawrite(inode->i_mapping); 867 rc = filemap_fdatawrite(inode->i_mapping);
868 if(CIFS_I(inode)->clientCanCacheRead == 0) { 868 if(CIFS_I(inode)->clientCanCacheRead == 0) {
@@ -871,7 +871,7 @@ static int cifs_oplock_thread(void * dummyarg)
871 } 871 }
872 } else 872 } else
873 rc = 0; 873 rc = 0;
874 /* up(&inode->i_sem);*/ 874 /* mutex_unlock(&inode->i_mutex);*/
875 if (rc) 875 if (rc)
876 CIFS_I(inode)->write_behind_rc = rc; 876 CIFS_I(inode)->write_behind_rc = rc;
877 cFYI(1,("Oplock flush inode %p rc %d",inode,rc)); 877 cFYI(1,("Oplock flush inode %p rc %d",inode,rc));
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 9558f51bca55..3ebce9430f4a 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1040,9 +1040,9 @@ int cifs_revalidate(struct dentry *direntry)
1040 } 1040 }
1041 1041
1042 /* can not grab this sem since kernel filesys locking documentation 1042 /* can not grab this sem since kernel filesys locking documentation
1043 indicates i_sem may be taken by the kernel on lookup and rename 1043 indicates i_mutex may be taken by the kernel on lookup and rename
1044 which could deadlock if we grab the i_sem here as well */ 1044 which could deadlock if we grab the i_mutex here as well */
1045/* down(&direntry->d_inode->i_sem);*/ 1045/* mutex_lock(&direntry->d_inode->i_mutex);*/
1046 /* need to write out dirty pages here */ 1046 /* need to write out dirty pages here */
1047 if (direntry->d_inode->i_mapping) { 1047 if (direntry->d_inode->i_mapping) {
1048 /* do we need to lock inode until after invalidate completes 1048 /* do we need to lock inode until after invalidate completes
@@ -1066,7 +1066,7 @@ int cifs_revalidate(struct dentry *direntry)
1066 } 1066 }
1067 } 1067 }
1068 } 1068 }
1069/* up(&direntry->d_inode->i_sem); */ 1069/* mutex_unlock(&direntry->d_inode->i_mutex); */
1070 1070
1071 kfree(full_path); 1071 kfree(full_path);
1072 FreeXid(xid); 1072 FreeXid(xid);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 2391766e9c7c..8f1a517f8b4e 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -453,7 +453,7 @@ int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir)
453 coda_vfs_stat.readdir++; 453 coda_vfs_stat.readdir++;
454 454
455 host_inode = host_file->f_dentry->d_inode; 455 host_inode = host_file->f_dentry->d_inode;
456 down(&host_inode->i_sem); 456 mutex_lock(&host_inode->i_mutex);
457 host_file->f_pos = coda_file->f_pos; 457 host_file->f_pos = coda_file->f_pos;
458 458
459 if (!host_file->f_op->readdir) { 459 if (!host_file->f_op->readdir) {
@@ -475,7 +475,7 @@ int coda_readdir(struct file *coda_file, void *dirent, filldir_t filldir)
475 } 475 }
476out: 476out:
477 coda_file->f_pos = host_file->f_pos; 477 coda_file->f_pos = host_file->f_pos;
478 up(&host_inode->i_sem); 478 mutex_unlock(&host_inode->i_mutex);
479 479
480 return ret; 480 return ret;
481} 481}
diff --git a/fs/coda/file.c b/fs/coda/file.c
index e6bc022568f3..30b4630bd735 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -77,14 +77,14 @@ coda_file_write(struct file *coda_file, const char __user *buf, size_t count, lo
77 return -EINVAL; 77 return -EINVAL;
78 78
79 host_inode = host_file->f_dentry->d_inode; 79 host_inode = host_file->f_dentry->d_inode;
80 down(&coda_inode->i_sem); 80 mutex_lock(&coda_inode->i_mutex);
81 81
82 ret = host_file->f_op->write(host_file, buf, count, ppos); 82 ret = host_file->f_op->write(host_file, buf, count, ppos);
83 83
84 coda_inode->i_size = host_inode->i_size; 84 coda_inode->i_size = host_inode->i_size;
85 coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9; 85 coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;
86 coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC; 86 coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC;
87 up(&coda_inode->i_sem); 87 mutex_unlock(&coda_inode->i_mutex);
88 88
89 return ret; 89 return ret;
90} 90}
@@ -272,9 +272,9 @@ int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
272 if (host_file->f_op && host_file->f_op->fsync) { 272 if (host_file->f_op && host_file->f_op->fsync) {
273 host_dentry = host_file->f_dentry; 273 host_dentry = host_file->f_dentry;
274 host_inode = host_dentry->d_inode; 274 host_inode = host_dentry->d_inode;
275 down(&host_inode->i_sem); 275 mutex_lock(&host_inode->i_mutex);
276 err = host_file->f_op->fsync(host_file, host_dentry, datasync); 276 err = host_file->f_op->fsync(host_file, host_dentry, datasync);
277 up(&host_inode->i_sem); 277 mutex_unlock(&host_inode->i_mutex);
278 } 278 }
279 279
280 if ( !err && !datasync ) { 280 if ( !err && !datasync ) {
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index e48b539243a1..b668ec61527e 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -288,10 +288,10 @@ static struct dentry * configfs_lookup(struct inode *dir,
288 288
289/* 289/*
290 * Only subdirectories count here. Files (CONFIGFS_NOT_PINNED) are 290 * Only subdirectories count here. Files (CONFIGFS_NOT_PINNED) are
291 * attributes and are removed by rmdir(). We recurse, taking i_sem 291 * attributes and are removed by rmdir(). We recurse, taking i_mutex
292 * on all children that are candidates for default detach. If the 292 * on all children that are candidates for default detach. If the
293 * result is clean, then configfs_detach_group() will handle dropping 293 * result is clean, then configfs_detach_group() will handle dropping
294 * i_sem. If there is an error, the caller will clean up the i_sem 294 * i_mutex. If there is an error, the caller will clean up the i_mutex
295 * holders via configfs_detach_rollback(). 295 * holders via configfs_detach_rollback().
296 */ 296 */
297static int configfs_detach_prep(struct dentry *dentry) 297static int configfs_detach_prep(struct dentry *dentry)
@@ -309,8 +309,8 @@ static int configfs_detach_prep(struct dentry *dentry)
309 if (sd->s_type & CONFIGFS_NOT_PINNED) 309 if (sd->s_type & CONFIGFS_NOT_PINNED)
310 continue; 310 continue;
311 if (sd->s_type & CONFIGFS_USET_DEFAULT) { 311 if (sd->s_type & CONFIGFS_USET_DEFAULT) {
312 down(&sd->s_dentry->d_inode->i_sem); 312 mutex_lock(&sd->s_dentry->d_inode->i_mutex);
313 /* Mark that we've taken i_sem */ 313 /* Mark that we've taken i_mutex */
314 sd->s_type |= CONFIGFS_USET_DROPPING; 314 sd->s_type |= CONFIGFS_USET_DROPPING;
315 315
316 ret = configfs_detach_prep(sd->s_dentry); 316 ret = configfs_detach_prep(sd->s_dentry);
@@ -327,7 +327,7 @@ out:
327} 327}
328 328
329/* 329/*
330 * Walk the tree, dropping i_sem wherever CONFIGFS_USET_DROPPING is 330 * Walk the tree, dropping i_mutex wherever CONFIGFS_USET_DROPPING is
331 * set. 331 * set.
332 */ 332 */
333static void configfs_detach_rollback(struct dentry *dentry) 333static void configfs_detach_rollback(struct dentry *dentry)
@@ -341,7 +341,7 @@ static void configfs_detach_rollback(struct dentry *dentry)
341 341
342 if (sd->s_type & CONFIGFS_USET_DROPPING) { 342 if (sd->s_type & CONFIGFS_USET_DROPPING) {
343 sd->s_type &= ~CONFIGFS_USET_DROPPING; 343 sd->s_type &= ~CONFIGFS_USET_DROPPING;
344 up(&sd->s_dentry->d_inode->i_sem); 344 mutex_unlock(&sd->s_dentry->d_inode->i_mutex);
345 } 345 }
346 } 346 }
347 } 347 }
@@ -424,11 +424,11 @@ static void detach_groups(struct config_group *group)
424 424
425 /* 425 /*
426 * From rmdir/unregister, a configfs_detach_prep() pass 426 * From rmdir/unregister, a configfs_detach_prep() pass
427 * has taken our i_sem for us. Drop it. 427 * has taken our i_mutex for us. Drop it.
428 * From mkdir/register cleanup, there is no sem held. 428 * From mkdir/register cleanup, there is no sem held.
429 */ 429 */
430 if (sd->s_type & CONFIGFS_USET_DROPPING) 430 if (sd->s_type & CONFIGFS_USET_DROPPING)
431 up(&child->d_inode->i_sem); 431 mutex_unlock(&child->d_inode->i_mutex);
432 432
433 d_delete(child); 433 d_delete(child);
434 dput(child); 434 dput(child);
@@ -493,11 +493,11 @@ static int populate_groups(struct config_group *group)
493 /* FYI, we're faking mkdir here 493 /* FYI, we're faking mkdir here
494 * I'm not sure we need this semaphore, as we're called 494 * I'm not sure we need this semaphore, as we're called
495 * from our parent's mkdir. That holds our parent's 495 * from our parent's mkdir. That holds our parent's
496 * i_sem, so afaik lookup cannot continue through our 496 * i_mutex, so afaik lookup cannot continue through our
497 * parent to find us, let alone mess with our tree. 497 * parent to find us, let alone mess with our tree.
498 * That said, taking our i_sem is closer to mkdir 498 * That said, taking our i_mutex is closer to mkdir
499 * emulation, and shouldn't hurt. */ 499 * emulation, and shouldn't hurt. */
500 down(&dentry->d_inode->i_sem); 500 mutex_lock(&dentry->d_inode->i_mutex);
501 501
502 for (i = 0; group->default_groups[i]; i++) { 502 for (i = 0; group->default_groups[i]; i++) {
503 new_group = group->default_groups[i]; 503 new_group = group->default_groups[i];
@@ -507,7 +507,7 @@ static int populate_groups(struct config_group *group)
507 break; 507 break;
508 } 508 }
509 509
510 up(&dentry->d_inode->i_sem); 510 mutex_unlock(&dentry->d_inode->i_mutex);
511 } 511 }
512 512
513 if (ret) 513 if (ret)
@@ -856,7 +856,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name)
856 down_write(&configfs_rename_sem); 856 down_write(&configfs_rename_sem);
857 parent = item->parent->dentry; 857 parent = item->parent->dentry;
858 858
859 down(&parent->d_inode->i_sem); 859 mutex_lock(&parent->d_inode->i_mutex);
860 860
861 new_dentry = lookup_one_len(new_name, parent, strlen(new_name)); 861 new_dentry = lookup_one_len(new_name, parent, strlen(new_name));
862 if (!IS_ERR(new_dentry)) { 862 if (!IS_ERR(new_dentry)) {
@@ -872,7 +872,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name)
872 error = -EEXIST; 872 error = -EEXIST;
873 dput(new_dentry); 873 dput(new_dentry);
874 } 874 }
875 up(&parent->d_inode->i_sem); 875 mutex_unlock(&parent->d_inode->i_mutex);
876 up_write(&configfs_rename_sem); 876 up_write(&configfs_rename_sem);
877 877
878 return error; 878 return error;
@@ -884,9 +884,9 @@ static int configfs_dir_open(struct inode *inode, struct file *file)
884 struct dentry * dentry = file->f_dentry; 884 struct dentry * dentry = file->f_dentry;
885 struct configfs_dirent * parent_sd = dentry->d_fsdata; 885 struct configfs_dirent * parent_sd = dentry->d_fsdata;
886 886
887 down(&dentry->d_inode->i_sem); 887 mutex_lock(&dentry->d_inode->i_mutex);
888 file->private_data = configfs_new_dirent(parent_sd, NULL); 888 file->private_data = configfs_new_dirent(parent_sd, NULL);
889 up(&dentry->d_inode->i_sem); 889 mutex_unlock(&dentry->d_inode->i_mutex);
890 890
891 return file->private_data ? 0 : -ENOMEM; 891 return file->private_data ? 0 : -ENOMEM;
892 892
@@ -897,9 +897,9 @@ static int configfs_dir_close(struct inode *inode, struct file *file)
897 struct dentry * dentry = file->f_dentry; 897 struct dentry * dentry = file->f_dentry;
898 struct configfs_dirent * cursor = file->private_data; 898 struct configfs_dirent * cursor = file->private_data;
899 899
900 down(&dentry->d_inode->i_sem); 900 mutex_lock(&dentry->d_inode->i_mutex);
901 list_del_init(&cursor->s_sibling); 901 list_del_init(&cursor->s_sibling);
902 up(&dentry->d_inode->i_sem); 902 mutex_unlock(&dentry->d_inode->i_mutex);
903 903
904 release_configfs_dirent(cursor); 904 release_configfs_dirent(cursor);
905 905
@@ -975,7 +975,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin)
975{ 975{
976 struct dentry * dentry = file->f_dentry; 976 struct dentry * dentry = file->f_dentry;
977 977
978 down(&dentry->d_inode->i_sem); 978 mutex_lock(&dentry->d_inode->i_mutex);
979 switch (origin) { 979 switch (origin) {
980 case 1: 980 case 1:
981 offset += file->f_pos; 981 offset += file->f_pos;
@@ -983,7 +983,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin)
983 if (offset >= 0) 983 if (offset >= 0)
984 break; 984 break;
985 default: 985 default:
986 up(&file->f_dentry->d_inode->i_sem); 986 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
987 return -EINVAL; 987 return -EINVAL;
988 } 988 }
989 if (offset != file->f_pos) { 989 if (offset != file->f_pos) {
@@ -1007,7 +1007,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin)
1007 list_add_tail(&cursor->s_sibling, p); 1007 list_add_tail(&cursor->s_sibling, p);
1008 } 1008 }
1009 } 1009 }
1010 up(&dentry->d_inode->i_sem); 1010 mutex_unlock(&dentry->d_inode->i_mutex);
1011 return offset; 1011 return offset;
1012} 1012}
1013 1013
@@ -1037,7 +1037,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
1037 sd = configfs_sb->s_root->d_fsdata; 1037 sd = configfs_sb->s_root->d_fsdata;
1038 link_group(to_config_group(sd->s_element), group); 1038 link_group(to_config_group(sd->s_element), group);
1039 1039
1040 down(&configfs_sb->s_root->d_inode->i_sem); 1040 mutex_lock(&configfs_sb->s_root->d_inode->i_mutex);
1041 1041
1042 name.name = group->cg_item.ci_name; 1042 name.name = group->cg_item.ci_name;
1043 name.len = strlen(name.name); 1043 name.len = strlen(name.name);
@@ -1057,7 +1057,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
1057 else 1057 else
1058 d_delete(dentry); 1058 d_delete(dentry);
1059 1059
1060 up(&configfs_sb->s_root->d_inode->i_sem); 1060 mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);
1061 1061
1062 if (dentry) { 1062 if (dentry) {
1063 dput(dentry); 1063 dput(dentry);
@@ -1079,18 +1079,18 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
1079 return; 1079 return;
1080 } 1080 }
1081 1081
1082 down(&configfs_sb->s_root->d_inode->i_sem); 1082 mutex_lock(&configfs_sb->s_root->d_inode->i_mutex);
1083 down(&dentry->d_inode->i_sem); 1083 mutex_lock(&dentry->d_inode->i_mutex);
1084 if (configfs_detach_prep(dentry)) { 1084 if (configfs_detach_prep(dentry)) {
1085 printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n"); 1085 printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n");
1086 } 1086 }
1087 configfs_detach_group(&group->cg_item); 1087 configfs_detach_group(&group->cg_item);
1088 dentry->d_inode->i_flags |= S_DEAD; 1088 dentry->d_inode->i_flags |= S_DEAD;
1089 up(&dentry->d_inode->i_sem); 1089 mutex_unlock(&dentry->d_inode->i_mutex);
1090 1090
1091 d_delete(dentry); 1091 d_delete(dentry);
1092 1092
1093 up(&configfs_sb->s_root->d_inode->i_sem); 1093 mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);
1094 1094
1095 dput(dentry); 1095 dput(dentry);
1096 1096
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index af1ffc9a15c0..c26cd61f13af 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -336,9 +336,9 @@ int configfs_add_file(struct dentry * dir, const struct configfs_attribute * att
336 umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG; 336 umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG;
337 int error = 0; 337 int error = 0;
338 338
339 down(&dir->d_inode->i_sem); 339 mutex_lock(&dir->d_inode->i_mutex);
340 error = configfs_make_dirent(parent_sd, NULL, (void *) attr, mode, type); 340 error = configfs_make_dirent(parent_sd, NULL, (void *) attr, mode, type);
341 up(&dir->d_inode->i_sem); 341 mutex_unlock(&dir->d_inode->i_mutex);
342 342
343 return error; 343 return error;
344} 344}
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 6b274c6d428f..6577c588de9d 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -122,7 +122,7 @@ const unsigned char * configfs_get_name(struct configfs_dirent *sd)
122 122
123/* 123/*
124 * Unhashes the dentry corresponding to given configfs_dirent 124 * Unhashes the dentry corresponding to given configfs_dirent
125 * Called with parent inode's i_sem held. 125 * Called with parent inode's i_mutex held.
126 */ 126 */
127void configfs_drop_dentry(struct configfs_dirent * sd, struct dentry * parent) 127void configfs_drop_dentry(struct configfs_dirent * sd, struct dentry * parent)
128{ 128{
@@ -145,7 +145,7 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name)
145 struct configfs_dirent * sd; 145 struct configfs_dirent * sd;
146 struct configfs_dirent * parent_sd = dir->d_fsdata; 146 struct configfs_dirent * parent_sd = dir->d_fsdata;
147 147
148 down(&dir->d_inode->i_sem); 148 mutex_lock(&dir->d_inode->i_mutex);
149 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { 149 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
150 if (!sd->s_element) 150 if (!sd->s_element)
151 continue; 151 continue;
@@ -156,7 +156,7 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name)
156 break; 156 break;
157 } 157 }
158 } 158 }
159 up(&dir->d_inode->i_sem); 159 mutex_unlock(&dir->d_inode->i_mutex);
160} 160}
161 161
162 162
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index a86ac4aeaedb..d4f1a2cddd47 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -146,7 +146,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
146 } 146 }
147 147
148 *dentry = NULL; 148 *dentry = NULL;
149 down(&parent->d_inode->i_sem); 149 mutex_lock(&parent->d_inode->i_mutex);
150 *dentry = lookup_one_len(name, parent, strlen(name)); 150 *dentry = lookup_one_len(name, parent, strlen(name));
151 if (!IS_ERR(dentry)) { 151 if (!IS_ERR(dentry)) {
152 if ((mode & S_IFMT) == S_IFDIR) 152 if ((mode & S_IFMT) == S_IFDIR)
@@ -155,7 +155,7 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
155 error = debugfs_create(parent->d_inode, *dentry, mode); 155 error = debugfs_create(parent->d_inode, *dentry, mode);
156 } else 156 } else
157 error = PTR_ERR(dentry); 157 error = PTR_ERR(dentry);
158 up(&parent->d_inode->i_sem); 158 mutex_unlock(&parent->d_inode->i_mutex);
159 159
160 return error; 160 return error;
161} 161}
@@ -273,7 +273,7 @@ void debugfs_remove(struct dentry *dentry)
273 if (!parent || !parent->d_inode) 273 if (!parent || !parent->d_inode)
274 return; 274 return;
275 275
276 down(&parent->d_inode->i_sem); 276 mutex_lock(&parent->d_inode->i_mutex);
277 if (debugfs_positive(dentry)) { 277 if (debugfs_positive(dentry)) {
278 if (dentry->d_inode) { 278 if (dentry->d_inode) {
279 if (S_ISDIR(dentry->d_inode->i_mode)) 279 if (S_ISDIR(dentry->d_inode->i_mode))
@@ -283,7 +283,7 @@ void debugfs_remove(struct dentry *dentry)
283 dput(dentry); 283 dput(dentry);
284 } 284 }
285 } 285 }
286 up(&parent->d_inode->i_sem); 286 mutex_unlock(&parent->d_inode->i_mutex);
287 simple_release_fs(&debugfs_mount, &debugfs_mount_count); 287 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
288} 288}
289EXPORT_SYMBOL_GPL(debugfs_remove); 289EXPORT_SYMBOL_GPL(debugfs_remove);
diff --git a/fs/devfs/base.c b/fs/devfs/base.c
index 1274422a5384..b621521e09d4 100644
--- a/fs/devfs/base.c
+++ b/fs/devfs/base.c
@@ -2162,27 +2162,27 @@ static int devfs_d_revalidate_wait(struct dentry *dentry, struct nameidata *nd)
2162 * 2162 *
2163 * make sure that 2163 * make sure that
2164 * d_instantiate always runs under lock 2164 * d_instantiate always runs under lock
2165 * we release i_sem lock before going to sleep 2165 * we release i_mutex lock before going to sleep
2166 * 2166 *
2167 * unfortunately sometimes d_revalidate is called with 2167 * unfortunately sometimes d_revalidate is called with
2168 * and sometimes without i_sem lock held. The following checks 2168 * and sometimes without i_mutex lock held. The following checks
2169 * attempt to deduce when we need to add (and drop resp.) lock 2169 * attempt to deduce when we need to add (and drop resp.) lock
2170 * here. This relies on current (2.6.2) calling coventions: 2170 * here. This relies on current (2.6.2) calling coventions:
2171 * 2171 *
2172 * lookup_hash is always run under i_sem and is passing NULL 2172 * lookup_hash is always run under i_mutex and is passing NULL
2173 * as nd 2173 * as nd
2174 * 2174 *
2175 * open(...,O_CREATE,...) calls _lookup_hash under i_sem 2175 * open(...,O_CREATE,...) calls _lookup_hash under i_mutex
2176 * and sets flags to LOOKUP_OPEN|LOOKUP_CREATE 2176 * and sets flags to LOOKUP_OPEN|LOOKUP_CREATE
2177 * 2177 *
2178 * all other invocations of ->d_revalidate seem to happen 2178 * all other invocations of ->d_revalidate seem to happen
2179 * outside of i_sem 2179 * outside of i_mutex
2180 */ 2180 */
2181 need_lock = nd && 2181 need_lock = nd &&
2182 (!(nd->flags & LOOKUP_CREATE) || (nd->flags & LOOKUP_PARENT)); 2182 (!(nd->flags & LOOKUP_CREATE) || (nd->flags & LOOKUP_PARENT));
2183 2183
2184 if (need_lock) 2184 if (need_lock)
2185 down(&dir->i_sem); 2185 mutex_lock(&dir->i_mutex);
2186 2186
2187 if (is_devfsd_or_child(fs_info)) { 2187 if (is_devfsd_or_child(fs_info)) {
2188 devfs_handle_t de = lookup_info->de; 2188 devfs_handle_t de = lookup_info->de;
@@ -2221,9 +2221,9 @@ static int devfs_d_revalidate_wait(struct dentry *dentry, struct nameidata *nd)
2221 add_wait_queue(&lookup_info->wait_queue, &wait); 2221 add_wait_queue(&lookup_info->wait_queue, &wait);
2222 read_unlock(&parent->u.dir.lock); 2222 read_unlock(&parent->u.dir.lock);
2223 /* at this point it is always (hopefully) locked */ 2223 /* at this point it is always (hopefully) locked */
2224 up(&dir->i_sem); 2224 mutex_unlock(&dir->i_mutex);
2225 schedule(); 2225 schedule();
2226 down(&dir->i_sem); 2226 mutex_lock(&dir->i_mutex);
2227 /* 2227 /*
2228 * This does not need nor should remove wait from wait_queue. 2228 * This does not need nor should remove wait from wait_queue.
2229 * Wait queue head is never reused - nothing is ever added to it 2229 * Wait queue head is never reused - nothing is ever added to it
@@ -2238,7 +2238,7 @@ static int devfs_d_revalidate_wait(struct dentry *dentry, struct nameidata *nd)
2238 2238
2239 out: 2239 out:
2240 if (need_lock) 2240 if (need_lock)
2241 up(&dir->i_sem); 2241 mutex_unlock(&dir->i_mutex);
2242 return 1; 2242 return 1;
2243} /* End Function devfs_d_revalidate_wait */ 2243} /* End Function devfs_d_revalidate_wait */
2244 2244
@@ -2284,9 +2284,9 @@ static struct dentry *devfs_lookup(struct inode *dir, struct dentry *dentry,
2284 /* Unlock directory semaphore, which will release any waiters. They 2284 /* Unlock directory semaphore, which will release any waiters. They
2285 will get the hashed dentry, and may be forced to wait for 2285 will get the hashed dentry, and may be forced to wait for
2286 revalidation */ 2286 revalidation */
2287 up(&dir->i_sem); 2287 mutex_unlock(&dir->i_mutex);
2288 wait_for_devfsd_finished(fs_info); /* If I'm not devfsd, must wait */ 2288 wait_for_devfsd_finished(fs_info); /* If I'm not devfsd, must wait */
2289 down(&dir->i_sem); /* Grab it again because them's the rules */ 2289 mutex_lock(&dir->i_mutex); /* Grab it again because them's the rules */
2290 de = lookup_info.de; 2290 de = lookup_info.de;
2291 /* If someone else has been so kind as to make the inode, we go home 2291 /* If someone else has been so kind as to make the inode, we go home
2292 early */ 2292 early */
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index f2be44d4491f..bfb8a230bac9 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -130,7 +130,7 @@ static struct dentry *get_node(int num)
130{ 130{
131 char s[12]; 131 char s[12];
132 struct dentry *root = devpts_root; 132 struct dentry *root = devpts_root;
133 down(&root->d_inode->i_sem); 133 mutex_lock(&root->d_inode->i_mutex);
134 return lookup_one_len(s, root, sprintf(s, "%d", num)); 134 return lookup_one_len(s, root, sprintf(s, "%d", num));
135} 135}
136 136
@@ -161,7 +161,7 @@ int devpts_pty_new(struct tty_struct *tty)
161 if (!IS_ERR(dentry) && !dentry->d_inode) 161 if (!IS_ERR(dentry) && !dentry->d_inode)
162 d_instantiate(dentry, inode); 162 d_instantiate(dentry, inode);
163 163
164 up(&devpts_root->d_inode->i_sem); 164 mutex_unlock(&devpts_root->d_inode->i_mutex);
165 165
166 return 0; 166 return 0;
167} 167}
@@ -178,7 +178,7 @@ struct tty_struct *devpts_get_tty(int number)
178 dput(dentry); 178 dput(dentry);
179 } 179 }
180 180
181 up(&devpts_root->d_inode->i_sem); 181 mutex_unlock(&devpts_root->d_inode->i_mutex);
182 182
183 return tty; 183 return tty;
184} 184}
@@ -196,7 +196,7 @@ void devpts_pty_kill(int number)
196 } 196 }
197 dput(dentry); 197 dput(dentry);
198 } 198 }
199 up(&devpts_root->d_inode->i_sem); 199 mutex_unlock(&devpts_root->d_inode->i_mutex);
200} 200}
201 201
202static int __init init_devpts_fs(void) 202static int __init init_devpts_fs(void)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 3931e7f1e6bf..30dbbd1df511 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -56,7 +56,7 @@
56 * lock_type is DIO_LOCKING for regular files on direct-IO-naive filesystems. 56 * lock_type is DIO_LOCKING for regular files on direct-IO-naive filesystems.
57 * This determines whether we need to do the fancy locking which prevents 57 * This determines whether we need to do the fancy locking which prevents
58 * direct-IO from being able to read uninitialised disk blocks. If its zero 58 * direct-IO from being able to read uninitialised disk blocks. If its zero
59 * (blockdev) this locking is not done, and if it is DIO_OWN_LOCKING i_sem is 59 * (blockdev) this locking is not done, and if it is DIO_OWN_LOCKING i_mutex is
60 * not held for the entire direct write (taken briefly, initially, during a 60 * not held for the entire direct write (taken briefly, initially, during a
61 * direct read though, but its never held for the duration of a direct-IO). 61 * direct read though, but its never held for the duration of a direct-IO).
62 */ 62 */
@@ -930,7 +930,7 @@ out:
930} 930}
931 931
932/* 932/*
933 * Releases both i_sem and i_alloc_sem 933 * Releases both i_mutex and i_alloc_sem
934 */ 934 */
935static ssize_t 935static ssize_t
936direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, 936direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
@@ -1062,11 +1062,11 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
1062 1062
1063 /* 1063 /*
1064 * All block lookups have been performed. For READ requests 1064 * All block lookups have been performed. For READ requests
1065 * we can let i_sem go now that its achieved its purpose 1065 * we can let i_mutex go now that its achieved its purpose
1066 * of protecting us from looking up uninitialized blocks. 1066 * of protecting us from looking up uninitialized blocks.
1067 */ 1067 */
1068 if ((rw == READ) && (dio->lock_type == DIO_LOCKING)) 1068 if ((rw == READ) && (dio->lock_type == DIO_LOCKING))
1069 up(&dio->inode->i_sem); 1069 mutex_unlock(&dio->inode->i_mutex);
1070 1070
1071 /* 1071 /*
1072 * OK, all BIOs are submitted, so we can decrement bio_count to truly 1072 * OK, all BIOs are submitted, so we can decrement bio_count to truly
@@ -1145,18 +1145,18 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
1145 * The locking rules are governed by the dio_lock_type parameter. 1145 * The locking rules are governed by the dio_lock_type parameter.
1146 * 1146 *
1147 * DIO_NO_LOCKING (no locking, for raw block device access) 1147 * DIO_NO_LOCKING (no locking, for raw block device access)
1148 * For writes, i_sem is not held on entry; it is never taken. 1148 * For writes, i_mutex is not held on entry; it is never taken.
1149 * 1149 *
1150 * DIO_LOCKING (simple locking for regular files) 1150 * DIO_LOCKING (simple locking for regular files)
1151 * For writes we are called under i_sem and return with i_sem held, even though 1151 * For writes we are called under i_mutex and return with i_mutex held, even though
1152 * it is internally dropped. 1152 * it is internally dropped.
1153 * For reads, i_sem is not held on entry, but it is taken and dropped before 1153 * For reads, i_mutex is not held on entry, but it is taken and dropped before
1154 * returning. 1154 * returning.
1155 * 1155 *
1156 * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of 1156 * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of
1157 * uninitialised data, allowing parallel direct readers and writers) 1157 * uninitialised data, allowing parallel direct readers and writers)
1158 * For writes we are called without i_sem, return without it, never touch it. 1158 * For writes we are called without i_mutex, return without it, never touch it.
1159 * For reads, i_sem is held on entry and will be released before returning. 1159 * For reads, i_mutex is held on entry and will be released before returning.
1160 * 1160 *
1161 * Additional i_alloc_sem locking requirements described inline below. 1161 * Additional i_alloc_sem locking requirements described inline below.
1162 */ 1162 */
@@ -1214,11 +1214,11 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1214 * For block device access DIO_NO_LOCKING is used, 1214 * For block device access DIO_NO_LOCKING is used,
1215 * neither readers nor writers do any locking at all 1215 * neither readers nor writers do any locking at all
1216 * For regular files using DIO_LOCKING, 1216 * For regular files using DIO_LOCKING,
1217 * readers need to grab i_sem and i_alloc_sem 1217 * readers need to grab i_mutex and i_alloc_sem
1218 * writers need to grab i_alloc_sem only (i_sem is already held) 1218 * writers need to grab i_alloc_sem only (i_mutex is already held)
1219 * For regular files using DIO_OWN_LOCKING, 1219 * For regular files using DIO_OWN_LOCKING,
1220 * neither readers nor writers take any locks here 1220 * neither readers nor writers take any locks here
1221 * (i_sem is already held and release for writers here) 1221 * (i_mutex is already held and release for writers here)
1222 */ 1222 */
1223 dio->lock_type = dio_lock_type; 1223 dio->lock_type = dio_lock_type;
1224 if (dio_lock_type != DIO_NO_LOCKING) { 1224 if (dio_lock_type != DIO_NO_LOCKING) {
@@ -1228,7 +1228,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1228 1228
1229 mapping = iocb->ki_filp->f_mapping; 1229 mapping = iocb->ki_filp->f_mapping;
1230 if (dio_lock_type != DIO_OWN_LOCKING) { 1230 if (dio_lock_type != DIO_OWN_LOCKING) {
1231 down(&inode->i_sem); 1231 mutex_lock(&inode->i_mutex);
1232 reader_with_isem = 1; 1232 reader_with_isem = 1;
1233 } 1233 }
1234 1234
@@ -1240,7 +1240,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1240 } 1240 }
1241 1241
1242 if (dio_lock_type == DIO_OWN_LOCKING) { 1242 if (dio_lock_type == DIO_OWN_LOCKING) {
1243 up(&inode->i_sem); 1243 mutex_unlock(&inode->i_mutex);
1244 reader_with_isem = 0; 1244 reader_with_isem = 0;
1245 } 1245 }
1246 } 1246 }
@@ -1266,7 +1266,7 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
1266 1266
1267out: 1267out:
1268 if (reader_with_isem) 1268 if (reader_with_isem)
1269 up(&inode->i_sem); 1269 mutex_unlock(&inode->i_mutex);
1270 if (rw & WRITE) 1270 if (rw & WRITE)
1271 current->flags &= ~PF_SYNCWRITE; 1271 current->flags &= ~PF_SYNCWRITE;
1272 return retval; 1272 return retval;
diff --git a/fs/dquot.c b/fs/dquot.c
index 2a62b3dc20ec..cb6d5bfbdfd5 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -100,7 +100,7 @@
100 * operation is just reading pointers from inode (or not using them at all) the 100 * operation is just reading pointers from inode (or not using them at all) the
101 * read lock is enough. If pointers are altered function must hold write lock 101 * read lock is enough. If pointers are altered function must hold write lock
102 * (these locking rules also apply for S_NOQUOTA flag in the inode - note that 102 * (these locking rules also apply for S_NOQUOTA flag in the inode - note that
103 * for altering the flag i_sem is also needed). If operation is holding 103 * for altering the flag i_mutex is also needed). If operation is holding
104 * reference to dquot in other way (e.g. quotactl ops) it must be guarded by 104 * reference to dquot in other way (e.g. quotactl ops) it must be guarded by
105 * dqonoff_sem. 105 * dqonoff_sem.
106 * This locking assures that: 106 * This locking assures that:
@@ -117,9 +117,9 @@
117 * spinlock to internal buffers before writing. 117 * spinlock to internal buffers before writing.
118 * 118 *
119 * Lock ordering (including related VFS locks) is the following: 119 * Lock ordering (including related VFS locks) is the following:
120 * i_sem > dqonoff_sem > iprune_sem > journal_lock > dqptr_sem > 120 * i_mutex > dqonoff_sem > iprune_sem > journal_lock > dqptr_sem >
121 * > dquot->dq_lock > dqio_sem 121 * > dquot->dq_lock > dqio_sem
122 * i_sem on quota files is special (it's below dqio_sem) 122 * i_mutex on quota files is special (it's below dqio_sem)
123 */ 123 */
124 124
125static DEFINE_SPINLOCK(dq_list_lock); 125static DEFINE_SPINLOCK(dq_list_lock);
@@ -1369,11 +1369,11 @@ int vfs_quota_off(struct super_block *sb, int type)
1369 /* If quota was reenabled in the meantime, we have 1369 /* If quota was reenabled in the meantime, we have
1370 * nothing to do */ 1370 * nothing to do */
1371 if (!sb_has_quota_enabled(sb, cnt)) { 1371 if (!sb_has_quota_enabled(sb, cnt)) {
1372 down(&toputinode[cnt]->i_sem); 1372 mutex_lock(&toputinode[cnt]->i_mutex);
1373 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | 1373 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
1374 S_NOATIME | S_NOQUOTA); 1374 S_NOATIME | S_NOQUOTA);
1375 truncate_inode_pages(&toputinode[cnt]->i_data, 0); 1375 truncate_inode_pages(&toputinode[cnt]->i_data, 0);
1376 up(&toputinode[cnt]->i_sem); 1376 mutex_unlock(&toputinode[cnt]->i_mutex);
1377 mark_inode_dirty(toputinode[cnt]); 1377 mark_inode_dirty(toputinode[cnt]);
1378 iput(toputinode[cnt]); 1378 iput(toputinode[cnt]);
1379 } 1379 }
@@ -1417,7 +1417,7 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
1417 write_inode_now(inode, 1); 1417 write_inode_now(inode, 1);
1418 /* And now flush the block cache so that kernel sees the changes */ 1418 /* And now flush the block cache so that kernel sees the changes */
1419 invalidate_bdev(sb->s_bdev, 0); 1419 invalidate_bdev(sb->s_bdev, 0);
1420 down(&inode->i_sem); 1420 mutex_lock(&inode->i_mutex);
1421 down(&dqopt->dqonoff_sem); 1421 down(&dqopt->dqonoff_sem);
1422 if (sb_has_quota_enabled(sb, type)) { 1422 if (sb_has_quota_enabled(sb, type)) {
1423 error = -EBUSY; 1423 error = -EBUSY;
@@ -1449,7 +1449,7 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
1449 goto out_file_init; 1449 goto out_file_init;
1450 } 1450 }
1451 up(&dqopt->dqio_sem); 1451 up(&dqopt->dqio_sem);
1452 up(&inode->i_sem); 1452 mutex_unlock(&inode->i_mutex);
1453 set_enable_flags(dqopt, type); 1453 set_enable_flags(dqopt, type);
1454 1454
1455 add_dquot_ref(sb, type); 1455 add_dquot_ref(sb, type);
@@ -1470,7 +1470,7 @@ out_lock:
1470 inode->i_flags |= oldflags; 1470 inode->i_flags |= oldflags;
1471 up_write(&dqopt->dqptr_sem); 1471 up_write(&dqopt->dqptr_sem);
1472 } 1472 }
1473 up(&inode->i_sem); 1473 mutex_unlock(&inode->i_mutex);
1474out_fmt: 1474out_fmt:
1475 put_quota_format(fmt); 1475 put_quota_format(fmt);
1476 1476
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index c49d6254379a..5bfe40085fbc 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -177,9 +177,9 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
177 struct dentry *ppd; 177 struct dentry *ppd;
178 struct dentry *npd; 178 struct dentry *npd;
179 179
180 down(&pd->d_inode->i_sem); 180 mutex_lock(&pd->d_inode->i_mutex);
181 ppd = CALL(nops,get_parent)(pd); 181 ppd = CALL(nops,get_parent)(pd);
182 up(&pd->d_inode->i_sem); 182 mutex_unlock(&pd->d_inode->i_mutex);
183 183
184 if (IS_ERR(ppd)) { 184 if (IS_ERR(ppd)) {
185 err = PTR_ERR(ppd); 185 err = PTR_ERR(ppd);
@@ -201,9 +201,9 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
201 break; 201 break;
202 } 202 }
203 dprintk("find_exported_dentry: found name: %s\n", nbuf); 203 dprintk("find_exported_dentry: found name: %s\n", nbuf);
204 down(&ppd->d_inode->i_sem); 204 mutex_lock(&ppd->d_inode->i_mutex);
205 npd = lookup_one_len(nbuf, ppd, strlen(nbuf)); 205 npd = lookup_one_len(nbuf, ppd, strlen(nbuf));
206 up(&ppd->d_inode->i_sem); 206 mutex_unlock(&ppd->d_inode->i_mutex);
207 if (IS_ERR(npd)) { 207 if (IS_ERR(npd)) {
208 err = PTR_ERR(npd); 208 err = PTR_ERR(npd);
209 dprintk("find_exported_dentry: lookup failed: %d\n", err); 209 dprintk("find_exported_dentry: lookup failed: %d\n", err);
@@ -242,9 +242,9 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
242 struct dentry *nresult; 242 struct dentry *nresult;
243 err = CALL(nops,get_name)(target_dir, nbuf, result); 243 err = CALL(nops,get_name)(target_dir, nbuf, result);
244 if (!err) { 244 if (!err) {
245 down(&target_dir->d_inode->i_sem); 245 mutex_lock(&target_dir->d_inode->i_mutex);
246 nresult = lookup_one_len(nbuf, target_dir, strlen(nbuf)); 246 nresult = lookup_one_len(nbuf, target_dir, strlen(nbuf));
247 up(&target_dir->d_inode->i_sem); 247 mutex_unlock(&target_dir->d_inode->i_mutex);
248 if (!IS_ERR(nresult)) { 248 if (!IS_ERR(nresult)) {
249 if (nresult->d_inode) { 249 if (nresult->d_inode) {
250 dput(result); 250 dput(result);
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 6af2f4130290..239133d01d91 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -149,7 +149,7 @@ ext2_iset_acl(struct inode *inode, struct posix_acl **i_acl,
149} 149}
150 150
151/* 151/*
152 * inode->i_sem: don't care 152 * inode->i_mutex: don't care
153 */ 153 */
154static struct posix_acl * 154static struct posix_acl *
155ext2_get_acl(struct inode *inode, int type) 155ext2_get_acl(struct inode *inode, int type)
@@ -211,7 +211,7 @@ ext2_get_acl(struct inode *inode, int type)
211} 211}
212 212
213/* 213/*
214 * inode->i_sem: down 214 * inode->i_mutex: down
215 */ 215 */
216static int 216static int
217ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 217ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
@@ -301,8 +301,8 @@ ext2_permission(struct inode *inode, int mask, struct nameidata *nd)
301/* 301/*
302 * Initialize the ACLs of a new inode. Called from ext2_new_inode. 302 * Initialize the ACLs of a new inode. Called from ext2_new_inode.
303 * 303 *
304 * dir->i_sem: down 304 * dir->i_mutex: down
305 * inode->i_sem: up (access to inode is still exclusive) 305 * inode->i_mutex: up (access to inode is still exclusive)
306 */ 306 */
307int 307int
308ext2_init_acl(struct inode *inode, struct inode *dir) 308ext2_init_acl(struct inode *inode, struct inode *dir)
@@ -361,7 +361,7 @@ cleanup:
361 * for directories) are added. There are no more bits available in the 361 * for directories) are added. There are no more bits available in the
362 * file mode. 362 * file mode.
363 * 363 *
364 * inode->i_sem: down 364 * inode->i_mutex: down
365 */ 365 */
366int 366int
367ext2_acl_chmod(struct inode *inode) 367ext2_acl_chmod(struct inode *inode)
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index e977f8566d14..00de0a7312a2 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -53,7 +53,7 @@ struct ext2_inode_info {
53#ifdef CONFIG_EXT2_FS_XATTR 53#ifdef CONFIG_EXT2_FS_XATTR
54 /* 54 /*
55 * Extended attributes can be read independently of the main file 55 * Extended attributes can be read independently of the main file
56 * data. Taking i_sem even when reading would cause contention 56 * data. Taking i_mutex even when reading would cause contention
57 * between readers of EAs and writers of regular file data, so 57 * between readers of EAs and writers of regular file data, so
58 * instead we synchronize on xattr_sem when reading or changing 58 * instead we synchronize on xattr_sem when reading or changing
59 * EAs. 59 * EAs.
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 522fa70dd8ea..8d6819846fc9 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1152,7 +1152,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type,
1152 struct buffer_head tmp_bh; 1152 struct buffer_head tmp_bh;
1153 struct buffer_head *bh; 1153 struct buffer_head *bh;
1154 1154
1155 down(&inode->i_sem); 1155 mutex_lock(&inode->i_mutex);
1156 while (towrite > 0) { 1156 while (towrite > 0) {
1157 tocopy = sb->s_blocksize - offset < towrite ? 1157 tocopy = sb->s_blocksize - offset < towrite ?
1158 sb->s_blocksize - offset : towrite; 1158 sb->s_blocksize - offset : towrite;
@@ -1189,7 +1189,7 @@ out:
1189 inode->i_version++; 1189 inode->i_version++;
1190 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1190 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
1191 mark_inode_dirty(inode); 1191 mark_inode_dirty(inode);
1192 up(&inode->i_sem); 1192 mutex_unlock(&inode->i_mutex);
1193 return len - towrite; 1193 return len - towrite;
1194} 1194}
1195 1195
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 0099462d4271..f7a3b5fee274 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -325,7 +325,7 @@ cleanup:
325/* 325/*
326 * Inode operation listxattr() 326 * Inode operation listxattr()
327 * 327 *
328 * dentry->d_inode->i_sem: don't care 328 * dentry->d_inode->i_mutex: don't care
329 */ 329 */
330ssize_t 330ssize_t
331ext2_listxattr(struct dentry *dentry, char *buffer, size_t size) 331ext2_listxattr(struct dentry *dentry, char *buffer, size_t size)
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index 3ac38266fc9e..9ed132c96034 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -152,7 +152,7 @@ ext3_iset_acl(struct inode *inode, struct posix_acl **i_acl,
152/* 152/*
153 * Inode operation get_posix_acl(). 153 * Inode operation get_posix_acl().
154 * 154 *
155 * inode->i_sem: don't care 155 * inode->i_mutex: don't care
156 */ 156 */
157static struct posix_acl * 157static struct posix_acl *
158ext3_get_acl(struct inode *inode, int type) 158ext3_get_acl(struct inode *inode, int type)
@@ -216,7 +216,7 @@ ext3_get_acl(struct inode *inode, int type)
216/* 216/*
217 * Set the access or default ACL of an inode. 217 * Set the access or default ACL of an inode.
218 * 218 *
219 * inode->i_sem: down unless called from ext3_new_inode 219 * inode->i_mutex: down unless called from ext3_new_inode
220 */ 220 */
221static int 221static int
222ext3_set_acl(handle_t *handle, struct inode *inode, int type, 222ext3_set_acl(handle_t *handle, struct inode *inode, int type,
@@ -306,8 +306,8 @@ ext3_permission(struct inode *inode, int mask, struct nameidata *nd)
306/* 306/*
307 * Initialize the ACLs of a new inode. Called from ext3_new_inode. 307 * Initialize the ACLs of a new inode. Called from ext3_new_inode.
308 * 308 *
309 * dir->i_sem: down 309 * dir->i_mutex: down
310 * inode->i_sem: up (access to inode is still exclusive) 310 * inode->i_mutex: up (access to inode is still exclusive)
311 */ 311 */
312int 312int
313ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir) 313ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
@@ -368,7 +368,7 @@ cleanup:
368 * for directories) are added. There are no more bits available in the 368 * for directories) are added. There are no more bits available in the
369 * file mode. 369 * file mode.
370 * 370 *
371 * inode->i_sem: down 371 * inode->i_mutex: down
372 */ 372 */
373int 373int
374ext3_acl_chmod(struct inode *inode) 374ext3_acl_chmod(struct inode *inode)
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 7c45acf94589..c3dbebdb9897 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2601,7 +2601,7 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,
2601 struct buffer_head *bh; 2601 struct buffer_head *bh;
2602 handle_t *handle = journal_current_handle(); 2602 handle_t *handle = journal_current_handle();
2603 2603
2604 down(&inode->i_sem); 2604 mutex_lock(&inode->i_mutex);
2605 while (towrite > 0) { 2605 while (towrite > 0) {
2606 tocopy = sb->s_blocksize - offset < towrite ? 2606 tocopy = sb->s_blocksize - offset < towrite ?
2607 sb->s_blocksize - offset : towrite; 2607 sb->s_blocksize - offset : towrite;
@@ -2644,7 +2644,7 @@ out:
2644 inode->i_version++; 2644 inode->i_version++;
2645 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 2645 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2646 ext3_mark_inode_dirty(handle, inode); 2646 ext3_mark_inode_dirty(handle, inode);
2647 up(&inode->i_sem); 2647 mutex_unlock(&inode->i_mutex);
2648 return len - towrite; 2648 return len - towrite;
2649} 2649}
2650 2650
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index 430de9f63be3..238199d82ce5 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -140,7 +140,7 @@ ext3_xattr_handler(int name_index)
140/* 140/*
141 * Inode operation listxattr() 141 * Inode operation listxattr()
142 * 142 *
143 * dentry->d_inode->i_sem: don't care 143 * dentry->d_inode->i_mutex: don't care
144 */ 144 */
145ssize_t 145ssize_t
146ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) 146ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index eef1b81aa294..db0de5c621c7 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -729,13 +729,13 @@ static int fat_dir_ioctl(struct inode * inode, struct file * filp,
729 729
730 buf.dirent = d1; 730 buf.dirent = d1;
731 buf.result = 0; 731 buf.result = 0;
732 down(&inode->i_sem); 732 mutex_lock(&inode->i_mutex);
733 ret = -ENOENT; 733 ret = -ENOENT;
734 if (!IS_DEADDIR(inode)) { 734 if (!IS_DEADDIR(inode)) {
735 ret = __fat_readdir(inode, filp, &buf, fat_ioctl_filldir, 735 ret = __fat_readdir(inode, filp, &buf, fat_ioctl_filldir,
736 short_only, both); 736 short_only, both);
737 } 737 }
738 up(&inode->i_sem); 738 mutex_unlock(&inode->i_mutex);
739 if (ret >= 0) 739 if (ret >= 0)
740 ret = buf.result; 740 ret = buf.result;
741 return ret; 741 return ret;
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 9b07c328a6fc..d30876cf35f5 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -41,7 +41,7 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp,
41 if (err) 41 if (err)
42 return err; 42 return err;
43 43
44 down(&inode->i_sem); 44 mutex_lock(&inode->i_mutex);
45 45
46 if (IS_RDONLY(inode)) { 46 if (IS_RDONLY(inode)) {
47 err = -EROFS; 47 err = -EROFS;
@@ -103,7 +103,7 @@ int fat_generic_ioctl(struct inode *inode, struct file *filp,
103 MSDOS_I(inode)->i_attrs = attr & ATTR_UNUSED; 103 MSDOS_I(inode)->i_attrs = attr & ATTR_UNUSED;
104 mark_inode_dirty(inode); 104 mark_inode_dirty(inode);
105 up: 105 up:
106 up(&inode->i_sem); 106 mutex_unlock(&inode->i_mutex);
107 return err; 107 return err;
108 } 108 }
109 default: 109 default:
diff --git a/fs/fifo.c b/fs/fifo.c
index 5455916241f0..923371b753ab 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -35,7 +35,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
35 int ret; 35 int ret;
36 36
37 ret = -ERESTARTSYS; 37 ret = -ERESTARTSYS;
38 if (down_interruptible(PIPE_SEM(*inode))) 38 if (mutex_lock_interruptible(PIPE_MUTEX(*inode)))
39 goto err_nolock_nocleanup; 39 goto err_nolock_nocleanup;
40 40
41 if (!inode->i_pipe) { 41 if (!inode->i_pipe) {
@@ -119,7 +119,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
119 } 119 }
120 120
121 /* Ok! */ 121 /* Ok! */
122 up(PIPE_SEM(*inode)); 122 mutex_unlock(PIPE_MUTEX(*inode));
123 return 0; 123 return 0;
124 124
125err_rd: 125err_rd:
@@ -139,7 +139,7 @@ err:
139 free_pipe_info(inode); 139 free_pipe_info(inode);
140 140
141err_nocleanup: 141err_nocleanup:
142 up(PIPE_SEM(*inode)); 142 mutex_unlock(PIPE_MUTEX(*inode));
143 143
144err_nolock_nocleanup: 144err_nolock_nocleanup:
145 return ret; 145 return ret;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 05dedddf4289..63d2980df5c9 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -560,9 +560,9 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
560 struct inode *inode = file->f_dentry->d_inode; 560 struct inode *inode = file->f_dentry->d_inode;
561 ssize_t res; 561 ssize_t res;
562 /* Don't allow parallel writes to the same file */ 562 /* Don't allow parallel writes to the same file */
563 down(&inode->i_sem); 563 mutex_lock(&inode->i_mutex);
564 res = fuse_direct_io(file, buf, count, ppos, 1); 564 res = fuse_direct_io(file, buf, count, ppos, 1);
565 up(&inode->i_sem); 565 mutex_unlock(&inode->i_mutex);
566 return res; 566 return res;
567} 567}
568 568
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index d499393a8ae7..050a49276499 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -547,13 +547,13 @@ static int hfs_file_release(struct inode *inode, struct file *file)
547 if (atomic_read(&file->f_count) != 0) 547 if (atomic_read(&file->f_count) != 0)
548 return 0; 548 return 0;
549 if (atomic_dec_and_test(&HFS_I(inode)->opencnt)) { 549 if (atomic_dec_and_test(&HFS_I(inode)->opencnt)) {
550 down(&inode->i_sem); 550 mutex_lock(&inode->i_mutex);
551 hfs_file_truncate(inode); 551 hfs_file_truncate(inode);
552 //if (inode->i_flags & S_DEAD) { 552 //if (inode->i_flags & S_DEAD) {
553 // hfs_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL); 553 // hfs_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL);
554 // hfs_delete_inode(inode); 554 // hfs_delete_inode(inode);
555 //} 555 //}
556 up(&inode->i_sem); 556 mutex_unlock(&inode->i_mutex);
557 } 557 }
558 return 0; 558 return 0;
559} 559}
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
index c7d316455fa0..9fb51632303c 100644
--- a/fs/hfsplus/bitmap.c
+++ b/fs/hfsplus/bitmap.c
@@ -29,7 +29,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
29 return size; 29 return size;
30 30
31 dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len); 31 dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
32 down(&HFSPLUS_SB(sb).alloc_file->i_sem); 32 mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
33 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; 33 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
34 page = read_cache_page(mapping, offset / PAGE_CACHE_BITS, 34 page = read_cache_page(mapping, offset / PAGE_CACHE_BITS,
35 (filler_t *)mapping->a_ops->readpage, NULL); 35 (filler_t *)mapping->a_ops->readpage, NULL);
@@ -143,7 +143,7 @@ done:
143 sb->s_dirt = 1; 143 sb->s_dirt = 1;
144 dprint(DBG_BITMAP, "-> %u,%u\n", start, *max); 144 dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
145out: 145out:
146 up(&HFSPLUS_SB(sb).alloc_file->i_sem); 146 mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
147 return start; 147 return start;
148} 148}
149 149
@@ -164,7 +164,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
164 if ((offset + count) > HFSPLUS_SB(sb).total_blocks) 164 if ((offset + count) > HFSPLUS_SB(sb).total_blocks)
165 return -2; 165 return -2;
166 166
167 down(&HFSPLUS_SB(sb).alloc_file->i_sem); 167 mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
168 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; 168 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
169 pnr = offset / PAGE_CACHE_BITS; 169 pnr = offset / PAGE_CACHE_BITS;
170 page = read_cache_page(mapping, pnr, (filler_t *)mapping->a_ops->readpage, NULL); 170 page = read_cache_page(mapping, pnr, (filler_t *)mapping->a_ops->readpage, NULL);
@@ -215,7 +215,7 @@ out:
215 kunmap(page); 215 kunmap(page);
216 HFSPLUS_SB(sb).free_blocks += len; 216 HFSPLUS_SB(sb).free_blocks += len;
217 sb->s_dirt = 1; 217 sb->s_dirt = 1;
218 up(&HFSPLUS_SB(sb).alloc_file->i_sem); 218 mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
219 219
220 return 0; 220 return 0;
221} 221}
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index fc98583cf045..983bcd02ac1c 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -276,13 +276,13 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
276 if (atomic_read(&file->f_count) != 0) 276 if (atomic_read(&file->f_count) != 0)
277 return 0; 277 return 0;
278 if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) { 278 if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) {
279 down(&inode->i_sem); 279 mutex_lock(&inode->i_mutex);
280 hfsplus_file_truncate(inode); 280 hfsplus_file_truncate(inode);
281 if (inode->i_flags & S_DEAD) { 281 if (inode->i_flags & S_DEAD) {
282 hfsplus_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL); 282 hfsplus_delete_cat(inode->i_ino, HFSPLUS_SB(sb).hidden_dir, NULL);
283 hfsplus_delete_inode(inode); 283 hfsplus_delete_inode(inode);
284 } 284 }
285 up(&inode->i_sem); 285 mutex_unlock(&inode->i_mutex);
286 } 286 }
287 return 0; 287 return 0;
288} 288}
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index 0217c3a04441..5591f9623aa2 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -32,19 +32,19 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence)
32 32
33 /*printk("dir lseek\n");*/ 33 /*printk("dir lseek\n");*/
34 if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok; 34 if (new_off == 0 || new_off == 1 || new_off == 11 || new_off == 12 || new_off == 13) goto ok;
35 down(&i->i_sem); 35 mutex_lock(&i->i_mutex);
36 pos = ((loff_t) hpfs_de_as_down_as_possible(s, hpfs_inode->i_dno) << 4) + 1; 36 pos = ((loff_t) hpfs_de_as_down_as_possible(s, hpfs_inode->i_dno) << 4) + 1;
37 while (pos != new_off) { 37 while (pos != new_off) {
38 if (map_pos_dirent(i, &pos, &qbh)) hpfs_brelse4(&qbh); 38 if (map_pos_dirent(i, &pos, &qbh)) hpfs_brelse4(&qbh);
39 else goto fail; 39 else goto fail;
40 if (pos == 12) goto fail; 40 if (pos == 12) goto fail;
41 } 41 }
42 up(&i->i_sem); 42 mutex_unlock(&i->i_mutex);
43ok: 43ok:
44 unlock_kernel(); 44 unlock_kernel();
45 return filp->f_pos = new_off; 45 return filp->f_pos = new_off;
46fail: 46fail:
47 up(&i->i_sem); 47 mutex_unlock(&i->i_mutex);
48 /*printk("illegal lseek: %016llx\n", new_off);*/ 48 /*printk("illegal lseek: %016llx\n", new_off);*/
49 unlock_kernel(); 49 unlock_kernel();
50 return -ESPIPE; 50 return -ESPIPE;
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c
index 52930915bad8..a44dc5897399 100644
--- a/fs/hppfs/hppfs_kern.c
+++ b/fs/hppfs/hppfs_kern.c
@@ -171,12 +171,12 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
171 171
172 err = -ENOMEM; 172 err = -ENOMEM;
173 parent = HPPFS_I(ino)->proc_dentry; 173 parent = HPPFS_I(ino)->proc_dentry;
174 down(&parent->d_inode->i_sem); 174 mutex_lock(&parent->d_inode->i_mutex);
175 proc_dentry = d_lookup(parent, &dentry->d_name); 175 proc_dentry = d_lookup(parent, &dentry->d_name);
176 if(proc_dentry == NULL){ 176 if(proc_dentry == NULL){
177 proc_dentry = d_alloc(parent, &dentry->d_name); 177 proc_dentry = d_alloc(parent, &dentry->d_name);
178 if(proc_dentry == NULL){ 178 if(proc_dentry == NULL){
179 up(&parent->d_inode->i_sem); 179 mutex_unlock(&parent->d_inode->i_mutex);
180 goto out; 180 goto out;
181 } 181 }
182 new = (*parent->d_inode->i_op->lookup)(parent->d_inode, 182 new = (*parent->d_inode->i_op->lookup)(parent->d_inode,
@@ -186,7 +186,7 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
186 proc_dentry = new; 186 proc_dentry = new;
187 } 187 }
188 } 188 }
189 up(&parent->d_inode->i_sem); 189 mutex_unlock(&parent->d_inode->i_mutex);
190 190
191 if(IS_ERR(proc_dentry)) 191 if(IS_ERR(proc_dentry))
192 return(proc_dentry); 192 return(proc_dentry);
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 8c41315a6e42..ff1b7d108bd0 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -118,7 +118,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
118 118
119 vma_len = (loff_t)(vma->vm_end - vma->vm_start); 119 vma_len = (loff_t)(vma->vm_end - vma->vm_start);
120 120
121 down(&inode->i_sem); 121 mutex_lock(&inode->i_mutex);
122 file_accessed(file); 122 file_accessed(file);
123 vma->vm_flags |= VM_HUGETLB | VM_RESERVED; 123 vma->vm_flags |= VM_HUGETLB | VM_RESERVED;
124 vma->vm_ops = &hugetlb_vm_ops; 124 vma->vm_ops = &hugetlb_vm_ops;
@@ -133,7 +133,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
133 if (inode->i_size < len) 133 if (inode->i_size < len)
134 inode->i_size = len; 134 inode->i_size = len;
135out: 135out:
136 up(&inode->i_sem); 136 mutex_unlock(&inode->i_mutex);
137 137
138 return ret; 138 return ret;
139} 139}
diff --git a/fs/inode.c b/fs/inode.c
index fd568caf7f74..e08767fd57b0 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -192,7 +192,7 @@ void inode_init_once(struct inode *inode)
192 INIT_HLIST_NODE(&inode->i_hash); 192 INIT_HLIST_NODE(&inode->i_hash);
193 INIT_LIST_HEAD(&inode->i_dentry); 193 INIT_LIST_HEAD(&inode->i_dentry);
194 INIT_LIST_HEAD(&inode->i_devices); 194 INIT_LIST_HEAD(&inode->i_devices);
195 sema_init(&inode->i_sem, 1); 195 mutex_init(&inode->i_mutex);
196 init_rwsem(&inode->i_alloc_sem); 196 init_rwsem(&inode->i_alloc_sem);
197 INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC); 197 INIT_RADIX_TREE(&inode->i_data.page_tree, GFP_ATOMIC);
198 rwlock_init(&inode->i_data.tree_lock); 198 rwlock_init(&inode->i_data.tree_lock);
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index 2559ee10beda..fc3855a1aef3 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -1415,7 +1415,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
1415 * This will never trigger with sane page sizes. leave it in 1415 * This will never trigger with sane page sizes. leave it in
1416 * anyway, since I'm thinking about how to merge larger writes 1416 * anyway, since I'm thinking about how to merge larger writes
1417 * (the current idea is to poke a thread that does the actual 1417 * (the current idea is to poke a thread that does the actual
1418 * I/O and starts by doing a down(&inode->i_sem). then we 1418 * I/O and starts by doing a mutex_lock(&inode->i_mutex). then we
1419 * would need to get the page cache pages and have a list of 1419 * would need to get the page cache pages and have a list of
1420 * I/O requests and do write-merging here. 1420 * I/O requests and do write-merging here.
1421 * -- prumpf 1421 * -- prumpf
diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h
index c0fd7b3eadc6..dc21a5bd54d4 100644
--- a/fs/jfs/jfs_incore.h
+++ b/fs/jfs/jfs_incore.h
@@ -58,7 +58,7 @@ struct jfs_inode_info {
58 /* 58 /*
59 * rdwrlock serializes xtree between reads & writes and synchronizes 59 * rdwrlock serializes xtree between reads & writes and synchronizes
60 * changes to special inodes. It's use would be redundant on 60 * changes to special inodes. It's use would be redundant on
61 * directories since the i_sem taken in the VFS is sufficient. 61 * directories since the i_mutex taken in the VFS is sufficient.
62 */ 62 */
63 struct rw_semaphore rdwrlock; 63 struct rw_semaphore rdwrlock;
64 /* 64 /*
@@ -68,7 +68,7 @@ struct jfs_inode_info {
68 * inode is blocked in txBegin or TxBeginAnon 68 * inode is blocked in txBegin or TxBeginAnon
69 */ 69 */
70 struct semaphore commit_sem; 70 struct semaphore commit_sem;
71 /* xattr_sem allows us to access the xattrs without taking i_sem */ 71 /* xattr_sem allows us to access the xattrs without taking i_mutex */
72 struct rw_semaphore xattr_sem; 72 struct rw_semaphore xattr_sem;
73 lid_t xtlid; /* lid of xtree lock on directory */ 73 lid_t xtlid; /* lid of xtree lock on directory */
74#ifdef CONFIG_JFS_POSIX_ACL 74#ifdef CONFIG_JFS_POSIX_ACL
diff --git a/fs/libfs.c b/fs/libfs.c
index 9c50523382e7..63c020e6589e 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -74,7 +74,7 @@ int dcache_dir_close(struct inode *inode, struct file *file)
74 74
75loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin) 75loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
76{ 76{
77 down(&file->f_dentry->d_inode->i_sem); 77 mutex_lock(&file->f_dentry->d_inode->i_mutex);
78 switch (origin) { 78 switch (origin) {
79 case 1: 79 case 1:
80 offset += file->f_pos; 80 offset += file->f_pos;
@@ -82,7 +82,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
82 if (offset >= 0) 82 if (offset >= 0)
83 break; 83 break;
84 default: 84 default:
85 up(&file->f_dentry->d_inode->i_sem); 85 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
86 return -EINVAL; 86 return -EINVAL;
87 } 87 }
88 if (offset != file->f_pos) { 88 if (offset != file->f_pos) {
@@ -106,7 +106,7 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int origin)
106 spin_unlock(&dcache_lock); 106 spin_unlock(&dcache_lock);
107 } 107 }
108 } 108 }
109 up(&file->f_dentry->d_inode->i_sem); 109 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
110 return offset; 110 return offset;
111} 111}
112 112
@@ -356,7 +356,7 @@ int simple_commit_write(struct file *file, struct page *page,
356 356
357 /* 357 /*
358 * No need to use i_size_read() here, the i_size 358 * No need to use i_size_read() here, the i_size
359 * cannot change under us because we hold the i_sem. 359 * cannot change under us because we hold the i_mutex.
360 */ 360 */
361 if (pos > inode->i_size) 361 if (pos > inode->i_size)
362 i_size_write(inode, pos); 362 i_size_write(inode, pos);
diff --git a/fs/namei.c b/fs/namei.c
index 300eae088d5f..0a8f073435af 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -438,7 +438,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
438 struct dentry * result; 438 struct dentry * result;
439 struct inode *dir = parent->d_inode; 439 struct inode *dir = parent->d_inode;
440 440
441 down(&dir->i_sem); 441 mutex_lock(&dir->i_mutex);
442 /* 442 /*
443 * First re-do the cached lookup just in case it was created 443 * First re-do the cached lookup just in case it was created
444 * while we waited for the directory semaphore.. 444 * while we waited for the directory semaphore..
@@ -464,7 +464,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
464 else 464 else
465 result = dentry; 465 result = dentry;
466 } 466 }
467 up(&dir->i_sem); 467 mutex_unlock(&dir->i_mutex);
468 return result; 468 return result;
469 } 469 }
470 470
@@ -472,7 +472,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
472 * Uhhuh! Nasty case: the cache was re-populated while 472 * Uhhuh! Nasty case: the cache was re-populated while
473 * we waited on the semaphore. Need to revalidate. 473 * we waited on the semaphore. Need to revalidate.
474 */ 474 */
475 up(&dir->i_sem); 475 mutex_unlock(&dir->i_mutex);
476 if (result->d_op && result->d_op->d_revalidate) { 476 if (result->d_op && result->d_op->d_revalidate) {
477 if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) { 477 if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) {
478 dput(result); 478 dput(result);
@@ -1366,7 +1366,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
1366 struct dentry *p; 1366 struct dentry *p;
1367 1367
1368 if (p1 == p2) { 1368 if (p1 == p2) {
1369 down(&p1->d_inode->i_sem); 1369 mutex_lock(&p1->d_inode->i_mutex);
1370 return NULL; 1370 return NULL;
1371 } 1371 }
1372 1372
@@ -1374,30 +1374,30 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
1374 1374
1375 for (p = p1; p->d_parent != p; p = p->d_parent) { 1375 for (p = p1; p->d_parent != p; p = p->d_parent) {
1376 if (p->d_parent == p2) { 1376 if (p->d_parent == p2) {
1377 down(&p2->d_inode->i_sem); 1377 mutex_lock(&p2->d_inode->i_mutex);
1378 down(&p1->d_inode->i_sem); 1378 mutex_lock(&p1->d_inode->i_mutex);
1379 return p; 1379 return p;
1380 } 1380 }
1381 } 1381 }
1382 1382
1383 for (p = p2; p->d_parent != p; p = p->d_parent) { 1383 for (p = p2; p->d_parent != p; p = p->d_parent) {
1384 if (p->d_parent == p1) { 1384 if (p->d_parent == p1) {
1385 down(&p1->d_inode->i_sem); 1385 mutex_lock(&p1->d_inode->i_mutex);
1386 down(&p2->d_inode->i_sem); 1386 mutex_lock(&p2->d_inode->i_mutex);
1387 return p; 1387 return p;
1388 } 1388 }
1389 } 1389 }
1390 1390
1391 down(&p1->d_inode->i_sem); 1391 mutex_lock(&p1->d_inode->i_mutex);
1392 down(&p2->d_inode->i_sem); 1392 mutex_lock(&p2->d_inode->i_mutex);
1393 return NULL; 1393 return NULL;
1394} 1394}
1395 1395
1396void unlock_rename(struct dentry *p1, struct dentry *p2) 1396void unlock_rename(struct dentry *p1, struct dentry *p2)
1397{ 1397{
1398 up(&p1->d_inode->i_sem); 1398 mutex_unlock(&p1->d_inode->i_mutex);
1399 if (p1 != p2) { 1399 if (p1 != p2) {
1400 up(&p2->d_inode->i_sem); 1400 mutex_unlock(&p2->d_inode->i_mutex);
1401 up(&p1->d_inode->i_sb->s_vfs_rename_sem); 1401 up(&p1->d_inode->i_sb->s_vfs_rename_sem);
1402 } 1402 }
1403} 1403}
@@ -1563,14 +1563,14 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
1563 1563
1564 dir = nd->dentry; 1564 dir = nd->dentry;
1565 nd->flags &= ~LOOKUP_PARENT; 1565 nd->flags &= ~LOOKUP_PARENT;
1566 down(&dir->d_inode->i_sem); 1566 mutex_lock(&dir->d_inode->i_mutex);
1567 path.dentry = lookup_hash(nd); 1567 path.dentry = lookup_hash(nd);
1568 path.mnt = nd->mnt; 1568 path.mnt = nd->mnt;
1569 1569
1570do_last: 1570do_last:
1571 error = PTR_ERR(path.dentry); 1571 error = PTR_ERR(path.dentry);
1572 if (IS_ERR(path.dentry)) { 1572 if (IS_ERR(path.dentry)) {
1573 up(&dir->d_inode->i_sem); 1573 mutex_unlock(&dir->d_inode->i_mutex);
1574 goto exit; 1574 goto exit;
1575 } 1575 }
1576 1576
@@ -1579,7 +1579,7 @@ do_last:
1579 if (!IS_POSIXACL(dir->d_inode)) 1579 if (!IS_POSIXACL(dir->d_inode))
1580 mode &= ~current->fs->umask; 1580 mode &= ~current->fs->umask;
1581 error = vfs_create(dir->d_inode, path.dentry, mode, nd); 1581 error = vfs_create(dir->d_inode, path.dentry, mode, nd);
1582 up(&dir->d_inode->i_sem); 1582 mutex_unlock(&dir->d_inode->i_mutex);
1583 dput(nd->dentry); 1583 dput(nd->dentry);
1584 nd->dentry = path.dentry; 1584 nd->dentry = path.dentry;
1585 if (error) 1585 if (error)
@@ -1593,7 +1593,7 @@ do_last:
1593 /* 1593 /*
1594 * It already exists. 1594 * It already exists.
1595 */ 1595 */
1596 up(&dir->d_inode->i_sem); 1596 mutex_unlock(&dir->d_inode->i_mutex);
1597 1597
1598 error = -EEXIST; 1598 error = -EEXIST;
1599 if (flag & O_EXCL) 1599 if (flag & O_EXCL)
@@ -1665,7 +1665,7 @@ do_link:
1665 goto exit; 1665 goto exit;
1666 } 1666 }
1667 dir = nd->dentry; 1667 dir = nd->dentry;
1668 down(&dir->d_inode->i_sem); 1668 mutex_lock(&dir->d_inode->i_mutex);
1669 path.dentry = lookup_hash(nd); 1669 path.dentry = lookup_hash(nd);
1670 path.mnt = nd->mnt; 1670 path.mnt = nd->mnt;
1671 __putname(nd->last.name); 1671 __putname(nd->last.name);
@@ -1680,13 +1680,13 @@ do_link:
1680 * Simple function to lookup and return a dentry and create it 1680 * Simple function to lookup and return a dentry and create it
1681 * if it doesn't exist. Is SMP-safe. 1681 * if it doesn't exist. Is SMP-safe.
1682 * 1682 *
1683 * Returns with nd->dentry->d_inode->i_sem locked. 1683 * Returns with nd->dentry->d_inode->i_mutex locked.
1684 */ 1684 */
1685struct dentry *lookup_create(struct nameidata *nd, int is_dir) 1685struct dentry *lookup_create(struct nameidata *nd, int is_dir)
1686{ 1686{
1687 struct dentry *dentry = ERR_PTR(-EEXIST); 1687 struct dentry *dentry = ERR_PTR(-EEXIST);
1688 1688
1689 down(&nd->dentry->d_inode->i_sem); 1689 mutex_lock(&nd->dentry->d_inode->i_mutex);
1690 /* 1690 /*
1691 * Yucky last component or no last component at all? 1691 * Yucky last component or no last component at all?
1692 * (foo/., foo/.., /////) 1692 * (foo/., foo/.., /////)
@@ -1784,7 +1784,7 @@ asmlinkage long sys_mknod(const char __user * filename, int mode, unsigned dev)
1784 } 1784 }
1785 dput(dentry); 1785 dput(dentry);
1786 } 1786 }
1787 up(&nd.dentry->d_inode->i_sem); 1787 mutex_unlock(&nd.dentry->d_inode->i_mutex);
1788 path_release(&nd); 1788 path_release(&nd);
1789out: 1789out:
1790 putname(tmp); 1790 putname(tmp);
@@ -1836,7 +1836,7 @@ asmlinkage long sys_mkdir(const char __user * pathname, int mode)
1836 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); 1836 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
1837 dput(dentry); 1837 dput(dentry);
1838 } 1838 }
1839 up(&nd.dentry->d_inode->i_sem); 1839 mutex_unlock(&nd.dentry->d_inode->i_mutex);
1840 path_release(&nd); 1840 path_release(&nd);
1841out: 1841out:
1842 putname(tmp); 1842 putname(tmp);
@@ -1885,7 +1885,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
1885 1885
1886 DQUOT_INIT(dir); 1886 DQUOT_INIT(dir);
1887 1887
1888 down(&dentry->d_inode->i_sem); 1888 mutex_lock(&dentry->d_inode->i_mutex);
1889 dentry_unhash(dentry); 1889 dentry_unhash(dentry);
1890 if (d_mountpoint(dentry)) 1890 if (d_mountpoint(dentry))
1891 error = -EBUSY; 1891 error = -EBUSY;
@@ -1897,7 +1897,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
1897 dentry->d_inode->i_flags |= S_DEAD; 1897 dentry->d_inode->i_flags |= S_DEAD;
1898 } 1898 }
1899 } 1899 }
1900 up(&dentry->d_inode->i_sem); 1900 mutex_unlock(&dentry->d_inode->i_mutex);
1901 if (!error) { 1901 if (!error) {
1902 d_delete(dentry); 1902 d_delete(dentry);
1903 } 1903 }
@@ -1932,14 +1932,14 @@ asmlinkage long sys_rmdir(const char __user * pathname)
1932 error = -EBUSY; 1932 error = -EBUSY;
1933 goto exit1; 1933 goto exit1;
1934 } 1934 }
1935 down(&nd.dentry->d_inode->i_sem); 1935 mutex_lock(&nd.dentry->d_inode->i_mutex);
1936 dentry = lookup_hash(&nd); 1936 dentry = lookup_hash(&nd);
1937 error = PTR_ERR(dentry); 1937 error = PTR_ERR(dentry);
1938 if (!IS_ERR(dentry)) { 1938 if (!IS_ERR(dentry)) {
1939 error = vfs_rmdir(nd.dentry->d_inode, dentry); 1939 error = vfs_rmdir(nd.dentry->d_inode, dentry);
1940 dput(dentry); 1940 dput(dentry);
1941 } 1941 }
1942 up(&nd.dentry->d_inode->i_sem); 1942 mutex_unlock(&nd.dentry->d_inode->i_mutex);
1943exit1: 1943exit1:
1944 path_release(&nd); 1944 path_release(&nd);
1945exit: 1945exit:
@@ -1959,7 +1959,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
1959 1959
1960 DQUOT_INIT(dir); 1960 DQUOT_INIT(dir);
1961 1961
1962 down(&dentry->d_inode->i_sem); 1962 mutex_lock(&dentry->d_inode->i_mutex);
1963 if (d_mountpoint(dentry)) 1963 if (d_mountpoint(dentry))
1964 error = -EBUSY; 1964 error = -EBUSY;
1965 else { 1965 else {
@@ -1967,7 +1967,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
1967 if (!error) 1967 if (!error)
1968 error = dir->i_op->unlink(dir, dentry); 1968 error = dir->i_op->unlink(dir, dentry);
1969 } 1969 }
1970 up(&dentry->d_inode->i_sem); 1970 mutex_unlock(&dentry->d_inode->i_mutex);
1971 1971
1972 /* We don't d_delete() NFS sillyrenamed files--they still exist. */ 1972 /* We don't d_delete() NFS sillyrenamed files--they still exist. */
1973 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) { 1973 if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
@@ -1979,7 +1979,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
1979 1979
1980/* 1980/*
1981 * Make sure that the actual truncation of the file will occur outside its 1981 * Make sure that the actual truncation of the file will occur outside its
1982 * directory's i_sem. Truncate can take a long time if there is a lot of 1982 * directory's i_mutex. Truncate can take a long time if there is a lot of
1983 * writeout happening, and we don't want to prevent access to the directory 1983 * writeout happening, and we don't want to prevent access to the directory
1984 * while waiting on the I/O. 1984 * while waiting on the I/O.
1985 */ 1985 */
@@ -2001,7 +2001,7 @@ asmlinkage long sys_unlink(const char __user * pathname)
2001 error = -EISDIR; 2001 error = -EISDIR;
2002 if (nd.last_type != LAST_NORM) 2002 if (nd.last_type != LAST_NORM)
2003 goto exit1; 2003 goto exit1;
2004 down(&nd.dentry->d_inode->i_sem); 2004 mutex_lock(&nd.dentry->d_inode->i_mutex);
2005 dentry = lookup_hash(&nd); 2005 dentry = lookup_hash(&nd);
2006 error = PTR_ERR(dentry); 2006 error = PTR_ERR(dentry);
2007 if (!IS_ERR(dentry)) { 2007 if (!IS_ERR(dentry)) {
@@ -2015,7 +2015,7 @@ asmlinkage long sys_unlink(const char __user * pathname)
2015 exit2: 2015 exit2:
2016 dput(dentry); 2016 dput(dentry);
2017 } 2017 }
2018 up(&nd.dentry->d_inode->i_sem); 2018 mutex_unlock(&nd.dentry->d_inode->i_mutex);
2019 if (inode) 2019 if (inode)
2020 iput(inode); /* truncate the inode here */ 2020 iput(inode); /* truncate the inode here */
2021exit1: 2021exit1:
@@ -2075,7 +2075,7 @@ asmlinkage long sys_symlink(const char __user * oldname, const char __user * new
2075 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); 2075 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
2076 dput(dentry); 2076 dput(dentry);
2077 } 2077 }
2078 up(&nd.dentry->d_inode->i_sem); 2078 mutex_unlock(&nd.dentry->d_inode->i_mutex);
2079 path_release(&nd); 2079 path_release(&nd);
2080out: 2080out:
2081 putname(to); 2081 putname(to);
@@ -2113,10 +2113,10 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
2113 if (error) 2113 if (error)
2114 return error; 2114 return error;
2115 2115
2116 down(&old_dentry->d_inode->i_sem); 2116 mutex_lock(&old_dentry->d_inode->i_mutex);
2117 DQUOT_INIT(dir); 2117 DQUOT_INIT(dir);
2118 error = dir->i_op->link(old_dentry, dir, new_dentry); 2118 error = dir->i_op->link(old_dentry, dir, new_dentry);
2119 up(&old_dentry->d_inode->i_sem); 2119 mutex_unlock(&old_dentry->d_inode->i_mutex);
2120 if (!error) 2120 if (!error)
2121 fsnotify_create(dir, new_dentry->d_name.name); 2121 fsnotify_create(dir, new_dentry->d_name.name);
2122 return error; 2122 return error;
@@ -2157,7 +2157,7 @@ asmlinkage long sys_link(const char __user * oldname, const char __user * newnam
2157 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); 2157 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
2158 dput(new_dentry); 2158 dput(new_dentry);
2159 } 2159 }
2160 up(&nd.dentry->d_inode->i_sem); 2160 mutex_unlock(&nd.dentry->d_inode->i_mutex);
2161out_release: 2161out_release:
2162 path_release(&nd); 2162 path_release(&nd);
2163out: 2163out:
@@ -2178,7 +2178,7 @@ exit:
2178 * sb->s_vfs_rename_sem. We might be more accurate, but that's another 2178 * sb->s_vfs_rename_sem. We might be more accurate, but that's another
2179 * story. 2179 * story.
2180 * c) we have to lock _three_ objects - parents and victim (if it exists). 2180 * c) we have to lock _three_ objects - parents and victim (if it exists).
2181 * And that - after we got ->i_sem on parents (until then we don't know 2181 * And that - after we got ->i_mutex on parents (until then we don't know
2182 * whether the target exists). Solution: try to be smart with locking 2182 * whether the target exists). Solution: try to be smart with locking
2183 * order for inodes. We rely on the fact that tree topology may change 2183 * order for inodes. We rely on the fact that tree topology may change
2184 * only under ->s_vfs_rename_sem _and_ that parent of the object we 2184 * only under ->s_vfs_rename_sem _and_ that parent of the object we
@@ -2195,9 +2195,9 @@ exit:
2195 * stuff into VFS), but the former is not going away. Solution: the same 2195 * stuff into VFS), but the former is not going away. Solution: the same
2196 * trick as in rmdir(). 2196 * trick as in rmdir().
2197 * e) conversion from fhandle to dentry may come in the wrong moment - when 2197 * e) conversion from fhandle to dentry may come in the wrong moment - when
2198 * we are removing the target. Solution: we will have to grab ->i_sem 2198 * we are removing the target. Solution: we will have to grab ->i_mutex
2199 * in the fhandle_to_dentry code. [FIXME - current nfsfh.c relies on 2199 * in the fhandle_to_dentry code. [FIXME - current nfsfh.c relies on
2200 * ->i_sem on parents, which works but leads to some truely excessive 2200 * ->i_mutex on parents, which works but leads to some truely excessive
2201 * locking]. 2201 * locking].
2202 */ 2202 */
2203static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry, 2203static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
@@ -2222,7 +2222,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
2222 2222
2223 target = new_dentry->d_inode; 2223 target = new_dentry->d_inode;
2224 if (target) { 2224 if (target) {
2225 down(&target->i_sem); 2225 mutex_lock(&target->i_mutex);
2226 dentry_unhash(new_dentry); 2226 dentry_unhash(new_dentry);
2227 } 2227 }
2228 if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) 2228 if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
@@ -2232,7 +2232,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
2232 if (target) { 2232 if (target) {
2233 if (!error) 2233 if (!error)
2234 target->i_flags |= S_DEAD; 2234 target->i_flags |= S_DEAD;
2235 up(&target->i_sem); 2235 mutex_unlock(&target->i_mutex);
2236 if (d_unhashed(new_dentry)) 2236 if (d_unhashed(new_dentry))
2237 d_rehash(new_dentry); 2237 d_rehash(new_dentry);
2238 dput(new_dentry); 2238 dput(new_dentry);
@@ -2255,7 +2255,7 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
2255 dget(new_dentry); 2255 dget(new_dentry);
2256 target = new_dentry->d_inode; 2256 target = new_dentry->d_inode;
2257 if (target) 2257 if (target)
2258 down(&target->i_sem); 2258 mutex_lock(&target->i_mutex);
2259 if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry)) 2259 if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
2260 error = -EBUSY; 2260 error = -EBUSY;
2261 else 2261 else
@@ -2266,7 +2266,7 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
2266 d_move(old_dentry, new_dentry); 2266 d_move(old_dentry, new_dentry);
2267 } 2267 }
2268 if (target) 2268 if (target)
2269 up(&target->i_sem); 2269 mutex_unlock(&target->i_mutex);
2270 dput(new_dentry); 2270 dput(new_dentry);
2271 return error; 2271 return error;
2272} 2272}
diff --git a/fs/namespace.c b/fs/namespace.c
index 3e8fb61ad597..f0e353f5bc30 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -814,7 +814,7 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd)
814 return -ENOTDIR; 814 return -ENOTDIR;
815 815
816 err = -ENOENT; 816 err = -ENOENT;
817 down(&nd->dentry->d_inode->i_sem); 817 mutex_lock(&nd->dentry->d_inode->i_mutex);
818 if (IS_DEADDIR(nd->dentry->d_inode)) 818 if (IS_DEADDIR(nd->dentry->d_inode))
819 goto out_unlock; 819 goto out_unlock;
820 820
@@ -826,7 +826,7 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd)
826 if (IS_ROOT(nd->dentry) || !d_unhashed(nd->dentry)) 826 if (IS_ROOT(nd->dentry) || !d_unhashed(nd->dentry))
827 err = attach_recursive_mnt(mnt, nd, NULL); 827 err = attach_recursive_mnt(mnt, nd, NULL);
828out_unlock: 828out_unlock:
829 up(&nd->dentry->d_inode->i_sem); 829 mutex_unlock(&nd->dentry->d_inode->i_mutex);
830 if (!err) 830 if (!err)
831 security_sb_post_addmount(mnt, nd); 831 security_sb_post_addmount(mnt, nd);
832 return err; 832 return err;
@@ -962,7 +962,7 @@ static int do_move_mount(struct nameidata *nd, char *old_name)
962 goto out; 962 goto out;
963 963
964 err = -ENOENT; 964 err = -ENOENT;
965 down(&nd->dentry->d_inode->i_sem); 965 mutex_lock(&nd->dentry->d_inode->i_mutex);
966 if (IS_DEADDIR(nd->dentry->d_inode)) 966 if (IS_DEADDIR(nd->dentry->d_inode))
967 goto out1; 967 goto out1;
968 968
@@ -1004,7 +1004,7 @@ static int do_move_mount(struct nameidata *nd, char *old_name)
1004 list_del_init(&old_nd.mnt->mnt_expire); 1004 list_del_init(&old_nd.mnt->mnt_expire);
1005 spin_unlock(&vfsmount_lock); 1005 spin_unlock(&vfsmount_lock);
1006out1: 1006out1:
1007 up(&nd->dentry->d_inode->i_sem); 1007 mutex_unlock(&nd->dentry->d_inode->i_mutex);
1008out: 1008out:
1009 up_write(&namespace_sem); 1009 up_write(&namespace_sem);
1010 if (!err) 1010 if (!err)
@@ -1573,7 +1573,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1573 user_nd.dentry = dget(current->fs->root); 1573 user_nd.dentry = dget(current->fs->root);
1574 read_unlock(&current->fs->lock); 1574 read_unlock(&current->fs->lock);
1575 down_write(&namespace_sem); 1575 down_write(&namespace_sem);
1576 down(&old_nd.dentry->d_inode->i_sem); 1576 mutex_lock(&old_nd.dentry->d_inode->i_mutex);
1577 error = -EINVAL; 1577 error = -EINVAL;
1578 if (IS_MNT_SHARED(old_nd.mnt) || 1578 if (IS_MNT_SHARED(old_nd.mnt) ||
1579 IS_MNT_SHARED(new_nd.mnt->mnt_parent) || 1579 IS_MNT_SHARED(new_nd.mnt->mnt_parent) ||
@@ -1626,7 +1626,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1626 path_release(&root_parent); 1626 path_release(&root_parent);
1627 path_release(&parent_nd); 1627 path_release(&parent_nd);
1628out2: 1628out2:
1629 up(&old_nd.dentry->d_inode->i_sem); 1629 mutex_unlock(&old_nd.dentry->d_inode->i_mutex);
1630 up_write(&namespace_sem); 1630 up_write(&namespace_sem);
1631 path_release(&user_nd); 1631 path_release(&user_nd);
1632 path_release(&old_nd); 1632 path_release(&old_nd);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index e9255198f767..a1554bead692 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -194,7 +194,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
194 spin_unlock(&inode->i_lock); 194 spin_unlock(&inode->i_lock);
195 /* Ensure consistent page alignment of the data. 195 /* Ensure consistent page alignment of the data.
196 * Note: assumes we have exclusive access to this mapping either 196 * Note: assumes we have exclusive access to this mapping either
197 * through inode->i_sem or some other mechanism. 197 * through inode->i_mutex or some other mechanism.
198 */ 198 */
199 if (page->index == 0) 199 if (page->index == 0)
200 invalidate_inode_pages2_range(inode->i_mapping, PAGE_CACHE_SIZE, -1); 200 invalidate_inode_pages2_range(inode->i_mapping, PAGE_CACHE_SIZE, -1);
@@ -573,7 +573,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
573 573
574loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) 574loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
575{ 575{
576 down(&filp->f_dentry->d_inode->i_sem); 576 mutex_lock(&filp->f_dentry->d_inode->i_mutex);
577 switch (origin) { 577 switch (origin) {
578 case 1: 578 case 1:
579 offset += filp->f_pos; 579 offset += filp->f_pos;
@@ -589,7 +589,7 @@ loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin)
589 ((struct nfs_open_context *)filp->private_data)->dir_cookie = 0; 589 ((struct nfs_open_context *)filp->private_data)->dir_cookie = 0;
590 } 590 }
591out: 591out:
592 up(&filp->f_dentry->d_inode->i_sem); 592 mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
593 return offset; 593 return offset;
594} 594}
595 595
@@ -1001,7 +1001,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
1001 openflags &= ~(O_CREAT|O_TRUNC); 1001 openflags &= ~(O_CREAT|O_TRUNC);
1002 1002
1003 /* 1003 /*
1004 * Note: we're not holding inode->i_sem and so may be racing with 1004 * Note: we're not holding inode->i_mutex and so may be racing with
1005 * operations that change the directory. We therefore save the 1005 * operations that change the directory. We therefore save the
1006 * change attribute *before* we do the RPC call. 1006 * change attribute *before* we do the RPC call.
1007 */ 1007 */
@@ -1051,7 +1051,7 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
1051 return dentry; 1051 return dentry;
1052 if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR)) 1052 if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR))
1053 return NULL; 1053 return NULL;
1054 /* Note: caller is already holding the dir->i_sem! */ 1054 /* Note: caller is already holding the dir->i_mutex! */
1055 dentry = d_alloc(parent, &name); 1055 dentry = d_alloc(parent, &name);
1056 if (dentry == NULL) 1056 if (dentry == NULL)
1057 return NULL; 1057 return NULL;
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 954cf893d50c..be963a133aaa 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -121,9 +121,9 @@ out:
121static void 121static void
122nfsd4_sync_rec_dir(void) 122nfsd4_sync_rec_dir(void)
123{ 123{
124 down(&rec_dir.dentry->d_inode->i_sem); 124 mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
125 nfsd_sync_dir(rec_dir.dentry); 125 nfsd_sync_dir(rec_dir.dentry);
126 up(&rec_dir.dentry->d_inode->i_sem); 126 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
127} 127}
128 128
129int 129int
@@ -143,7 +143,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
143 nfs4_save_user(&uid, &gid); 143 nfs4_save_user(&uid, &gid);
144 144
145 /* lock the parent */ 145 /* lock the parent */
146 down(&rec_dir.dentry->d_inode->i_sem); 146 mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
147 147
148 dentry = lookup_one_len(dname, rec_dir.dentry, HEXDIR_LEN-1); 148 dentry = lookup_one_len(dname, rec_dir.dentry, HEXDIR_LEN-1);
149 if (IS_ERR(dentry)) { 149 if (IS_ERR(dentry)) {
@@ -159,7 +159,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
159out_put: 159out_put:
160 dput(dentry); 160 dput(dentry);
161out_unlock: 161out_unlock:
162 up(&rec_dir.dentry->d_inode->i_sem); 162 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
163 if (status == 0) { 163 if (status == 0) {
164 clp->cl_firststate = 1; 164 clp->cl_firststate = 1;
165 nfsd4_sync_rec_dir(); 165 nfsd4_sync_rec_dir();
@@ -259,9 +259,9 @@ nfsd4_remove_clid_file(struct dentry *dir, struct dentry *dentry)
259 printk("nfsd4: non-file found in client recovery directory\n"); 259 printk("nfsd4: non-file found in client recovery directory\n");
260 return -EINVAL; 260 return -EINVAL;
261 } 261 }
262 down(&dir->d_inode->i_sem); 262 mutex_lock(&dir->d_inode->i_mutex);
263 status = vfs_unlink(dir->d_inode, dentry); 263 status = vfs_unlink(dir->d_inode, dentry);
264 up(&dir->d_inode->i_sem); 264 mutex_unlock(&dir->d_inode->i_mutex);
265 return status; 265 return status;
266} 266}
267 267
@@ -274,9 +274,9 @@ nfsd4_clear_clid_dir(struct dentry *dir, struct dentry *dentry)
274 * any regular files anyway, just in case the directory was created by 274 * any regular files anyway, just in case the directory was created by
275 * a kernel from the future.... */ 275 * a kernel from the future.... */
276 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file); 276 nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file);
277 down(&dir->d_inode->i_sem); 277 mutex_lock(&dir->d_inode->i_mutex);
278 status = vfs_rmdir(dir->d_inode, dentry); 278 status = vfs_rmdir(dir->d_inode, dentry);
279 up(&dir->d_inode->i_sem); 279 mutex_unlock(&dir->d_inode->i_mutex);
280 return status; 280 return status;
281} 281}
282 282
@@ -288,9 +288,9 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
288 288
289 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); 289 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name);
290 290
291 down(&rec_dir.dentry->d_inode->i_sem); 291 mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
292 dentry = lookup_one_len(name, rec_dir.dentry, namlen); 292 dentry = lookup_one_len(name, rec_dir.dentry, namlen);
293 up(&rec_dir.dentry->d_inode->i_sem); 293 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
294 if (IS_ERR(dentry)) { 294 if (IS_ERR(dentry)) {
295 status = PTR_ERR(dentry); 295 status = PTR_ERR(dentry);
296 return status; 296 return status;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index df4019f04560..bb36b4304491 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -390,12 +390,12 @@ set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key)
390 390
391 error = -EOPNOTSUPP; 391 error = -EOPNOTSUPP;
392 if (inode->i_op && inode->i_op->setxattr) { 392 if (inode->i_op && inode->i_op->setxattr) {
393 down(&inode->i_sem); 393 mutex_lock(&inode->i_mutex);
394 security_inode_setxattr(dentry, key, buf, len, 0); 394 security_inode_setxattr(dentry, key, buf, len, 0);
395 error = inode->i_op->setxattr(dentry, key, buf, len, 0); 395 error = inode->i_op->setxattr(dentry, key, buf, len, 0);
396 if (!error) 396 if (!error)
397 security_inode_post_setxattr(dentry, key, buf, len, 0); 397 security_inode_post_setxattr(dentry, key, buf, len, 0);
398 up(&inode->i_sem); 398 mutex_unlock(&inode->i_mutex);
399 } 399 }
400out: 400out:
401 kfree(buf); 401 kfree(buf);
@@ -739,9 +739,9 @@ nfsd_sync(struct file *filp)
739 int err; 739 int err;
740 struct inode *inode = filp->f_dentry->d_inode; 740 struct inode *inode = filp->f_dentry->d_inode;
741 dprintk("nfsd: sync file %s\n", filp->f_dentry->d_name.name); 741 dprintk("nfsd: sync file %s\n", filp->f_dentry->d_name.name);
742 down(&inode->i_sem); 742 mutex_lock(&inode->i_mutex);
743 err=nfsd_dosync(filp, filp->f_dentry, filp->f_op); 743 err=nfsd_dosync(filp, filp->f_dentry, filp->f_op);
744 up(&inode->i_sem); 744 mutex_unlock(&inode->i_mutex);
745 745
746 return err; 746 return err;
747} 747}
@@ -885,9 +885,9 @@ static void kill_suid(struct dentry *dentry)
885 struct iattr ia; 885 struct iattr ia;
886 ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID; 886 ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID;
887 887
888 down(&dentry->d_inode->i_sem); 888 mutex_lock(&dentry->d_inode->i_mutex);
889 notify_change(dentry, &ia); 889 notify_change(dentry, &ia);
890 up(&dentry->d_inode->i_sem); 890 mutex_unlock(&dentry->d_inode->i_mutex);
891} 891}
892 892
893static inline int 893static inline int
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index eda056bac256..9480a0526cd3 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -1532,7 +1532,7 @@ int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
1532 * NOTE to self: No changes in the attribute list are required to move from 1532 * NOTE to self: No changes in the attribute list are required to move from
1533 * a resident to a non-resident attribute. 1533 * a resident to a non-resident attribute.
1534 * 1534 *
1535 * Locking: - The caller must hold i_sem on the inode. 1535 * Locking: - The caller must hold i_mutex on the inode.
1536 */ 1536 */
1537int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size) 1537int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
1538{ 1538{
@@ -1728,7 +1728,7 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
1728 /* 1728 /*
1729 * This needs to be last since the address space operations ->readpage 1729 * This needs to be last since the address space operations ->readpage
1730 * and ->writepage can run concurrently with us as they are not 1730 * and ->writepage can run concurrently with us as they are not
1731 * serialized on i_sem. Note, we are not allowed to fail once we flip 1731 * serialized on i_mutex. Note, we are not allowed to fail once we flip
1732 * this switch, which is another reason to do this last. 1732 * this switch, which is another reason to do this last.
1733 */ 1733 */
1734 NInoSetNonResident(ni); 1734 NInoSetNonResident(ni);
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 795c3d1930f5..b0690d4c8906 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -69,7 +69,7 @@ ntfschar I30[5] = { const_cpu_to_le16('$'), const_cpu_to_le16('I'),
69 * work but we don't care for how quickly one can access them. This also fixes 69 * work but we don't care for how quickly one can access them. This also fixes
70 * the dcache aliasing issues. 70 * the dcache aliasing issues.
71 * 71 *
72 * Locking: - Caller must hold i_sem on the directory. 72 * Locking: - Caller must hold i_mutex on the directory.
73 * - Each page cache page in the index allocation mapping must be 73 * - Each page cache page in the index allocation mapping must be
74 * locked whilst being accessed otherwise we may find a corrupt 74 * locked whilst being accessed otherwise we may find a corrupt
75 * page due to it being under ->writepage at the moment which 75 * page due to it being under ->writepage at the moment which
@@ -1085,11 +1085,11 @@ static inline int ntfs_filldir(ntfs_volume *vol, loff_t fpos,
1085 * While this will return the names in random order this doesn't matter for 1085 * While this will return the names in random order this doesn't matter for
1086 * ->readdir but OTOH results in a faster ->readdir. 1086 * ->readdir but OTOH results in a faster ->readdir.
1087 * 1087 *
1088 * VFS calls ->readdir without BKL but with i_sem held. This protects the VFS 1088 * VFS calls ->readdir without BKL but with i_mutex held. This protects the VFS
1089 * parts (e.g. ->f_pos and ->i_size, and it also protects against directory 1089 * parts (e.g. ->f_pos and ->i_size, and it also protects against directory
1090 * modifications). 1090 * modifications).
1091 * 1091 *
1092 * Locking: - Caller must hold i_sem on the directory. 1092 * Locking: - Caller must hold i_mutex on the directory.
1093 * - Each page cache page in the index allocation mapping must be 1093 * - Each page cache page in the index allocation mapping must be
1094 * locked whilst being accessed otherwise we may find a corrupt 1094 * locked whilst being accessed otherwise we may find a corrupt
1095 * page due to it being under ->writepage at the moment which 1095 * page due to it being under ->writepage at the moment which
@@ -1520,7 +1520,7 @@ static int ntfs_dir_open(struct inode *vi, struct file *filp)
1520 * Note: In the past @filp could be NULL so we ignore it as we don't need it 1520 * Note: In the past @filp could be NULL so we ignore it as we don't need it
1521 * anyway. 1521 * anyway.
1522 * 1522 *
1523 * Locking: Caller must hold i_sem on the inode. 1523 * Locking: Caller must hold i_mutex on the inode.
1524 * 1524 *
1525 * TODO: We should probably also write all attribute/index inodes associated 1525 * TODO: We should probably also write all attribute/index inodes associated
1526 * with this inode but since we have no simple way of getting to them we ignore 1526 * with this inode but since we have no simple way of getting to them we ignore
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 727533891813..30f71acdc1cb 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -106,7 +106,7 @@ static int ntfs_file_open(struct inode *vi, struct file *filp)
106 * this is the case, the necessary zeroing will also have happened and that all 106 * this is the case, the necessary zeroing will also have happened and that all
107 * metadata is self-consistent. 107 * metadata is self-consistent.
108 * 108 *
109 * Locking: i_sem on the vfs inode corrseponsind to the ntfs inode @ni must be 109 * Locking: i_mutex on the vfs inode corrseponsind to the ntfs inode @ni must be
110 * held by the caller. 110 * held by the caller.
111 */ 111 */
112static int ntfs_attr_extend_initialized(ntfs_inode *ni, const s64 new_init_size, 112static int ntfs_attr_extend_initialized(ntfs_inode *ni, const s64 new_init_size,
@@ -473,7 +473,7 @@ static inline int ntfs_submit_bh_for_read(struct buffer_head *bh)
473 * @bytes: number of bytes to be written 473 * @bytes: number of bytes to be written
474 * 474 *
475 * This is called for non-resident attributes from ntfs_file_buffered_write() 475 * This is called for non-resident attributes from ntfs_file_buffered_write()
476 * with i_sem held on the inode (@pages[0]->mapping->host). There are 476 * with i_mutex held on the inode (@pages[0]->mapping->host). There are
477 * @nr_pages pages in @pages which are locked but not kmap()ped. The source 477 * @nr_pages pages in @pages which are locked but not kmap()ped. The source
478 * data has not yet been copied into the @pages. 478 * data has not yet been copied into the @pages.
479 * 479 *
@@ -1637,7 +1637,7 @@ err_out:
1637 * @pos: byte position in file at which the write begins 1637 * @pos: byte position in file at which the write begins
1638 * @bytes: number of bytes to be written 1638 * @bytes: number of bytes to be written
1639 * 1639 *
1640 * This is called from ntfs_file_buffered_write() with i_sem held on the inode 1640 * This is called from ntfs_file_buffered_write() with i_mutex held on the inode
1641 * (@pages[0]->mapping->host). There are @nr_pages pages in @pages which are 1641 * (@pages[0]->mapping->host). There are @nr_pages pages in @pages which are
1642 * locked but not kmap()ped. The source data has already been copied into the 1642 * locked but not kmap()ped. The source data has already been copied into the
1643 * @page. ntfs_prepare_pages_for_non_resident_write() has been called before 1643 * @page. ntfs_prepare_pages_for_non_resident_write() has been called before
@@ -1814,7 +1814,7 @@ err_out:
1814/** 1814/**
1815 * ntfs_file_buffered_write - 1815 * ntfs_file_buffered_write -
1816 * 1816 *
1817 * Locking: The vfs is holding ->i_sem on the inode. 1817 * Locking: The vfs is holding ->i_mutex on the inode.
1818 */ 1818 */
1819static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, 1819static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
1820 const struct iovec *iov, unsigned long nr_segs, 1820 const struct iovec *iov, unsigned long nr_segs,
@@ -2196,9 +2196,9 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const char __user *buf,
2196 2196
2197 BUG_ON(iocb->ki_pos != pos); 2197 BUG_ON(iocb->ki_pos != pos);
2198 2198
2199 down(&inode->i_sem); 2199 mutex_lock(&inode->i_mutex);
2200 ret = ntfs_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); 2200 ret = ntfs_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos);
2201 up(&inode->i_sem); 2201 mutex_unlock(&inode->i_mutex);
2202 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { 2202 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2203 int err = sync_page_range(inode, mapping, pos, ret); 2203 int err = sync_page_range(inode, mapping, pos, ret);
2204 if (err < 0) 2204 if (err < 0)
@@ -2221,12 +2221,12 @@ static ssize_t ntfs_file_writev(struct file *file, const struct iovec *iov,
2221 struct kiocb kiocb; 2221 struct kiocb kiocb;
2222 ssize_t ret; 2222 ssize_t ret;
2223 2223
2224 down(&inode->i_sem); 2224 mutex_lock(&inode->i_mutex);
2225 init_sync_kiocb(&kiocb, file); 2225 init_sync_kiocb(&kiocb, file);
2226 ret = ntfs_file_aio_write_nolock(&kiocb, iov, nr_segs, ppos); 2226 ret = ntfs_file_aio_write_nolock(&kiocb, iov, nr_segs, ppos);
2227 if (ret == -EIOCBQUEUED) 2227 if (ret == -EIOCBQUEUED)
2228 ret = wait_on_sync_kiocb(&kiocb); 2228 ret = wait_on_sync_kiocb(&kiocb);
2229 up(&inode->i_sem); 2229 mutex_unlock(&inode->i_mutex);
2230 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { 2230 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2231 int err = sync_page_range(inode, mapping, *ppos - ret, ret); 2231 int err = sync_page_range(inode, mapping, *ppos - ret, ret);
2232 if (err < 0) 2232 if (err < 0)
@@ -2269,7 +2269,7 @@ static ssize_t ntfs_file_write(struct file *file, const char __user *buf,
2269 * Note: In the past @filp could be NULL so we ignore it as we don't need it 2269 * Note: In the past @filp could be NULL so we ignore it as we don't need it
2270 * anyway. 2270 * anyway.
2271 * 2271 *
2272 * Locking: Caller must hold i_sem on the inode. 2272 * Locking: Caller must hold i_mutex on the inode.
2273 * 2273 *
2274 * TODO: We should probably also write all attribute/index inodes associated 2274 * TODO: We should probably also write all attribute/index inodes associated
2275 * with this inode but since we have no simple way of getting to them we ignore 2275 * with this inode but since we have no simple way of getting to them we ignore
diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c
index 8f2d5727546f..9f5427c2d105 100644
--- a/fs/ntfs/index.c
+++ b/fs/ntfs/index.c
@@ -32,7 +32,7 @@
32 * Allocate a new index context, initialize it with @idx_ni and return it. 32 * Allocate a new index context, initialize it with @idx_ni and return it.
33 * Return NULL if allocation failed. 33 * Return NULL if allocation failed.
34 * 34 *
35 * Locking: Caller must hold i_sem on the index inode. 35 * Locking: Caller must hold i_mutex on the index inode.
36 */ 36 */
37ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni) 37ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni)
38{ 38{
@@ -50,7 +50,7 @@ ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni)
50 * 50 *
51 * Release the index context @ictx, releasing all associated resources. 51 * Release the index context @ictx, releasing all associated resources.
52 * 52 *
53 * Locking: Caller must hold i_sem on the index inode. 53 * Locking: Caller must hold i_mutex on the index inode.
54 */ 54 */
55void ntfs_index_ctx_put(ntfs_index_context *ictx) 55void ntfs_index_ctx_put(ntfs_index_context *ictx)
56{ 56{
@@ -106,7 +106,7 @@ void ntfs_index_ctx_put(ntfs_index_context *ictx)
106 * or ntfs_index_entry_write() before the call to ntfs_index_ctx_put() to 106 * or ntfs_index_entry_write() before the call to ntfs_index_ctx_put() to
107 * ensure that the changes are written to disk. 107 * ensure that the changes are written to disk.
108 * 108 *
109 * Locking: - Caller must hold i_sem on the index inode. 109 * Locking: - Caller must hold i_mutex on the index inode.
110 * - Each page cache page in the index allocation mapping must be 110 * - Each page cache page in the index allocation mapping must be
111 * locked whilst being accessed otherwise we may find a corrupt 111 * locked whilst being accessed otherwise we may find a corrupt
112 * page due to it being under ->writepage at the moment which 112 * page due to it being under ->writepage at the moment which
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index b24f4c4b2c5c..bda7a08911a5 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2125,13 +2125,13 @@ void ntfs_put_inode(struct inode *vi)
2125 ntfs_inode *ni = NTFS_I(vi); 2125 ntfs_inode *ni = NTFS_I(vi);
2126 if (NInoIndexAllocPresent(ni)) { 2126 if (NInoIndexAllocPresent(ni)) {
2127 struct inode *bvi = NULL; 2127 struct inode *bvi = NULL;
2128 down(&vi->i_sem); 2128 mutex_lock(&vi->i_mutex);
2129 if (atomic_read(&vi->i_count) == 2) { 2129 if (atomic_read(&vi->i_count) == 2) {
2130 bvi = ni->itype.index.bmp_ino; 2130 bvi = ni->itype.index.bmp_ino;
2131 if (bvi) 2131 if (bvi)
2132 ni->itype.index.bmp_ino = NULL; 2132 ni->itype.index.bmp_ino = NULL;
2133 } 2133 }
2134 up(&vi->i_sem); 2134 mutex_unlock(&vi->i_mutex);
2135 if (bvi) 2135 if (bvi)
2136 iput(bvi); 2136 iput(bvi);
2137 } 2137 }
@@ -2311,7 +2311,7 @@ static const char *es = " Leaving inconsistent metadata. Unmount and run "
2311 * 2311 *
2312 * Returns 0 on success or -errno on error. 2312 * Returns 0 on success or -errno on error.
2313 * 2313 *
2314 * Called with ->i_sem held. In all but one case ->i_alloc_sem is held for 2314 * Called with ->i_mutex held. In all but one case ->i_alloc_sem is held for
2315 * writing. The only case in the kernel where ->i_alloc_sem is not held is 2315 * writing. The only case in the kernel where ->i_alloc_sem is not held is
2316 * mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called 2316 * mm/filemap.c::generic_file_buffered_write() where vmtruncate() is called
2317 * with the current i_size as the offset. The analogous place in NTFS is in 2317 * with the current i_size as the offset. The analogous place in NTFS is in
@@ -2831,7 +2831,7 @@ void ntfs_truncate_vfs(struct inode *vi) {
2831 * We also abort all changes of user, group, and mode as we do not implement 2831 * We also abort all changes of user, group, and mode as we do not implement
2832 * the NTFS ACLs yet. 2832 * the NTFS ACLs yet.
2833 * 2833 *
2834 * Called with ->i_sem held. For the ATTR_SIZE (i.e. ->truncate) case, also 2834 * Called with ->i_mutex held. For the ATTR_SIZE (i.e. ->truncate) case, also
2835 * called with ->i_alloc_sem held for writing. 2835 * called with ->i_alloc_sem held for writing.
2836 * 2836 *
2837 * Basically this is a copy of generic notify_change() and inode_setattr() 2837 * Basically this is a copy of generic notify_change() and inode_setattr()
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 351dbc3b6e40..5ea9eb93af62 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -96,7 +96,7 @@
96 * name. We then convert the name to the current NLS code page, and proceed 96 * name. We then convert the name to the current NLS code page, and proceed
97 * searching for a dentry with this name, etc, as in case 2), above. 97 * searching for a dentry with this name, etc, as in case 2), above.
98 * 98 *
99 * Locking: Caller must hold i_sem on the directory. 99 * Locking: Caller must hold i_mutex on the directory.
100 */ 100 */
101static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent, 101static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
102 struct nameidata *nd) 102 struct nameidata *nd)
@@ -254,7 +254,7 @@ handle_name:
254 nls_name.hash = full_name_hash(nls_name.name, nls_name.len); 254 nls_name.hash = full_name_hash(nls_name.name, nls_name.len);
255 255
256 /* 256 /*
257 * Note: No need for dent->d_lock lock as i_sem is held on the 257 * Note: No need for dent->d_lock lock as i_mutex is held on the
258 * parent inode. 258 * parent inode.
259 */ 259 */
260 260
@@ -374,7 +374,7 @@ struct inode_operations ntfs_dir_inode_ops = {
374 * The code is based on the ext3 ->get_parent() implementation found in 374 * The code is based on the ext3 ->get_parent() implementation found in
375 * fs/ext3/namei.c::ext3_get_parent(). 375 * fs/ext3/namei.c::ext3_get_parent().
376 * 376 *
377 * Note: ntfs_get_parent() is called with @child_dent->d_inode->i_sem down. 377 * Note: ntfs_get_parent() is called with @child_dent->d_inode->i_mutex down.
378 * 378 *
379 * Return the dentry of the parent directory on success or the error code on 379 * Return the dentry of the parent directory on success or the error code on
380 * error (IS_ERR() is true). 380 * error (IS_ERR() is true).
diff --git a/fs/ntfs/quota.c b/fs/ntfs/quota.c
index 833df2a4e9fb..d0ef4182147b 100644
--- a/fs/ntfs/quota.c
+++ b/fs/ntfs/quota.c
@@ -48,7 +48,7 @@ BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
48 ntfs_error(vol->sb, "Quota inodes are not open."); 48 ntfs_error(vol->sb, "Quota inodes are not open.");
49 return FALSE; 49 return FALSE;
50 } 50 }
51 down(&vol->quota_q_ino->i_sem); 51 mutex_lock(&vol->quota_q_ino->i_mutex);
52 ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino)); 52 ictx = ntfs_index_ctx_get(NTFS_I(vol->quota_q_ino));
53 if (!ictx) { 53 if (!ictx) {
54 ntfs_error(vol->sb, "Failed to get index context."); 54 ntfs_error(vol->sb, "Failed to get index context.");
@@ -98,7 +98,7 @@ BOOL ntfs_mark_quotas_out_of_date(ntfs_volume *vol)
98 ntfs_index_entry_mark_dirty(ictx); 98 ntfs_index_entry_mark_dirty(ictx);
99set_done: 99set_done:
100 ntfs_index_ctx_put(ictx); 100 ntfs_index_ctx_put(ictx);
101 up(&vol->quota_q_ino->i_sem); 101 mutex_unlock(&vol->quota_q_ino->i_mutex);
102 /* 102 /*
103 * We set the flag so we do not try to mark the quotas out of date 103 * We set the flag so we do not try to mark the quotas out of date
104 * again on remount. 104 * again on remount.
@@ -110,7 +110,7 @@ done:
110err_out: 110err_out:
111 if (ictx) 111 if (ictx)
112 ntfs_index_ctx_put(ictx); 112 ntfs_index_ctx_put(ictx);
113 up(&vol->quota_q_ino->i_sem); 113 mutex_unlock(&vol->quota_q_ino->i_mutex);
114 return FALSE; 114 return FALSE;
115} 115}
116 116
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 6c16db9e1a8a..280e383fc84e 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1213,10 +1213,10 @@ static int check_windows_hibernation_status(ntfs_volume *vol)
1213 * Find the inode number for the hibernation file by looking up the 1213 * Find the inode number for the hibernation file by looking up the
1214 * filename hiberfil.sys in the root directory. 1214 * filename hiberfil.sys in the root directory.
1215 */ 1215 */
1216 down(&vol->root_ino->i_sem); 1216 mutex_lock(&vol->root_ino->i_mutex);
1217 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->root_ino), hiberfil, 12, 1217 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->root_ino), hiberfil, 12,
1218 &name); 1218 &name);
1219 up(&vol->root_ino->i_sem); 1219 mutex_unlock(&vol->root_ino->i_mutex);
1220 if (IS_ERR_MREF(mref)) { 1220 if (IS_ERR_MREF(mref)) {
1221 ret = MREF_ERR(mref); 1221 ret = MREF_ERR(mref);
1222 /* If the file does not exist, Windows is not hibernated. */ 1222 /* If the file does not exist, Windows is not hibernated. */
@@ -1307,10 +1307,10 @@ static BOOL load_and_init_quota(ntfs_volume *vol)
1307 * Find the inode number for the quota file by looking up the filename 1307 * Find the inode number for the quota file by looking up the filename
1308 * $Quota in the extended system files directory $Extend. 1308 * $Quota in the extended system files directory $Extend.
1309 */ 1309 */
1310 down(&vol->extend_ino->i_sem); 1310 mutex_lock(&vol->extend_ino->i_mutex);
1311 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), Quota, 6, 1311 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), Quota, 6,
1312 &name); 1312 &name);
1313 up(&vol->extend_ino->i_sem); 1313 mutex_unlock(&vol->extend_ino->i_mutex);
1314 if (IS_ERR_MREF(mref)) { 1314 if (IS_ERR_MREF(mref)) {
1315 /* 1315 /*
1316 * If the file does not exist, quotas are disabled and have 1316 * If the file does not exist, quotas are disabled and have
@@ -1390,10 +1390,10 @@ static BOOL load_and_init_usnjrnl(ntfs_volume *vol)
1390 * Find the inode number for the transaction log file by looking up the 1390 * Find the inode number for the transaction log file by looking up the
1391 * filename $UsnJrnl in the extended system files directory $Extend. 1391 * filename $UsnJrnl in the extended system files directory $Extend.
1392 */ 1392 */
1393 down(&vol->extend_ino->i_sem); 1393 mutex_lock(&vol->extend_ino->i_mutex);
1394 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), UsnJrnl, 8, 1394 mref = ntfs_lookup_inode_by_name(NTFS_I(vol->extend_ino), UsnJrnl, 8,
1395 &name); 1395 &name);
1396 up(&vol->extend_ino->i_sem); 1396 mutex_unlock(&vol->extend_ino->i_mutex);
1397 if (IS_ERR_MREF(mref)) { 1397 if (IS_ERR_MREF(mref)) {
1398 /* 1398 /*
1399 * If the file does not exist, transaction logging is disabled, 1399 * If the file does not exist, transaction logging is disabled,
@@ -2312,9 +2312,9 @@ static void ntfs_put_super(struct super_block *sb)
2312 if (!list_empty(&sb->s_dirty)) { 2312 if (!list_empty(&sb->s_dirty)) {
2313 const char *s1, *s2; 2313 const char *s1, *s2;
2314 2314
2315 down(&vol->mft_ino->i_sem); 2315 mutex_lock(&vol->mft_ino->i_mutex);
2316 truncate_inode_pages(vol->mft_ino->i_mapping, 0); 2316 truncate_inode_pages(vol->mft_ino->i_mapping, 0);
2317 up(&vol->mft_ino->i_sem); 2317 mutex_unlock(&vol->mft_ino->i_mutex);
2318 write_inode_now(vol->mft_ino, 1); 2318 write_inode_now(vol->mft_ino, 1);
2319 if (!list_empty(&sb->s_dirty)) { 2319 if (!list_empty(&sb->s_dirty)) {
2320 static const char *_s1 = "inodes"; 2320 static const char *_s1 = "inodes";
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 465f797451ee..6b9812db3779 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -966,7 +966,7 @@ static int ocfs2_truncate_log_append(struct ocfs2_super *osb,
966 mlog_entry("start_blk = %"MLFu64", num_clusters = %u\n", start_blk, 966 mlog_entry("start_blk = %"MLFu64", num_clusters = %u\n", start_blk,
967 num_clusters); 967 num_clusters);
968 968
969 BUG_ON(!down_trylock(&tl_inode->i_sem)); 969 BUG_ON(mutex_trylock(&tl_inode->i_mutex));
970 970
971 start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk); 971 start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk);
972 972
@@ -1108,7 +1108,7 @@ bail:
1108 return status; 1108 return status;
1109} 1109}
1110 1110
1111/* Expects you to already be holding tl_inode->i_sem */ 1111/* Expects you to already be holding tl_inode->i_mutex */
1112static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) 1112static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1113{ 1113{
1114 int status; 1114 int status;
@@ -1123,7 +1123,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1123 1123
1124 mlog_entry_void(); 1124 mlog_entry_void();
1125 1125
1126 BUG_ON(!down_trylock(&tl_inode->i_sem)); 1126 BUG_ON(mutex_trylock(&tl_inode->i_mutex));
1127 1127
1128 di = (struct ocfs2_dinode *) tl_bh->b_data; 1128 di = (struct ocfs2_dinode *) tl_bh->b_data;
1129 tl = &di->id2.i_dealloc; 1129 tl = &di->id2.i_dealloc;
@@ -1198,9 +1198,9 @@ int ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1198 int status; 1198 int status;
1199 struct inode *tl_inode = osb->osb_tl_inode; 1199 struct inode *tl_inode = osb->osb_tl_inode;
1200 1200
1201 down(&tl_inode->i_sem); 1201 mutex_lock(&tl_inode->i_mutex);
1202 status = __ocfs2_flush_truncate_log(osb); 1202 status = __ocfs2_flush_truncate_log(osb);
1203 up(&tl_inode->i_sem); 1203 mutex_unlock(&tl_inode->i_mutex);
1204 1204
1205 return status; 1205 return status;
1206} 1206}
@@ -1363,7 +1363,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1363 mlog(0, "cleanup %u records from %"MLFu64"\n", num_recs, 1363 mlog(0, "cleanup %u records from %"MLFu64"\n", num_recs,
1364 tl_copy->i_blkno); 1364 tl_copy->i_blkno);
1365 1365
1366 down(&tl_inode->i_sem); 1366 mutex_lock(&tl_inode->i_mutex);
1367 for(i = 0; i < num_recs; i++) { 1367 for(i = 0; i < num_recs; i++) {
1368 if (ocfs2_truncate_log_needs_flush(osb)) { 1368 if (ocfs2_truncate_log_needs_flush(osb)) {
1369 status = __ocfs2_flush_truncate_log(osb); 1369 status = __ocfs2_flush_truncate_log(osb);
@@ -1395,7 +1395,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1395 } 1395 }
1396 1396
1397bail_up: 1397bail_up:
1398 up(&tl_inode->i_sem); 1398 mutex_unlock(&tl_inode->i_mutex);
1399 1399
1400 mlog_exit(status); 1400 mlog_exit(status);
1401 return status; 1401 return status;
@@ -1840,7 +1840,7 @@ start:
1840 1840
1841 mlog(0, "clusters_to_del = %u in this pass\n", clusters_to_del); 1841 mlog(0, "clusters_to_del = %u in this pass\n", clusters_to_del);
1842 1842
1843 down(&tl_inode->i_sem); 1843 mutex_lock(&tl_inode->i_mutex);
1844 tl_sem = 1; 1844 tl_sem = 1;
1845 /* ocfs2_truncate_log_needs_flush guarantees us at least one 1845 /* ocfs2_truncate_log_needs_flush guarantees us at least one
1846 * record is free for use. If there isn't any, we flush to get 1846 * record is free for use. If there isn't any, we flush to get
@@ -1875,7 +1875,7 @@ start:
1875 goto bail; 1875 goto bail;
1876 } 1876 }
1877 1877
1878 up(&tl_inode->i_sem); 1878 mutex_unlock(&tl_inode->i_mutex);
1879 tl_sem = 0; 1879 tl_sem = 0;
1880 1880
1881 ocfs2_commit_trans(handle); 1881 ocfs2_commit_trans(handle);
@@ -1890,7 +1890,7 @@ bail:
1890 ocfs2_schedule_truncate_log_flush(osb, 1); 1890 ocfs2_schedule_truncate_log_flush(osb, 1);
1891 1891
1892 if (tl_sem) 1892 if (tl_sem)
1893 up(&tl_inode->i_sem); 1893 mutex_unlock(&tl_inode->i_mutex);
1894 1894
1895 if (handle) 1895 if (handle)
1896 ocfs2_commit_trans(handle); 1896 ocfs2_commit_trans(handle);
@@ -1994,7 +1994,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
1994 goto bail; 1994 goto bail;
1995 } 1995 }
1996 1996
1997 down(&ext_alloc_inode->i_sem); 1997 mutex_lock(&ext_alloc_inode->i_mutex);
1998 (*tc)->tc_ext_alloc_inode = ext_alloc_inode; 1998 (*tc)->tc_ext_alloc_inode = ext_alloc_inode;
1999 1999
2000 status = ocfs2_meta_lock(ext_alloc_inode, 2000 status = ocfs2_meta_lock(ext_alloc_inode,
@@ -2026,7 +2026,7 @@ static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc)
2026 if (tc->tc_ext_alloc_locked) 2026 if (tc->tc_ext_alloc_locked)
2027 ocfs2_meta_unlock(tc->tc_ext_alloc_inode, 1); 2027 ocfs2_meta_unlock(tc->tc_ext_alloc_inode, 1);
2028 2028
2029 up(&tc->tc_ext_alloc_inode->i_sem); 2029 mutex_unlock(&tc->tc_ext_alloc_inode->i_mutex);
2030 iput(tc->tc_ext_alloc_inode); 2030 iput(tc->tc_ext_alloc_inode);
2031 } 2031 }
2032 2032
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index 5fd60c105913..cf7828f23361 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -653,7 +653,7 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
653 struct config_group *o2hb_group = NULL, *ret = NULL; 653 struct config_group *o2hb_group = NULL, *ret = NULL;
654 void *defs = NULL; 654 void *defs = NULL;
655 655
656 /* this runs under the parent dir's i_sem; there can be only 656 /* this runs under the parent dir's i_mutex; there can be only
657 * one caller in here at a time */ 657 * one caller in here at a time */
658 if (o2nm_single_cluster) 658 if (o2nm_single_cluster)
659 goto out; /* ENOSPC */ 659 goto out; /* ENOSPC */
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 856e20ae8263..57158fa75d91 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -202,7 +202,7 @@ bail:
202} 202}
203 203
204/* 204/*
205 * NOTE: this should always be called with parent dir i_sem taken. 205 * NOTE: this should always be called with parent dir i_mutex taken.
206 */ 206 */
207int ocfs2_find_files_on_disk(const char *name, 207int ocfs2_find_files_on_disk(const char *name,
208 int namelen, 208 int namelen,
@@ -245,7 +245,7 @@ leave:
245 * Return 0 if the name does not exist 245 * Return 0 if the name does not exist
246 * Return -EEXIST if the directory contains the name 246 * Return -EEXIST if the directory contains the name
247 * 247 *
248 * Callers should have i_sem + a cluster lock on dir 248 * Callers should have i_mutex + a cluster lock on dir
249 */ 249 */
250int ocfs2_check_dir_for_entry(struct inode *dir, 250int ocfs2_check_dir_for_entry(struct inode *dir,
251 const char *name, 251 const char *name,
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 72ae9e3306f4..ca5f9f90d794 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -492,7 +492,7 @@ restart_all:
492 } 492 }
493 493
494 /* blocks peope in read/write from reading our allocation 494 /* blocks peope in read/write from reading our allocation
495 * until we're done changing it. We depend on i_sem to block 495 * until we're done changing it. We depend on i_mutex to block
496 * other extend/truncate calls while we're here. Ordering wrt 496 * other extend/truncate calls while we're here. Ordering wrt
497 * start_trans is important here -- always do it before! */ 497 * start_trans is important here -- always do it before! */
498 down_write(&OCFS2_I(inode)->ip_alloc_sem); 498 down_write(&OCFS2_I(inode)->ip_alloc_sem);
@@ -958,8 +958,8 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
958 filp->f_flags &= ~O_DIRECT; 958 filp->f_flags &= ~O_DIRECT;
959#endif 959#endif
960 960
961 down(&inode->i_sem); 961 mutex_lock(&inode->i_mutex);
962 /* to match setattr's i_sem -> i_alloc_sem -> rw_lock ordering */ 962 /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */
963 if (filp->f_flags & O_DIRECT) { 963 if (filp->f_flags & O_DIRECT) {
964 have_alloc_sem = 1; 964 have_alloc_sem = 1;
965 down_read(&inode->i_alloc_sem); 965 down_read(&inode->i_alloc_sem);
@@ -1123,7 +1123,7 @@ out:
1123 up_read(&inode->i_alloc_sem); 1123 up_read(&inode->i_alloc_sem);
1124 if (rw_level != -1) 1124 if (rw_level != -1)
1125 ocfs2_rw_unlock(inode, rw_level); 1125 ocfs2_rw_unlock(inode, rw_level);
1126 up(&inode->i_sem); 1126 mutex_unlock(&inode->i_mutex);
1127 1127
1128 mlog_exit(ret); 1128 mlog_exit(ret);
1129 return ret; 1129 return ret;
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index a91ba4dec936..d4ecc0627716 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -485,10 +485,10 @@ static int ocfs2_remove_inode(struct inode *inode,
485 goto bail; 485 goto bail;
486 } 486 }
487 487
488 down(&inode_alloc_inode->i_sem); 488 mutex_lock(&inode_alloc_inode->i_mutex);
489 status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1); 489 status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1);
490 if (status < 0) { 490 if (status < 0) {
491 up(&inode_alloc_inode->i_sem); 491 mutex_unlock(&inode_alloc_inode->i_mutex);
492 492
493 mlog_errno(status); 493 mlog_errno(status);
494 goto bail; 494 goto bail;
@@ -536,7 +536,7 @@ bail_commit:
536 ocfs2_commit_trans(handle); 536 ocfs2_commit_trans(handle);
537bail_unlock: 537bail_unlock:
538 ocfs2_meta_unlock(inode_alloc_inode, 1); 538 ocfs2_meta_unlock(inode_alloc_inode, 1);
539 up(&inode_alloc_inode->i_sem); 539 mutex_unlock(&inode_alloc_inode->i_mutex);
540 brelse(inode_alloc_bh); 540 brelse(inode_alloc_bh);
541bail: 541bail:
542 iput(inode_alloc_inode); 542 iput(inode_alloc_inode);
@@ -567,10 +567,10 @@ static int ocfs2_wipe_inode(struct inode *inode,
567 /* Lock the orphan dir. The lock will be held for the entire 567 /* Lock the orphan dir. The lock will be held for the entire
568 * delete_inode operation. We do this now to avoid races with 568 * delete_inode operation. We do this now to avoid races with
569 * recovery completion on other nodes. */ 569 * recovery completion on other nodes. */
570 down(&orphan_dir_inode->i_sem); 570 mutex_lock(&orphan_dir_inode->i_mutex);
571 status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1); 571 status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1);
572 if (status < 0) { 572 if (status < 0) {
573 up(&orphan_dir_inode->i_sem); 573 mutex_unlock(&orphan_dir_inode->i_mutex);
574 574
575 mlog_errno(status); 575 mlog_errno(status);
576 goto bail; 576 goto bail;
@@ -593,7 +593,7 @@ static int ocfs2_wipe_inode(struct inode *inode,
593 593
594bail_unlock_dir: 594bail_unlock_dir:
595 ocfs2_meta_unlock(orphan_dir_inode, 1); 595 ocfs2_meta_unlock(orphan_dir_inode, 1);
596 up(&orphan_dir_inode->i_sem); 596 mutex_unlock(&orphan_dir_inode->i_mutex);
597 brelse(orphan_dir_bh); 597 brelse(orphan_dir_bh);
598bail: 598bail:
599 iput(orphan_dir_inode); 599 iput(orphan_dir_inode);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 04428042e5e5..303c8d96457f 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -216,7 +216,7 @@ void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle,
216 atomic_inc(&inode->i_count); 216 atomic_inc(&inode->i_count);
217 217
218 /* we're obviously changing it... */ 218 /* we're obviously changing it... */
219 down(&inode->i_sem); 219 mutex_lock(&inode->i_mutex);
220 220
221 /* sanity check */ 221 /* sanity check */
222 BUG_ON(OCFS2_I(inode)->ip_handle); 222 BUG_ON(OCFS2_I(inode)->ip_handle);
@@ -241,7 +241,7 @@ static void ocfs2_handle_unlock_inodes(struct ocfs2_journal_handle *handle)
241 OCFS2_I(inode)->ip_handle = NULL; 241 OCFS2_I(inode)->ip_handle = NULL;
242 list_del_init(&OCFS2_I(inode)->ip_handle_list); 242 list_del_init(&OCFS2_I(inode)->ip_handle_list);
243 243
244 up(&inode->i_sem); 244 mutex_unlock(&inode->i_mutex);
245 iput(inode); 245 iput(inode);
246 } 246 }
247} 247}
@@ -1433,10 +1433,10 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1433 goto out; 1433 goto out;
1434 } 1434 }
1435 1435
1436 down(&orphan_dir_inode->i_sem); 1436 mutex_lock(&orphan_dir_inode->i_mutex);
1437 status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); 1437 status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0);
1438 if (status < 0) { 1438 if (status < 0) {
1439 up(&orphan_dir_inode->i_sem); 1439 mutex_unlock(&orphan_dir_inode->i_mutex);
1440 mlog_errno(status); 1440 mlog_errno(status);
1441 goto out; 1441 goto out;
1442 } 1442 }
@@ -1451,7 +1451,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1451 if (!bh) 1451 if (!bh)
1452 status = -EINVAL; 1452 status = -EINVAL;
1453 if (status < 0) { 1453 if (status < 0) {
1454 up(&orphan_dir_inode->i_sem); 1454 mutex_unlock(&orphan_dir_inode->i_mutex);
1455 if (bh) 1455 if (bh)
1456 brelse(bh); 1456 brelse(bh);
1457 mlog_errno(status); 1457 mlog_errno(status);
@@ -1465,7 +1465,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1465 1465
1466 if (!ocfs2_check_dir_entry(orphan_dir_inode, 1466 if (!ocfs2_check_dir_entry(orphan_dir_inode,
1467 de, bh, local)) { 1467 de, bh, local)) {
1468 up(&orphan_dir_inode->i_sem); 1468 mutex_unlock(&orphan_dir_inode->i_mutex);
1469 status = -EINVAL; 1469 status = -EINVAL;
1470 mlog_errno(status); 1470 mlog_errno(status);
1471 brelse(bh); 1471 brelse(bh);
@@ -1509,7 +1509,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1509 } 1509 }
1510 brelse(bh); 1510 brelse(bh);
1511 } 1511 }
1512 up(&orphan_dir_inode->i_sem); 1512 mutex_unlock(&orphan_dir_inode->i_mutex);
1513 1513
1514 ocfs2_meta_unlock(orphan_dir_inode, 0); 1514 ocfs2_meta_unlock(orphan_dir_inode, 0);
1515 have_disk_lock = 0; 1515 have_disk_lock = 0;
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index fe373a2101d9..149b35181666 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -334,7 +334,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb,
334 goto bail; 334 goto bail;
335 } 335 }
336 336
337 down(&inode->i_sem); 337 mutex_lock(&inode->i_mutex);
338 338
339 status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, 339 status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno,
340 &alloc_bh, 0, inode); 340 &alloc_bh, 0, inode);
@@ -367,7 +367,7 @@ bail:
367 brelse(alloc_bh); 367 brelse(alloc_bh);
368 368
369 if (inode) { 369 if (inode) {
370 up(&inode->i_sem); 370 mutex_unlock(&inode->i_mutex);
371 iput(inode); 371 iput(inode);
372 } 372 }
373 373
@@ -446,7 +446,7 @@ bail:
446 446
447/* 447/*
448 * make sure we've got at least bitswanted contiguous bits in the 448 * make sure we've got at least bitswanted contiguous bits in the
449 * local alloc. You lose them when you drop i_sem. 449 * local alloc. You lose them when you drop i_mutex.
450 * 450 *
451 * We will add ourselves to the transaction passed in, but may start 451 * We will add ourselves to the transaction passed in, but may start
452 * our own in order to shift windows. 452 * our own in order to shift windows.
diff --git a/fs/open.c b/fs/open.c
index 75f3329e8a67..a3b3a9b5c2ff 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -211,9 +211,9 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
211 newattrs.ia_valid |= ATTR_FILE; 211 newattrs.ia_valid |= ATTR_FILE;
212 } 212 }
213 213
214 down(&dentry->d_inode->i_sem); 214 mutex_lock(&dentry->d_inode->i_mutex);
215 err = notify_change(dentry, &newattrs); 215 err = notify_change(dentry, &newattrs);
216 up(&dentry->d_inode->i_sem); 216 mutex_unlock(&dentry->d_inode->i_mutex);
217 return err; 217 return err;
218} 218}
219 219
@@ -398,9 +398,9 @@ asmlinkage long sys_utime(char __user * filename, struct utimbuf __user * times)
398 (error = vfs_permission(&nd, MAY_WRITE)) != 0) 398 (error = vfs_permission(&nd, MAY_WRITE)) != 0)
399 goto dput_and_out; 399 goto dput_and_out;
400 } 400 }
401 down(&inode->i_sem); 401 mutex_lock(&inode->i_mutex);
402 error = notify_change(nd.dentry, &newattrs); 402 error = notify_change(nd.dentry, &newattrs);
403 up(&inode->i_sem); 403 mutex_unlock(&inode->i_mutex);
404dput_and_out: 404dput_and_out:
405 path_release(&nd); 405 path_release(&nd);
406out: 406out:
@@ -451,9 +451,9 @@ long do_utimes(char __user * filename, struct timeval * times)
451 (error = vfs_permission(&nd, MAY_WRITE)) != 0) 451 (error = vfs_permission(&nd, MAY_WRITE)) != 0)
452 goto dput_and_out; 452 goto dput_and_out;
453 } 453 }
454 down(&inode->i_sem); 454 mutex_lock(&inode->i_mutex);
455 error = notify_change(nd.dentry, &newattrs); 455 error = notify_change(nd.dentry, &newattrs);
456 up(&inode->i_sem); 456 mutex_unlock(&inode->i_mutex);
457dput_and_out: 457dput_and_out:
458 path_release(&nd); 458 path_release(&nd);
459out: 459out:
@@ -620,13 +620,13 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
620 err = -EPERM; 620 err = -EPERM;
621 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 621 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
622 goto out_putf; 622 goto out_putf;
623 down(&inode->i_sem); 623 mutex_lock(&inode->i_mutex);
624 if (mode == (mode_t) -1) 624 if (mode == (mode_t) -1)
625 mode = inode->i_mode; 625 mode = inode->i_mode;
626 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); 626 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
627 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; 627 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
628 err = notify_change(dentry, &newattrs); 628 err = notify_change(dentry, &newattrs);
629 up(&inode->i_sem); 629 mutex_unlock(&inode->i_mutex);
630 630
631out_putf: 631out_putf:
632 fput(file); 632 fput(file);
@@ -654,13 +654,13 @@ asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
654 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 654 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
655 goto dput_and_out; 655 goto dput_and_out;
656 656
657 down(&inode->i_sem); 657 mutex_lock(&inode->i_mutex);
658 if (mode == (mode_t) -1) 658 if (mode == (mode_t) -1)
659 mode = inode->i_mode; 659 mode = inode->i_mode;
660 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); 660 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
661 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; 661 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
662 error = notify_change(nd.dentry, &newattrs); 662 error = notify_change(nd.dentry, &newattrs);
663 up(&inode->i_sem); 663 mutex_unlock(&inode->i_mutex);
664 664
665dput_and_out: 665dput_and_out:
666 path_release(&nd); 666 path_release(&nd);
@@ -696,9 +696,9 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
696 } 696 }
697 if (!S_ISDIR(inode->i_mode)) 697 if (!S_ISDIR(inode->i_mode))
698 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID; 698 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
699 down(&inode->i_sem); 699 mutex_lock(&inode->i_mutex);
700 error = notify_change(dentry, &newattrs); 700 error = notify_change(dentry, &newattrs);
701 up(&inode->i_sem); 701 mutex_unlock(&inode->i_mutex);
702out: 702out:
703 return error; 703 return error;
704} 704}
diff --git a/fs/pipe.c b/fs/pipe.c
index 66aa0b938d6a..acb030b61fb0 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -44,10 +44,10 @@ void pipe_wait(struct inode * inode)
44 * is considered a noninteractive wait: 44 * is considered a noninteractive wait:
45 */ 45 */
46 prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE|TASK_NONINTERACTIVE); 46 prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE|TASK_NONINTERACTIVE);
47 up(PIPE_SEM(*inode)); 47 mutex_unlock(PIPE_MUTEX(*inode));
48 schedule(); 48 schedule();
49 finish_wait(PIPE_WAIT(*inode), &wait); 49 finish_wait(PIPE_WAIT(*inode), &wait);
50 down(PIPE_SEM(*inode)); 50 mutex_lock(PIPE_MUTEX(*inode));
51} 51}
52 52
53static inline int 53static inline int
@@ -136,7 +136,7 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
136 136
137 do_wakeup = 0; 137 do_wakeup = 0;
138 ret = 0; 138 ret = 0;
139 down(PIPE_SEM(*inode)); 139 mutex_lock(PIPE_MUTEX(*inode));
140 info = inode->i_pipe; 140 info = inode->i_pipe;
141 for (;;) { 141 for (;;) {
142 int bufs = info->nrbufs; 142 int bufs = info->nrbufs;
@@ -200,7 +200,7 @@ pipe_readv(struct file *filp, const struct iovec *_iov,
200 } 200 }
201 pipe_wait(inode); 201 pipe_wait(inode);
202 } 202 }
203 up(PIPE_SEM(*inode)); 203 mutex_unlock(PIPE_MUTEX(*inode));
204 /* Signal writers asynchronously that there is more room. */ 204 /* Signal writers asynchronously that there is more room. */
205 if (do_wakeup) { 205 if (do_wakeup) {
206 wake_up_interruptible(PIPE_WAIT(*inode)); 206 wake_up_interruptible(PIPE_WAIT(*inode));
@@ -237,7 +237,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
237 237
238 do_wakeup = 0; 238 do_wakeup = 0;
239 ret = 0; 239 ret = 0;
240 down(PIPE_SEM(*inode)); 240 mutex_lock(PIPE_MUTEX(*inode));
241 info = inode->i_pipe; 241 info = inode->i_pipe;
242 242
243 if (!PIPE_READERS(*inode)) { 243 if (!PIPE_READERS(*inode)) {
@@ -341,7 +341,7 @@ pipe_writev(struct file *filp, const struct iovec *_iov,
341 PIPE_WAITING_WRITERS(*inode)--; 341 PIPE_WAITING_WRITERS(*inode)--;
342 } 342 }
343out: 343out:
344 up(PIPE_SEM(*inode)); 344 mutex_unlock(PIPE_MUTEX(*inode));
345 if (do_wakeup) { 345 if (do_wakeup) {
346 wake_up_interruptible(PIPE_WAIT(*inode)); 346 wake_up_interruptible(PIPE_WAIT(*inode));
347 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); 347 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
@@ -381,7 +381,7 @@ pipe_ioctl(struct inode *pino, struct file *filp,
381 381
382 switch (cmd) { 382 switch (cmd) {
383 case FIONREAD: 383 case FIONREAD:
384 down(PIPE_SEM(*inode)); 384 mutex_lock(PIPE_MUTEX(*inode));
385 info = inode->i_pipe; 385 info = inode->i_pipe;
386 count = 0; 386 count = 0;
387 buf = info->curbuf; 387 buf = info->curbuf;
@@ -390,7 +390,7 @@ pipe_ioctl(struct inode *pino, struct file *filp,
390 count += info->bufs[buf].len; 390 count += info->bufs[buf].len;
391 buf = (buf+1) & (PIPE_BUFFERS-1); 391 buf = (buf+1) & (PIPE_BUFFERS-1);
392 } 392 }
393 up(PIPE_SEM(*inode)); 393 mutex_unlock(PIPE_MUTEX(*inode));
394 return put_user(count, (int __user *)arg); 394 return put_user(count, (int __user *)arg);
395 default: 395 default:
396 return -EINVAL; 396 return -EINVAL;
@@ -433,7 +433,7 @@ pipe_poll(struct file *filp, poll_table *wait)
433static int 433static int
434pipe_release(struct inode *inode, int decr, int decw) 434pipe_release(struct inode *inode, int decr, int decw)
435{ 435{
436 down(PIPE_SEM(*inode)); 436 mutex_lock(PIPE_MUTEX(*inode));
437 PIPE_READERS(*inode) -= decr; 437 PIPE_READERS(*inode) -= decr;
438 PIPE_WRITERS(*inode) -= decw; 438 PIPE_WRITERS(*inode) -= decw;
439 if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) { 439 if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) {
@@ -443,7 +443,7 @@ pipe_release(struct inode *inode, int decr, int decw)
443 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN); 443 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
444 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT); 444 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
445 } 445 }
446 up(PIPE_SEM(*inode)); 446 mutex_unlock(PIPE_MUTEX(*inode));
447 447
448 return 0; 448 return 0;
449} 449}
@@ -454,9 +454,9 @@ pipe_read_fasync(int fd, struct file *filp, int on)
454 struct inode *inode = filp->f_dentry->d_inode; 454 struct inode *inode = filp->f_dentry->d_inode;
455 int retval; 455 int retval;
456 456
457 down(PIPE_SEM(*inode)); 457 mutex_lock(PIPE_MUTEX(*inode));
458 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode)); 458 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode));
459 up(PIPE_SEM(*inode)); 459 mutex_unlock(PIPE_MUTEX(*inode));
460 460
461 if (retval < 0) 461 if (retval < 0)
462 return retval; 462 return retval;
@@ -471,9 +471,9 @@ pipe_write_fasync(int fd, struct file *filp, int on)
471 struct inode *inode = filp->f_dentry->d_inode; 471 struct inode *inode = filp->f_dentry->d_inode;
472 int retval; 472 int retval;
473 473
474 down(PIPE_SEM(*inode)); 474 mutex_lock(PIPE_MUTEX(*inode));
475 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode)); 475 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode));
476 up(PIPE_SEM(*inode)); 476 mutex_unlock(PIPE_MUTEX(*inode));
477 477
478 if (retval < 0) 478 if (retval < 0)
479 return retval; 479 return retval;
@@ -488,14 +488,14 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on)
488 struct inode *inode = filp->f_dentry->d_inode; 488 struct inode *inode = filp->f_dentry->d_inode;
489 int retval; 489 int retval;
490 490
491 down(PIPE_SEM(*inode)); 491 mutex_lock(PIPE_MUTEX(*inode));
492 492
493 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode)); 493 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode));
494 494
495 if (retval >= 0) 495 if (retval >= 0)
496 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode)); 496 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode));
497 497
498 up(PIPE_SEM(*inode)); 498 mutex_unlock(PIPE_MUTEX(*inode));
499 499
500 if (retval < 0) 500 if (retval < 0)
501 return retval; 501 return retval;
@@ -534,9 +534,9 @@ pipe_read_open(struct inode *inode, struct file *filp)
534{ 534{
535 /* We could have perhaps used atomic_t, but this and friends 535 /* We could have perhaps used atomic_t, but this and friends
536 below are the only places. So it doesn't seem worthwhile. */ 536 below are the only places. So it doesn't seem worthwhile. */
537 down(PIPE_SEM(*inode)); 537 mutex_lock(PIPE_MUTEX(*inode));
538 PIPE_READERS(*inode)++; 538 PIPE_READERS(*inode)++;
539 up(PIPE_SEM(*inode)); 539 mutex_unlock(PIPE_MUTEX(*inode));
540 540
541 return 0; 541 return 0;
542} 542}
@@ -544,9 +544,9 @@ pipe_read_open(struct inode *inode, struct file *filp)
544static int 544static int
545pipe_write_open(struct inode *inode, struct file *filp) 545pipe_write_open(struct inode *inode, struct file *filp)
546{ 546{
547 down(PIPE_SEM(*inode)); 547 mutex_lock(PIPE_MUTEX(*inode));
548 PIPE_WRITERS(*inode)++; 548 PIPE_WRITERS(*inode)++;
549 up(PIPE_SEM(*inode)); 549 mutex_unlock(PIPE_MUTEX(*inode));
550 550
551 return 0; 551 return 0;
552} 552}
@@ -554,12 +554,12 @@ pipe_write_open(struct inode *inode, struct file *filp)
554static int 554static int
555pipe_rdwr_open(struct inode *inode, struct file *filp) 555pipe_rdwr_open(struct inode *inode, struct file *filp)
556{ 556{
557 down(PIPE_SEM(*inode)); 557 mutex_lock(PIPE_MUTEX(*inode));
558 if (filp->f_mode & FMODE_READ) 558 if (filp->f_mode & FMODE_READ)
559 PIPE_READERS(*inode)++; 559 PIPE_READERS(*inode)++;
560 if (filp->f_mode & FMODE_WRITE) 560 if (filp->f_mode & FMODE_WRITE)
561 PIPE_WRITERS(*inode)++; 561 PIPE_WRITERS(*inode)++;
562 up(PIPE_SEM(*inode)); 562 mutex_unlock(PIPE_MUTEX(*inode));
563 563
564 return 0; 564 return 0;
565} 565}
diff --git a/fs/quota.c b/fs/quota.c
index 612e04db4b93..d14d872646d4 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -168,7 +168,7 @@ static void quota_sync_sb(struct super_block *sb, int type)
168 sync_blockdev(sb->s_bdev); 168 sync_blockdev(sb->s_bdev);
169 169
170 /* Now when everything is written we can discard the pagecache so 170 /* Now when everything is written we can discard the pagecache so
171 * that userspace sees the changes. We need i_sem and so we could 171 * that userspace sees the changes. We need i_mutex and so we could
172 * not do it inside dqonoff_sem. Moreover we need to be carefull 172 * not do it inside dqonoff_sem. Moreover we need to be carefull
173 * about races with quotaoff() (that is the reason why we have own 173 * about races with quotaoff() (that is the reason why we have own
174 * reference to inode). */ 174 * reference to inode). */
@@ -184,9 +184,9 @@ static void quota_sync_sb(struct super_block *sb, int type)
184 up(&sb_dqopt(sb)->dqonoff_sem); 184 up(&sb_dqopt(sb)->dqonoff_sem);
185 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 185 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
186 if (discard[cnt]) { 186 if (discard[cnt]) {
187 down(&discard[cnt]->i_sem); 187 mutex_lock(&discard[cnt]->i_mutex);
188 truncate_inode_pages(&discard[cnt]->i_data, 0); 188 truncate_inode_pages(&discard[cnt]->i_data, 0);
189 up(&discard[cnt]->i_sem); 189 mutex_unlock(&discard[cnt]->i_mutex);
190 iput(discard[cnt]); 190 iput(discard[cnt]);
191 } 191 }
192 } 192 }
diff --git a/fs/read_write.c b/fs/read_write.c
index df3468a22fea..3f7a1a62165f 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -33,7 +33,7 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
33 long long retval; 33 long long retval;
34 struct inode *inode = file->f_mapping->host; 34 struct inode *inode = file->f_mapping->host;
35 35
36 down(&inode->i_sem); 36 mutex_lock(&inode->i_mutex);
37 switch (origin) { 37 switch (origin) {
38 case 2: 38 case 2:
39 offset += inode->i_size; 39 offset += inode->i_size;
@@ -49,7 +49,7 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
49 } 49 }
50 retval = offset; 50 retval = offset;
51 } 51 }
52 up(&inode->i_sem); 52 mutex_unlock(&inode->i_mutex);
53 return retval; 53 return retval;
54} 54}
55 55
diff --git a/fs/readdir.c b/fs/readdir.c
index b03579bc0210..b6109329b607 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -30,13 +30,13 @@ int vfs_readdir(struct file *file, filldir_t filler, void *buf)
30 if (res) 30 if (res)
31 goto out; 31 goto out;
32 32
33 down(&inode->i_sem); 33 mutex_lock(&inode->i_mutex);
34 res = -ENOENT; 34 res = -ENOENT;
35 if (!IS_DEADDIR(inode)) { 35 if (!IS_DEADDIR(inode)) {
36 res = file->f_op->readdir(file, buf, filler); 36 res = file->f_op->readdir(file, buf, filler);
37 file_accessed(file); 37 file_accessed(file);
38 } 38 }
39 up(&inode->i_sem); 39 mutex_unlock(&inode->i_mutex);
40out: 40out:
41 return res; 41 return res;
42} 42}
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 7892a865b58a..127e7d2cabdd 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -49,7 +49,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
49 } 49 }
50 50
51 reiserfs_write_lock(inode->i_sb); 51 reiserfs_write_lock(inode->i_sb);
52 down(&inode->i_sem); 52 mutex_lock(&inode->i_mutex);
53 /* freeing preallocation only involves relogging blocks that 53 /* freeing preallocation only involves relogging blocks that
54 * are already in the current transaction. preallocation gets 54 * are already in the current transaction. preallocation gets
55 * freed at the end of each transaction, so it is impossible for 55 * freed at the end of each transaction, so it is impossible for
@@ -100,7 +100,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
100 err = reiserfs_truncate_file(inode, 0); 100 err = reiserfs_truncate_file(inode, 0);
101 } 101 }
102 out: 102 out:
103 up(&inode->i_sem); 103 mutex_unlock(&inode->i_mutex);
104 reiserfs_write_unlock(inode->i_sb); 104 reiserfs_write_unlock(inode->i_sb);
105 return err; 105 return err;
106} 106}
@@ -1342,7 +1342,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1342 if (unlikely(!access_ok(VERIFY_READ, buf, count))) 1342 if (unlikely(!access_ok(VERIFY_READ, buf, count)))
1343 return -EFAULT; 1343 return -EFAULT;
1344 1344
1345 down(&inode->i_sem); // locks the entire file for just us 1345 mutex_lock(&inode->i_mutex); // locks the entire file for just us
1346 1346
1347 pos = *ppos; 1347 pos = *ppos;
1348 1348
@@ -1532,12 +1532,12 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1532 generic_osync_inode(inode, file->f_mapping, 1532 generic_osync_inode(inode, file->f_mapping,
1533 OSYNC_METADATA | OSYNC_DATA); 1533 OSYNC_METADATA | OSYNC_DATA);
1534 1534
1535 up(&inode->i_sem); 1535 mutex_unlock(&inode->i_mutex);
1536 reiserfs_async_progress_wait(inode->i_sb); 1536 reiserfs_async_progress_wait(inode->i_sb);
1537 return (already_written != 0) ? already_written : res; 1537 return (already_written != 0) ? already_written : res;
1538 1538
1539 out: 1539 out:
1540 up(&inode->i_sem); // unlock the file on exit. 1540 mutex_unlock(&inode->i_mutex); // unlock the file on exit.
1541 return res; 1541 return res;
1542} 1542}
1543 1543
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index a5e3a0ddbe53..ffa34b861bdb 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -40,12 +40,12 @@ void reiserfs_delete_inode(struct inode *inode)
40 40
41 /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ 41 /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */
42 if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */ 42 if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */
43 down(&inode->i_sem); 43 mutex_lock(&inode->i_mutex);
44 44
45 reiserfs_delete_xattrs(inode); 45 reiserfs_delete_xattrs(inode);
46 46
47 if (journal_begin(&th, inode->i_sb, jbegin_count)) { 47 if (journal_begin(&th, inode->i_sb, jbegin_count)) {
48 up(&inode->i_sem); 48 mutex_unlock(&inode->i_mutex);
49 goto out; 49 goto out;
50 } 50 }
51 reiserfs_update_inode_transaction(inode); 51 reiserfs_update_inode_transaction(inode);
@@ -59,11 +59,11 @@ void reiserfs_delete_inode(struct inode *inode)
59 DQUOT_FREE_INODE(inode); 59 DQUOT_FREE_INODE(inode);
60 60
61 if (journal_end(&th, inode->i_sb, jbegin_count)) { 61 if (journal_end(&th, inode->i_sb, jbegin_count)) {
62 up(&inode->i_sem); 62 mutex_unlock(&inode->i_mutex);
63 goto out; 63 goto out;
64 } 64 }
65 65
66 up(&inode->i_sem); 66 mutex_unlock(&inode->i_mutex);
67 67
68 /* check return value from reiserfs_delete_object after 68 /* check return value from reiserfs_delete_object after
69 * ending the transaction 69 * ending the transaction
@@ -551,7 +551,7 @@ static int convert_tail_for_hole(struct inode *inode,
551 551
552 /* we don't have to make sure the conversion did not happen while 552 /* we don't have to make sure the conversion did not happen while
553 ** we were locking the page because anyone that could convert 553 ** we were locking the page because anyone that could convert
554 ** must first take i_sem. 554 ** must first take i_mutex.
555 ** 555 **
556 ** We must fix the tail page for writing because it might have buffers 556 ** We must fix the tail page for writing because it might have buffers
557 ** that are mapped, but have a block number of 0. This indicates tail 557 ** that are mapped, but have a block number of 0. This indicates tail
@@ -586,7 +586,7 @@ static inline int _allocate_block(struct reiserfs_transaction_handle *th,
586 BUG_ON(!th->t_trans_id); 586 BUG_ON(!th->t_trans_id);
587 587
588#ifdef REISERFS_PREALLOCATE 588#ifdef REISERFS_PREALLOCATE
589 if (!(flags & GET_BLOCK_NO_ISEM)) { 589 if (!(flags & GET_BLOCK_NO_IMUX)) {
590 return reiserfs_new_unf_blocknrs2(th, inode, allocated_block_nr, 590 return reiserfs_new_unf_blocknrs2(th, inode, allocated_block_nr,
591 path, block); 591 path, block);
592 } 592 }
@@ -2318,7 +2318,7 @@ static int map_block_for_writepage(struct inode *inode,
2318 /* this is where we fill in holes in the file. */ 2318 /* this is where we fill in holes in the file. */
2319 if (use_get_block) { 2319 if (use_get_block) {
2320 retval = reiserfs_get_block(inode, block, bh_result, 2320 retval = reiserfs_get_block(inode, block, bh_result,
2321 GET_BLOCK_CREATE | GET_BLOCK_NO_ISEM 2321 GET_BLOCK_CREATE | GET_BLOCK_NO_IMUX
2322 | GET_BLOCK_NO_DANGLE); 2322 | GET_BLOCK_NO_DANGLE);
2323 if (!retval) { 2323 if (!retval) {
2324 if (!buffer_mapped(bh_result) 2324 if (!buffer_mapped(bh_result)
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 81fc00285f60..ba8bf8df6dc7 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -120,7 +120,7 @@ static int reiserfs_unpack(struct inode *inode, struct file *filp)
120 /* we need to make sure nobody is changing the file size beneath 120 /* we need to make sure nobody is changing the file size beneath
121 ** us 121 ** us
122 */ 122 */
123 down(&inode->i_sem); 123 mutex_lock(&inode->i_mutex);
124 124
125 write_from = inode->i_size & (blocksize - 1); 125 write_from = inode->i_size & (blocksize - 1);
126 /* if we are on a block boundary, we are already unpacked. */ 126 /* if we are on a block boundary, we are already unpacked. */
@@ -156,7 +156,7 @@ static int reiserfs_unpack(struct inode *inode, struct file *filp)
156 page_cache_release(page); 156 page_cache_release(page);
157 157
158 out: 158 out:
159 up(&inode->i_sem); 159 mutex_unlock(&inode->i_mutex);
160 reiserfs_write_unlock(inode->i_sb); 160 reiserfs_write_unlock(inode->i_sb);
161 return retval; 161 return retval;
162} 162}
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 42afb5bef111..397d9590c8f2 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -2211,7 +2211,7 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2211 size_t towrite = len; 2211 size_t towrite = len;
2212 struct buffer_head tmp_bh, *bh; 2212 struct buffer_head tmp_bh, *bh;
2213 2213
2214 down(&inode->i_sem); 2214 mutex_lock(&inode->i_mutex);
2215 while (towrite > 0) { 2215 while (towrite > 0) {
2216 tocopy = sb->s_blocksize - offset < towrite ? 2216 tocopy = sb->s_blocksize - offset < towrite ?
2217 sb->s_blocksize - offset : towrite; 2217 sb->s_blocksize - offset : towrite;
@@ -2250,7 +2250,7 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2250 inode->i_version++; 2250 inode->i_version++;
2251 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 2251 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2252 mark_inode_dirty(inode); 2252 mark_inode_dirty(inode);
2253 up(&inode->i_sem); 2253 mutex_unlock(&inode->i_mutex);
2254 return len - towrite; 2254 return len - towrite;
2255} 2255}
2256 2256
diff --git a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c
index c92e124f628e..196e971c03c9 100644
--- a/fs/reiserfs/tail_conversion.c
+++ b/fs/reiserfs/tail_conversion.c
@@ -205,7 +205,7 @@ int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *p_s_in
205 1) * p_s_sb->s_blocksize; 205 1) * p_s_sb->s_blocksize;
206 pos1 = pos; 206 pos1 = pos;
207 207
208 // we are protected by i_sem. The tail can not disapper, not 208 // we are protected by i_mutex. The tail can not disapper, not
209 // append can be done either 209 // append can be done either
210 // we are in truncate or packing tail in file_release 210 // we are in truncate or packing tail in file_release
211 211
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 02091eaac0b4..f1895f0a278e 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -67,11 +67,11 @@ static struct dentry *create_xa_root(struct super_block *sb)
67 goto out; 67 goto out;
68 } else if (!xaroot->d_inode) { 68 } else if (!xaroot->d_inode) {
69 int err; 69 int err;
70 down(&privroot->d_inode->i_sem); 70 mutex_lock(&privroot->d_inode->i_mutex);
71 err = 71 err =
72 privroot->d_inode->i_op->mkdir(privroot->d_inode, xaroot, 72 privroot->d_inode->i_op->mkdir(privroot->d_inode, xaroot,
73 0700); 73 0700);
74 up(&privroot->d_inode->i_sem); 74 mutex_unlock(&privroot->d_inode->i_mutex);
75 75
76 if (err) { 76 if (err) {
77 dput(xaroot); 77 dput(xaroot);
@@ -219,7 +219,7 @@ static struct dentry *get_xa_file_dentry(const struct inode *inode,
219 } else if (flags & XATTR_REPLACE || flags & FL_READONLY) { 219 } else if (flags & XATTR_REPLACE || flags & FL_READONLY) {
220 goto out; 220 goto out;
221 } else { 221 } else {
222 /* inode->i_sem is down, so nothing else can try to create 222 /* inode->i_mutex is down, so nothing else can try to create
223 * the same xattr */ 223 * the same xattr */
224 err = xadir->d_inode->i_op->create(xadir->d_inode, xafile, 224 err = xadir->d_inode->i_op->create(xadir->d_inode, xafile,
225 0700 | S_IFREG, NULL); 225 0700 | S_IFREG, NULL);
@@ -268,7 +268,7 @@ static struct file *open_xa_file(const struct inode *inode, const char *name,
268 * and don't mess with f->f_pos, but the idea is the same. Do some 268 * and don't mess with f->f_pos, but the idea is the same. Do some
269 * action on each and every entry in the directory. 269 * action on each and every entry in the directory.
270 * 270 *
271 * we're called with i_sem held, so there are no worries about the directory 271 * we're called with i_mutex held, so there are no worries about the directory
272 * changing underneath us. 272 * changing underneath us.
273 */ 273 */
274static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir) 274static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
@@ -426,7 +426,7 @@ int xattr_readdir(struct file *file, filldir_t filler, void *buf)
426 int res = -ENOTDIR; 426 int res = -ENOTDIR;
427 if (!file->f_op || !file->f_op->readdir) 427 if (!file->f_op || !file->f_op->readdir)
428 goto out; 428 goto out;
429 down(&inode->i_sem); 429 mutex_lock(&inode->i_mutex);
430// down(&inode->i_zombie); 430// down(&inode->i_zombie);
431 res = -ENOENT; 431 res = -ENOENT;
432 if (!IS_DEADDIR(inode)) { 432 if (!IS_DEADDIR(inode)) {
@@ -435,7 +435,7 @@ int xattr_readdir(struct file *file, filldir_t filler, void *buf)
435 unlock_kernel(); 435 unlock_kernel();
436 } 436 }
437// up(&inode->i_zombie); 437// up(&inode->i_zombie);
438 up(&inode->i_sem); 438 mutex_unlock(&inode->i_mutex);
439 out: 439 out:
440 return res; 440 return res;
441} 441}
@@ -480,7 +480,7 @@ static inline __u32 xattr_hash(const char *msg, int len)
480/* Generic extended attribute operations that can be used by xa plugins */ 480/* Generic extended attribute operations that can be used by xa plugins */
481 481
482/* 482/*
483 * inode->i_sem: down 483 * inode->i_mutex: down
484 */ 484 */
485int 485int
486reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer, 486reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
@@ -535,7 +535,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
535 /* Resize it so we're ok to write there */ 535 /* Resize it so we're ok to write there */
536 newattrs.ia_size = buffer_size; 536 newattrs.ia_size = buffer_size;
537 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; 537 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
538 down(&xinode->i_sem); 538 mutex_lock(&xinode->i_mutex);
539 err = notify_change(fp->f_dentry, &newattrs); 539 err = notify_change(fp->f_dentry, &newattrs);
540 if (err) 540 if (err)
541 goto out_filp; 541 goto out_filp;
@@ -598,7 +598,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
598 } 598 }
599 599
600 out_filp: 600 out_filp:
601 up(&xinode->i_sem); 601 mutex_unlock(&xinode->i_mutex);
602 fput(fp); 602 fput(fp);
603 603
604 out: 604 out:
@@ -606,7 +606,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
606} 606}
607 607
608/* 608/*
609 * inode->i_sem: down 609 * inode->i_mutex: down
610 */ 610 */
611int 611int
612reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer, 612reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer,
@@ -793,7 +793,7 @@ reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen,
793 793
794} 794}
795 795
796/* This is called w/ inode->i_sem downed */ 796/* This is called w/ inode->i_mutex downed */
797int reiserfs_delete_xattrs(struct inode *inode) 797int reiserfs_delete_xattrs(struct inode *inode)
798{ 798{
799 struct file *fp; 799 struct file *fp;
@@ -946,7 +946,7 @@ int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
946 946
947/* 947/*
948 * Inode operation getxattr() 948 * Inode operation getxattr()
949 * Preliminary locking: we down dentry->d_inode->i_sem 949 * Preliminary locking: we down dentry->d_inode->i_mutex
950 */ 950 */
951ssize_t 951ssize_t
952reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, 952reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
@@ -970,7 +970,7 @@ reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
970/* 970/*
971 * Inode operation setxattr() 971 * Inode operation setxattr()
972 * 972 *
973 * dentry->d_inode->i_sem down 973 * dentry->d_inode->i_mutex down
974 */ 974 */
975int 975int
976reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, 976reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
@@ -1008,7 +1008,7 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
1008/* 1008/*
1009 * Inode operation removexattr() 1009 * Inode operation removexattr()
1010 * 1010 *
1011 * dentry->d_inode->i_sem down 1011 * dentry->d_inode->i_mutex down
1012 */ 1012 */
1013int reiserfs_removexattr(struct dentry *dentry, const char *name) 1013int reiserfs_removexattr(struct dentry *dentry, const char *name)
1014{ 1014{
@@ -1091,7 +1091,7 @@ reiserfs_listxattr_filler(void *buf, const char *name, int namelen,
1091/* 1091/*
1092 * Inode operation listxattr() 1092 * Inode operation listxattr()
1093 * 1093 *
1094 * Preliminary locking: we down dentry->d_inode->i_sem 1094 * Preliminary locking: we down dentry->d_inode->i_mutex
1095 */ 1095 */
1096ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size) 1096ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
1097{ 1097{
@@ -1289,9 +1289,9 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
1289 if (!IS_ERR(dentry)) { 1289 if (!IS_ERR(dentry)) {
1290 if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) { 1290 if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) {
1291 struct inode *inode = dentry->d_parent->d_inode; 1291 struct inode *inode = dentry->d_parent->d_inode;
1292 down(&inode->i_sem); 1292 mutex_lock(&inode->i_mutex);
1293 err = inode->i_op->mkdir(inode, dentry, 0700); 1293 err = inode->i_op->mkdir(inode, dentry, 0700);
1294 up(&inode->i_sem); 1294 mutex_unlock(&inode->i_mutex);
1295 if (err) { 1295 if (err) {
1296 dput(dentry); 1296 dput(dentry);
1297 dentry = NULL; 1297 dentry = NULL;
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index a47ac9aac8b2..2dc953504cc0 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -174,7 +174,7 @@ static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
174/* 174/*
175 * Inode operation get_posix_acl(). 175 * Inode operation get_posix_acl().
176 * 176 *
177 * inode->i_sem: down 177 * inode->i_mutex: down
178 * BKL held [before 2.5.x] 178 * BKL held [before 2.5.x]
179 */ 179 */
180struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) 180struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
@@ -237,7 +237,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
237/* 237/*
238 * Inode operation set_posix_acl(). 238 * Inode operation set_posix_acl().
239 * 239 *
240 * inode->i_sem: down 240 * inode->i_mutex: down
241 * BKL held [before 2.5.x] 241 * BKL held [before 2.5.x]
242 */ 242 */
243static int 243static int
@@ -312,7 +312,7 @@ reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
312 return error; 312 return error;
313} 313}
314 314
315/* dir->i_sem: down, 315/* dir->i_mutex: locked,
316 * inode is new and not released into the wild yet */ 316 * inode is new and not released into the wild yet */
317int 317int
318reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry, 318reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
diff --git a/fs/relayfs/inode.c b/fs/relayfs/inode.c
index 7b7f2cb5f0e1..383523011aad 100644
--- a/fs/relayfs/inode.c
+++ b/fs/relayfs/inode.c
@@ -109,7 +109,7 @@ static struct dentry *relayfs_create_entry(const char *name,
109 } 109 }
110 110
111 parent = dget(parent); 111 parent = dget(parent);
112 down(&parent->d_inode->i_sem); 112 mutex_lock(&parent->d_inode->i_mutex);
113 d = lookup_one_len(name, parent, strlen(name)); 113 d = lookup_one_len(name, parent, strlen(name));
114 if (IS_ERR(d)) { 114 if (IS_ERR(d)) {
115 d = NULL; 115 d = NULL;
@@ -139,7 +139,7 @@ release_mount:
139 simple_release_fs(&relayfs_mount, &relayfs_mount_count); 139 simple_release_fs(&relayfs_mount, &relayfs_mount_count);
140 140
141exit: 141exit:
142 up(&parent->d_inode->i_sem); 142 mutex_unlock(&parent->d_inode->i_mutex);
143 dput(parent); 143 dput(parent);
144 return d; 144 return d;
145} 145}
@@ -204,7 +204,7 @@ int relayfs_remove(struct dentry *dentry)
204 return -EINVAL; 204 return -EINVAL;
205 205
206 parent = dget(parent); 206 parent = dget(parent);
207 down(&parent->d_inode->i_sem); 207 mutex_lock(&parent->d_inode->i_mutex);
208 if (dentry->d_inode) { 208 if (dentry->d_inode) {
209 if (S_ISDIR(dentry->d_inode->i_mode)) 209 if (S_ISDIR(dentry->d_inode->i_mode))
210 error = simple_rmdir(parent->d_inode, dentry); 210 error = simple_rmdir(parent->d_inode, dentry);
@@ -215,7 +215,7 @@ int relayfs_remove(struct dentry *dentry)
215 } 215 }
216 if (!error) 216 if (!error)
217 dput(dentry); 217 dput(dentry);
218 up(&parent->d_inode->i_sem); 218 mutex_unlock(&parent->d_inode->i_mutex);
219 dput(parent); 219 dput(parent);
220 220
221 if (!error) 221 if (!error)
@@ -476,7 +476,7 @@ static ssize_t relay_file_read(struct file *filp,
476 ssize_t ret = 0; 476 ssize_t ret = 0;
477 void *from; 477 void *from;
478 478
479 down(&inode->i_sem); 479 mutex_lock(&inode->i_mutex);
480 if(!relay_file_read_avail(buf, *ppos)) 480 if(!relay_file_read_avail(buf, *ppos))
481 goto out; 481 goto out;
482 482
@@ -494,7 +494,7 @@ static ssize_t relay_file_read(struct file *filp,
494 relay_file_read_consume(buf, read_start, count); 494 relay_file_read_consume(buf, read_start, count);
495 *ppos = relay_file_read_end_pos(buf, read_start, count); 495 *ppos = relay_file_read_end_pos(buf, read_start, count);
496out: 496out:
497 up(&inode->i_sem); 497 mutex_unlock(&inode->i_mutex);
498 return ret; 498 return ret;
499} 499}
500 500
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index d36780382176..49bd219275db 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -99,7 +99,7 @@ static int create_dir(struct kobject * k, struct dentry * p,
99 int error; 99 int error;
100 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; 100 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
101 101
102 down(&p->d_inode->i_sem); 102 mutex_lock(&p->d_inode->i_mutex);
103 *d = lookup_one_len(n, p, strlen(n)); 103 *d = lookup_one_len(n, p, strlen(n));
104 if (!IS_ERR(*d)) { 104 if (!IS_ERR(*d)) {
105 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR); 105 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR);
@@ -122,7 +122,7 @@ static int create_dir(struct kobject * k, struct dentry * p,
122 dput(*d); 122 dput(*d);
123 } else 123 } else
124 error = PTR_ERR(*d); 124 error = PTR_ERR(*d);
125 up(&p->d_inode->i_sem); 125 mutex_unlock(&p->d_inode->i_mutex);
126 return error; 126 return error;
127} 127}
128 128
@@ -246,7 +246,7 @@ static void remove_dir(struct dentry * d)
246 struct dentry * parent = dget(d->d_parent); 246 struct dentry * parent = dget(d->d_parent);
247 struct sysfs_dirent * sd; 247 struct sysfs_dirent * sd;
248 248
249 down(&parent->d_inode->i_sem); 249 mutex_lock(&parent->d_inode->i_mutex);
250 d_delete(d); 250 d_delete(d);
251 sd = d->d_fsdata; 251 sd = d->d_fsdata;
252 list_del_init(&sd->s_sibling); 252 list_del_init(&sd->s_sibling);
@@ -257,7 +257,7 @@ static void remove_dir(struct dentry * d)
257 pr_debug(" o %s removing done (%d)\n",d->d_name.name, 257 pr_debug(" o %s removing done (%d)\n",d->d_name.name,
258 atomic_read(&d->d_count)); 258 atomic_read(&d->d_count));
259 259
260 up(&parent->d_inode->i_sem); 260 mutex_unlock(&parent->d_inode->i_mutex);
261 dput(parent); 261 dput(parent);
262} 262}
263 263
@@ -286,7 +286,7 @@ void sysfs_remove_dir(struct kobject * kobj)
286 return; 286 return;
287 287
288 pr_debug("sysfs %s: removing dir\n",dentry->d_name.name); 288 pr_debug("sysfs %s: removing dir\n",dentry->d_name.name);
289 down(&dentry->d_inode->i_sem); 289 mutex_lock(&dentry->d_inode->i_mutex);
290 parent_sd = dentry->d_fsdata; 290 parent_sd = dentry->d_fsdata;
291 list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) { 291 list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) {
292 if (!sd->s_element || !(sd->s_type & SYSFS_NOT_PINNED)) 292 if (!sd->s_element || !(sd->s_type & SYSFS_NOT_PINNED))
@@ -295,7 +295,7 @@ void sysfs_remove_dir(struct kobject * kobj)
295 sysfs_drop_dentry(sd, dentry); 295 sysfs_drop_dentry(sd, dentry);
296 sysfs_put(sd); 296 sysfs_put(sd);
297 } 297 }
298 up(&dentry->d_inode->i_sem); 298 mutex_unlock(&dentry->d_inode->i_mutex);
299 299
300 remove_dir(dentry); 300 remove_dir(dentry);
301 /** 301 /**
@@ -318,7 +318,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
318 down_write(&sysfs_rename_sem); 318 down_write(&sysfs_rename_sem);
319 parent = kobj->parent->dentry; 319 parent = kobj->parent->dentry;
320 320
321 down(&parent->d_inode->i_sem); 321 mutex_lock(&parent->d_inode->i_mutex);
322 322
323 new_dentry = lookup_one_len(new_name, parent, strlen(new_name)); 323 new_dentry = lookup_one_len(new_name, parent, strlen(new_name));
324 if (!IS_ERR(new_dentry)) { 324 if (!IS_ERR(new_dentry)) {
@@ -334,7 +334,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
334 error = -EEXIST; 334 error = -EEXIST;
335 dput(new_dentry); 335 dput(new_dentry);
336 } 336 }
337 up(&parent->d_inode->i_sem); 337 mutex_unlock(&parent->d_inode->i_mutex);
338 up_write(&sysfs_rename_sem); 338 up_write(&sysfs_rename_sem);
339 339
340 return error; 340 return error;
@@ -345,9 +345,9 @@ static int sysfs_dir_open(struct inode *inode, struct file *file)
345 struct dentry * dentry = file->f_dentry; 345 struct dentry * dentry = file->f_dentry;
346 struct sysfs_dirent * parent_sd = dentry->d_fsdata; 346 struct sysfs_dirent * parent_sd = dentry->d_fsdata;
347 347
348 down(&dentry->d_inode->i_sem); 348 mutex_lock(&dentry->d_inode->i_mutex);
349 file->private_data = sysfs_new_dirent(parent_sd, NULL); 349 file->private_data = sysfs_new_dirent(parent_sd, NULL);
350 up(&dentry->d_inode->i_sem); 350 mutex_unlock(&dentry->d_inode->i_mutex);
351 351
352 return file->private_data ? 0 : -ENOMEM; 352 return file->private_data ? 0 : -ENOMEM;
353 353
@@ -358,9 +358,9 @@ static int sysfs_dir_close(struct inode *inode, struct file *file)
358 struct dentry * dentry = file->f_dentry; 358 struct dentry * dentry = file->f_dentry;
359 struct sysfs_dirent * cursor = file->private_data; 359 struct sysfs_dirent * cursor = file->private_data;
360 360
361 down(&dentry->d_inode->i_sem); 361 mutex_lock(&dentry->d_inode->i_mutex);
362 list_del_init(&cursor->s_sibling); 362 list_del_init(&cursor->s_sibling);
363 up(&dentry->d_inode->i_sem); 363 mutex_unlock(&dentry->d_inode->i_mutex);
364 364
365 release_sysfs_dirent(cursor); 365 release_sysfs_dirent(cursor);
366 366
@@ -436,7 +436,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
436{ 436{
437 struct dentry * dentry = file->f_dentry; 437 struct dentry * dentry = file->f_dentry;
438 438
439 down(&dentry->d_inode->i_sem); 439 mutex_lock(&dentry->d_inode->i_mutex);
440 switch (origin) { 440 switch (origin) {
441 case 1: 441 case 1:
442 offset += file->f_pos; 442 offset += file->f_pos;
@@ -444,7 +444,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
444 if (offset >= 0) 444 if (offset >= 0)
445 break; 445 break;
446 default: 446 default:
447 up(&file->f_dentry->d_inode->i_sem); 447 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
448 return -EINVAL; 448 return -EINVAL;
449 } 449 }
450 if (offset != file->f_pos) { 450 if (offset != file->f_pos) {
@@ -468,7 +468,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
468 list_add_tail(&cursor->s_sibling, p); 468 list_add_tail(&cursor->s_sibling, p);
469 } 469 }
470 } 470 }
471 up(&dentry->d_inode->i_sem); 471 mutex_unlock(&dentry->d_inode->i_mutex);
472 return offset; 472 return offset;
473} 473}
474 474
@@ -483,4 +483,3 @@ struct file_operations sysfs_dir_operations = {
483EXPORT_SYMBOL_GPL(sysfs_create_dir); 483EXPORT_SYMBOL_GPL(sysfs_create_dir);
484EXPORT_SYMBOL_GPL(sysfs_remove_dir); 484EXPORT_SYMBOL_GPL(sysfs_remove_dir);
485EXPORT_SYMBOL_GPL(sysfs_rename_dir); 485EXPORT_SYMBOL_GPL(sysfs_rename_dir);
486
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 4013d7905e84..d0e3d8495165 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -364,9 +364,9 @@ int sysfs_add_file(struct dentry * dir, const struct attribute * attr, int type)
364 umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG; 364 umode_t mode = (attr->mode & S_IALLUGO) | S_IFREG;
365 int error = 0; 365 int error = 0;
366 366
367 down(&dir->d_inode->i_sem); 367 mutex_lock(&dir->d_inode->i_mutex);
368 error = sysfs_make_dirent(parent_sd, NULL, (void *) attr, mode, type); 368 error = sysfs_make_dirent(parent_sd, NULL, (void *) attr, mode, type);
369 up(&dir->d_inode->i_sem); 369 mutex_unlock(&dir->d_inode->i_mutex);
370 370
371 return error; 371 return error;
372} 372}
@@ -398,7 +398,7 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
398 struct dentry * victim; 398 struct dentry * victim;
399 int res = -ENOENT; 399 int res = -ENOENT;
400 400
401 down(&dir->d_inode->i_sem); 401 mutex_lock(&dir->d_inode->i_mutex);
402 victim = lookup_one_len(attr->name, dir, strlen(attr->name)); 402 victim = lookup_one_len(attr->name, dir, strlen(attr->name));
403 if (!IS_ERR(victim)) { 403 if (!IS_ERR(victim)) {
404 /* make sure dentry is really there */ 404 /* make sure dentry is really there */
@@ -420,7 +420,7 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
420 */ 420 */
421 dput(victim); 421 dput(victim);
422 } 422 }
423 up(&dir->d_inode->i_sem); 423 mutex_unlock(&dir->d_inode->i_mutex);
424 424
425 return res; 425 return res;
426} 426}
@@ -441,22 +441,22 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
441 struct iattr newattrs; 441 struct iattr newattrs;
442 int res = -ENOENT; 442 int res = -ENOENT;
443 443
444 down(&dir->d_inode->i_sem); 444 mutex_lock(&dir->d_inode->i_mutex);
445 victim = lookup_one_len(attr->name, dir, strlen(attr->name)); 445 victim = lookup_one_len(attr->name, dir, strlen(attr->name));
446 if (!IS_ERR(victim)) { 446 if (!IS_ERR(victim)) {
447 if (victim->d_inode && 447 if (victim->d_inode &&
448 (victim->d_parent->d_inode == dir->d_inode)) { 448 (victim->d_parent->d_inode == dir->d_inode)) {
449 inode = victim->d_inode; 449 inode = victim->d_inode;
450 down(&inode->i_sem); 450 mutex_lock(&inode->i_mutex);
451 newattrs.ia_mode = (mode & S_IALLUGO) | 451 newattrs.ia_mode = (mode & S_IALLUGO) |
452 (inode->i_mode & ~S_IALLUGO); 452 (inode->i_mode & ~S_IALLUGO);
453 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; 453 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
454 res = notify_change(victim, &newattrs); 454 res = notify_change(victim, &newattrs);
455 up(&inode->i_sem); 455 mutex_unlock(&inode->i_mutex);
456 } 456 }
457 dput(victim); 457 dput(victim);
458 } 458 }
459 up(&dir->d_inode->i_sem); 459 mutex_unlock(&dir->d_inode->i_mutex);
460 460
461 return res; 461 return res;
462} 462}
@@ -480,4 +480,3 @@ void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr)
480EXPORT_SYMBOL_GPL(sysfs_create_file); 480EXPORT_SYMBOL_GPL(sysfs_create_file);
481EXPORT_SYMBOL_GPL(sysfs_remove_file); 481EXPORT_SYMBOL_GPL(sysfs_remove_file);
482EXPORT_SYMBOL_GPL(sysfs_update_file); 482EXPORT_SYMBOL_GPL(sysfs_update_file);
483
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 970a33f03299..c3133219941c 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -201,7 +201,7 @@ const unsigned char * sysfs_get_name(struct sysfs_dirent *sd)
201 201
202/* 202/*
203 * Unhashes the dentry corresponding to given sysfs_dirent 203 * Unhashes the dentry corresponding to given sysfs_dirent
204 * Called with parent inode's i_sem held. 204 * Called with parent inode's i_mutex held.
205 */ 205 */
206void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent) 206void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
207{ 207{
@@ -232,7 +232,7 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name)
232 /* no inode means this hasn't been made visible yet */ 232 /* no inode means this hasn't been made visible yet */
233 return; 233 return;
234 234
235 down(&dir->d_inode->i_sem); 235 mutex_lock(&dir->d_inode->i_mutex);
236 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { 236 list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
237 if (!sd->s_element) 237 if (!sd->s_element)
238 continue; 238 continue;
@@ -243,7 +243,5 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name)
243 break; 243 break;
244 } 244 }
245 } 245 }
246 up(&dir->d_inode->i_sem); 246 mutex_unlock(&dir->d_inode->i_mutex);
247} 247}
248
249
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index de402fa915f2..e38d6338a20d 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -86,9 +86,9 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
86 86
87 BUG_ON(!kobj || !kobj->dentry || !name); 87 BUG_ON(!kobj || !kobj->dentry || !name);
88 88
89 down(&dentry->d_inode->i_sem); 89 mutex_lock(&dentry->d_inode->i_mutex);
90 error = sysfs_add_link(dentry, name, target); 90 error = sysfs_add_link(dentry, name, target);
91 up(&dentry->d_inode->i_sem); 91 mutex_unlock(&dentry->d_inode->i_mutex);
92 return error; 92 return error;
93} 93}
94 94
@@ -177,4 +177,3 @@ struct inode_operations sysfs_symlink_inode_operations = {
177 177
178EXPORT_SYMBOL_GPL(sysfs_create_link); 178EXPORT_SYMBOL_GPL(sysfs_create_link);
179EXPORT_SYMBOL_GPL(sysfs_remove_link); 179EXPORT_SYMBOL_GPL(sysfs_remove_link);
180
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 2ba11a9aa995..e9a42c711a9e 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -1275,7 +1275,7 @@ static ssize_t ufs_quota_write(struct super_block *sb, int type,
1275 size_t towrite = len; 1275 size_t towrite = len;
1276 struct buffer_head *bh; 1276 struct buffer_head *bh;
1277 1277
1278 down(&inode->i_sem); 1278 mutex_lock(&inode->i_mutex);
1279 while (towrite > 0) { 1279 while (towrite > 0) {
1280 tocopy = sb->s_blocksize - offset < towrite ? 1280 tocopy = sb->s_blocksize - offset < towrite ?
1281 sb->s_blocksize - offset : towrite; 1281 sb->s_blocksize - offset : towrite;
@@ -1297,7 +1297,7 @@ static ssize_t ufs_quota_write(struct super_block *sb, int type,
1297 } 1297 }
1298out: 1298out:
1299 if (len == towrite) { 1299 if (len == towrite) {
1300 up(&inode->i_sem); 1300 mutex_unlock(&inode->i_mutex);
1301 return err; 1301 return err;
1302 } 1302 }
1303 if (inode->i_size < off+len-towrite) 1303 if (inode->i_size < off+len-towrite)
@@ -1305,7 +1305,7 @@ out:
1305 inode->i_version++; 1305 inode->i_version++;
1306 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; 1306 inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
1307 mark_inode_dirty(inode); 1307 mark_inode_dirty(inode);
1308 up(&inode->i_sem); 1308 mutex_unlock(&inode->i_mutex);
1309 return len - towrite; 1309 return len - towrite;
1310} 1310}
1311 1311
diff --git a/fs/xattr.c b/fs/xattr.c
index bcc2156d4d28..386a532ee5a9 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -51,7 +51,7 @@ setxattr(struct dentry *d, char __user *name, void __user *value,
51 } 51 }
52 } 52 }
53 53
54 down(&d->d_inode->i_sem); 54 mutex_lock(&d->d_inode->i_mutex);
55 error = security_inode_setxattr(d, kname, kvalue, size, flags); 55 error = security_inode_setxattr(d, kname, kvalue, size, flags);
56 if (error) 56 if (error)
57 goto out; 57 goto out;
@@ -73,7 +73,7 @@ setxattr(struct dentry *d, char __user *name, void __user *value,
73 fsnotify_xattr(d); 73 fsnotify_xattr(d);
74 } 74 }
75out: 75out:
76 up(&d->d_inode->i_sem); 76 mutex_unlock(&d->d_inode->i_mutex);
77 kfree(kvalue); 77 kfree(kvalue);
78 return error; 78 return error;
79} 79}
@@ -323,9 +323,9 @@ removexattr(struct dentry *d, char __user *name)
323 error = security_inode_removexattr(d, kname); 323 error = security_inode_removexattr(d, kname);
324 if (error) 324 if (error)
325 goto out; 325 goto out;
326 down(&d->d_inode->i_sem); 326 mutex_lock(&d->d_inode->i_mutex);
327 error = d->d_inode->i_op->removexattr(d, kname); 327 error = d->d_inode->i_op->removexattr(d, kname);
328 up(&d->d_inode->i_sem); 328 mutex_unlock(&d->d_inode->i_mutex);
329 if (!error) 329 if (!error)
330 fsnotify_xattr(d); 330 fsnotify_xattr(d);
331 } 331 }
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 14215a7db59f..41c478bb1ffc 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -203,7 +203,7 @@ validate_fields(
203 ip->i_nlink = va.va_nlink; 203 ip->i_nlink = va.va_nlink;
204 ip->i_blocks = va.va_nblocks; 204 ip->i_blocks = va.va_nblocks;
205 205
206 /* we're under i_sem so i_size can't change under us */ 206 /* we're under i_mutex so i_size can't change under us */
207 if (i_size_read(ip) != va.va_size) 207 if (i_size_read(ip) != va.va_size)
208 i_size_write(ip, va.va_size); 208 i_size_write(ip, va.va_size);
209 } 209 }
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 279e9bc92aba..5675117ef227 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -254,7 +254,7 @@ xfs_read(
254 } 254 }
255 255
256 if (unlikely(ioflags & IO_ISDIRECT)) 256 if (unlikely(ioflags & IO_ISDIRECT))
257 down(&inode->i_sem); 257 mutex_lock(&inode->i_mutex);
258 xfs_ilock(ip, XFS_IOLOCK_SHARED); 258 xfs_ilock(ip, XFS_IOLOCK_SHARED);
259 259
260 if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) && 260 if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
@@ -286,7 +286,7 @@ xfs_read(
286 286
287unlock_isem: 287unlock_isem:
288 if (unlikely(ioflags & IO_ISDIRECT)) 288 if (unlikely(ioflags & IO_ISDIRECT))
289 up(&inode->i_sem); 289 mutex_unlock(&inode->i_mutex);
290 return ret; 290 return ret;
291} 291}
292 292
@@ -655,7 +655,7 @@ relock:
655 iolock = XFS_IOLOCK_EXCL; 655 iolock = XFS_IOLOCK_EXCL;
656 locktype = VRWLOCK_WRITE; 656 locktype = VRWLOCK_WRITE;
657 657
658 down(&inode->i_sem); 658 mutex_lock(&inode->i_mutex);
659 } else { 659 } else {
660 iolock = XFS_IOLOCK_SHARED; 660 iolock = XFS_IOLOCK_SHARED;
661 locktype = VRWLOCK_WRITE_DIRECT; 661 locktype = VRWLOCK_WRITE_DIRECT;
@@ -686,7 +686,7 @@ start:
686 int dmflags = FILP_DELAY_FLAG(file); 686 int dmflags = FILP_DELAY_FLAG(file);
687 687
688 if (need_isem) 688 if (need_isem)
689 dmflags |= DM_FLAGS_ISEM; 689 dmflags |= DM_FLAGS_IMUX;
690 690
691 xfs_iunlock(xip, XFS_ILOCK_EXCL); 691 xfs_iunlock(xip, XFS_ILOCK_EXCL);
692 error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp, 692 error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp,
@@ -772,7 +772,7 @@ retry:
772 if (need_isem) { 772 if (need_isem) {
773 /* demote the lock now the cached pages are gone */ 773 /* demote the lock now the cached pages are gone */
774 XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL); 774 XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
775 up(&inode->i_sem); 775 mutex_unlock(&inode->i_mutex);
776 776
777 iolock = XFS_IOLOCK_SHARED; 777 iolock = XFS_IOLOCK_SHARED;
778 locktype = VRWLOCK_WRITE_DIRECT; 778 locktype = VRWLOCK_WRITE_DIRECT;
@@ -817,14 +817,14 @@ retry:
817 817
818 xfs_rwunlock(bdp, locktype); 818 xfs_rwunlock(bdp, locktype);
819 if (need_isem) 819 if (need_isem)
820 up(&inode->i_sem); 820 mutex_unlock(&inode->i_mutex);
821 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, 821 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
822 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL, 822 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
823 0, 0, 0); /* Delay flag intentionally unused */ 823 0, 0, 0); /* Delay flag intentionally unused */
824 if (error) 824 if (error)
825 goto out_nounlocks; 825 goto out_nounlocks;
826 if (need_isem) 826 if (need_isem)
827 down(&inode->i_sem); 827 mutex_lock(&inode->i_mutex);
828 xfs_rwlock(bdp, locktype); 828 xfs_rwlock(bdp, locktype);
829 pos = xip->i_d.di_size; 829 pos = xip->i_d.di_size;
830 ret = 0; 830 ret = 0;
@@ -926,7 +926,7 @@ retry:
926 926
927 xfs_rwunlock(bdp, locktype); 927 xfs_rwunlock(bdp, locktype);
928 if (need_isem) 928 if (need_isem)
929 up(&inode->i_sem); 929 mutex_unlock(&inode->i_mutex);
930 930
931 error = sync_page_range(inode, mapping, pos, ret); 931 error = sync_page_range(inode, mapping, pos, ret);
932 if (!error) 932 if (!error)
@@ -938,7 +938,7 @@ retry:
938 xfs_rwunlock(bdp, locktype); 938 xfs_rwunlock(bdp, locktype);
939 out_unlock_isem: 939 out_unlock_isem:
940 if (need_isem) 940 if (need_isem)
941 up(&inode->i_sem); 941 mutex_unlock(&inode->i_mutex);
942 out_nounlocks: 942 out_nounlocks:
943 return -error; 943 return -error;
944} 944}
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h
index 864bf6955689..b4c7f2bc55a0 100644
--- a/fs/xfs/xfs_dmapi.h
+++ b/fs/xfs/xfs_dmapi.h
@@ -152,7 +152,7 @@ typedef enum {
152 152
153#define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */ 153#define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
154#define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */ 154#define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
155#define DM_FLAGS_ISEM 0x004 /* thread holds i_sem */ 155#define DM_FLAGS_IMUX 0x004 /* thread holds i_mutex */
156#define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */ 156#define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
157#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */ 157#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
158 158
@@ -161,21 +161,21 @@ typedef enum {
161 */ 161 */
162#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) 162#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
163#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ 163#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
164 DM_FLAGS_ISEM : 0) 164 DM_FLAGS_IMUX : 0)
165#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM) 165#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_IMUX)
166#endif 166#endif
167 167
168#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \ 168#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
169 (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22)) 169 (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22))
170#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ 170#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
171 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM) 171 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_IMUX)
172#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM) 172#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_IMUX)
173#endif 173#endif
174 174
175#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21) 175#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21)
176#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ 176#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
177 0 : DM_FLAGS_ISEM) 177 0 : DM_FLAGS_IMUX)
178#define DM_SEM_FLAG_WR (DM_FLAGS_ISEM) 178#define DM_SEM_FLAG_WR (DM_FLAGS_IMUX)
179#endif 179#endif
180 180
181 181