aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c12
-rw-r--r--drivers/block/loop.c4
-rw-r--r--drivers/char/mem.c4
-rw-r--r--drivers/isdn/capi/capifs.c6
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/md/md.c8
-rw-r--r--drivers/pci/proc.c4
-rw-r--r--drivers/usb/core/inode.c28
-rw-r--r--drivers/usb/gadget/file_storage.c4
-rw-r--r--drivers/usb/gadget/inode.c4
-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
-rw-r--r--include/linux/ext3_fs_i.h2
-rw-r--r--include/linux/fs.h7
-rw-r--r--include/linux/jffs2_fs_i.h4
-rw-r--r--include/linux/nfsd/nfsfh.h6
-rw-r--r--include/linux/pipe_fs_i.h2
-rw-r--r--include/linux/reiserfs_fs.h2
-rw-r--r--ipc/mqueue.c8
-rw-r--r--kernel/cpuset.c10
-rw-r--r--mm/filemap.c30
-rw-r--r--mm/filemap_xip.c6
-rw-r--r--mm/memory.c4
-rw-r--r--mm/msync.c2
-rw-r--r--mm/rmap.c8
-rw-r--r--mm/shmem.c6
-rw-r--r--mm/swapfile.c8
-rw-r--r--mm/truncate.c2
-rw-r--r--net/sunrpc/rpc_pipe.c58
-rw-r--r--net/unix/af_unix.c4
-rw-r--r--security/inode.c8
-rw-r--r--sound/core/oss/pcm_oss.c2
-rw-r--r--sound/core/seq/seq_memory.c4
113 files changed, 563 insertions, 573 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 1f3507c75e9..d2ba358c6e3 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -137,7 +137,7 @@ spufs_delete_inode(struct inode *inode)
137static void spufs_prune_dir(struct dentry *dir) 137static void spufs_prune_dir(struct dentry *dir)
138{ 138{
139 struct dentry *dentry, *tmp; 139 struct dentry *dentry, *tmp;
140 down(&dir->d_inode->i_sem); 140 mutex_lock(&dir->d_inode->i_mutex);
141 list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) { 141 list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
142 spin_lock(&dcache_lock); 142 spin_lock(&dcache_lock);
143 spin_lock(&dentry->d_lock); 143 spin_lock(&dentry->d_lock);
@@ -154,7 +154,7 @@ static void spufs_prune_dir(struct dentry *dir)
154 } 154 }
155 } 155 }
156 shrink_dcache_parent(dir); 156 shrink_dcache_parent(dir);
157 up(&dir->d_inode->i_sem); 157 mutex_unlock(&dir->d_inode->i_mutex);
158} 158}
159 159
160static int spufs_rmdir(struct inode *root, struct dentry *dir_dentry) 160static int spufs_rmdir(struct inode *root, struct dentry *dir_dentry)
@@ -162,15 +162,15 @@ static int spufs_rmdir(struct inode *root, struct dentry *dir_dentry)
162 struct spu_context *ctx; 162 struct spu_context *ctx;
163 163
164 /* remove all entries */ 164 /* remove all entries */
165 down(&root->i_sem); 165 mutex_lock(&root->i_mutex);
166 spufs_prune_dir(dir_dentry); 166 spufs_prune_dir(dir_dentry);
167 up(&root->i_sem); 167 mutex_unlock(&root->i_mutex);
168 168
169 /* We have to give up the mm_struct */ 169 /* We have to give up the mm_struct */
170 ctx = SPUFS_I(dir_dentry->d_inode)->i_ctx; 170 ctx = SPUFS_I(dir_dentry->d_inode)->i_ctx;
171 spu_forget(ctx); 171 spu_forget(ctx);
172 172
173 /* XXX Do we need to hold i_sem here ? */ 173 /* XXX Do we need to hold i_mutex here ? */
174 return simple_rmdir(root, dir_dentry); 174 return simple_rmdir(root, dir_dentry);
175} 175}
176 176
@@ -330,7 +330,7 @@ long spufs_create_thread(struct nameidata *nd,
330out_dput: 330out_dput:
331 dput(dentry); 331 dput(dentry);
332out_dir: 332out_dir:
333 up(&nd->dentry->d_inode->i_sem); 333 mutex_unlock(&nd->dentry->d_inode->i_mutex);
334out: 334out:
335 return ret; 335 return ret;
336} 336}
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index a452b13620a..bed9ad76c04 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -215,7 +215,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
215 unsigned offset, bv_offs; 215 unsigned offset, bv_offs;
216 int len, ret; 216 int len, ret;
217 217
218 down(&mapping->host->i_sem); 218 mutex_lock(&mapping->host->i_mutex);
219 index = pos >> PAGE_CACHE_SHIFT; 219 index = pos >> PAGE_CACHE_SHIFT;
220 offset = pos & ((pgoff_t)PAGE_CACHE_SIZE - 1); 220 offset = pos & ((pgoff_t)PAGE_CACHE_SIZE - 1);
221 bv_offs = bvec->bv_offset; 221 bv_offs = bvec->bv_offset;
@@ -278,7 +278,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
278 } 278 }
279 ret = 0; 279 ret = 0;
280out: 280out:
281 up(&mapping->host->i_sem); 281 mutex_unlock(&mapping->host->i_mutex);
282 return ret; 282 return ret;
283unlock: 283unlock:
284 unlock_page(page); 284 unlock_page(page);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 5b2d1803507..704c3c07f0a 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -741,7 +741,7 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig)
741{ 741{
742 loff_t ret; 742 loff_t ret;
743 743
744 down(&file->f_dentry->d_inode->i_sem); 744 mutex_lock(&file->f_dentry->d_inode->i_mutex);
745 switch (orig) { 745 switch (orig) {
746 case 0: 746 case 0:
747 file->f_pos = offset; 747 file->f_pos = offset;
@@ -756,7 +756,7 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig)
756 default: 756 default:
757 ret = -EINVAL; 757 ret = -EINVAL;
758 } 758 }
759 up(&file->f_dentry->d_inode->i_sem); 759 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
760 return ret; 760 return ret;
761} 761}
762 762
diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c
index 207cae36625..0a37aded4b5 100644
--- a/drivers/isdn/capi/capifs.c
+++ b/drivers/isdn/capi/capifs.c
@@ -138,7 +138,7 @@ static struct dentry *get_node(int num)
138{ 138{
139 char s[10]; 139 char s[10];
140 struct dentry *root = capifs_root; 140 struct dentry *root = capifs_root;
141 down(&root->d_inode->i_sem); 141 mutex_lock(&root->d_inode->i_mutex);
142 return lookup_one_len(s, root, sprintf(s, "%d", num)); 142 return lookup_one_len(s, root, sprintf(s, "%d", num));
143} 143}
144 144
@@ -159,7 +159,7 @@ void capifs_new_ncci(unsigned int number, dev_t device)
159 dentry = get_node(number); 159 dentry = get_node(number);
160 if (!IS_ERR(dentry) && !dentry->d_inode) 160 if (!IS_ERR(dentry) && !dentry->d_inode)
161 d_instantiate(dentry, inode); 161 d_instantiate(dentry, inode);
162 up(&capifs_root->d_inode->i_sem); 162 mutex_unlock(&capifs_root->d_inode->i_mutex);
163} 163}
164 164
165void capifs_free_ncci(unsigned int number) 165void capifs_free_ncci(unsigned int number)
@@ -175,7 +175,7 @@ void capifs_free_ncci(unsigned int number)
175 } 175 }
176 dput(dentry); 176 dput(dentry);
177 } 177 }
178 up(&capifs_root->d_inode->i_sem); 178 mutex_unlock(&capifs_root->d_inode->i_mutex);
179} 179}
180 180
181static int __init capifs_init(void) 181static int __init capifs_init(void)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 0e481512f91..5c210b0a4cb 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -837,9 +837,9 @@ static void __set_size(struct mapped_device *md, sector_t size)
837{ 837{
838 set_capacity(md->disk, size); 838 set_capacity(md->disk, size);
839 839
840 down(&md->suspended_bdev->bd_inode->i_sem); 840 mutex_lock(&md->suspended_bdev->bd_inode->i_mutex);
841 i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT); 841 i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
842 up(&md->suspended_bdev->bd_inode->i_sem); 842 mutex_unlock(&md->suspended_bdev->bd_inode->i_mutex);
843} 843}
844 844
845static int __bind(struct mapped_device *md, struct dm_table *t) 845static int __bind(struct mapped_device *md, struct dm_table *t)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index e423a16ba3c..0302723fa21 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3460,9 +3460,9 @@ static int update_size(mddev_t *mddev, unsigned long size)
3460 3460
3461 bdev = bdget_disk(mddev->gendisk, 0); 3461 bdev = bdget_disk(mddev->gendisk, 0);
3462 if (bdev) { 3462 if (bdev) {
3463 down(&bdev->bd_inode->i_sem); 3463 mutex_lock(&bdev->bd_inode->i_mutex);
3464 i_size_write(bdev->bd_inode, mddev->array_size << 10); 3464 i_size_write(bdev->bd_inode, mddev->array_size << 10);
3465 up(&bdev->bd_inode->i_sem); 3465 mutex_unlock(&bdev->bd_inode->i_mutex);
3466 bdput(bdev); 3466 bdput(bdev);
3467 } 3467 }
3468 } 3468 }
@@ -3486,9 +3486,9 @@ static int update_raid_disks(mddev_t *mddev, int raid_disks)
3486 3486
3487 bdev = bdget_disk(mddev->gendisk, 0); 3487 bdev = bdget_disk(mddev->gendisk, 0);
3488 if (bdev) { 3488 if (bdev) {
3489 down(&bdev->bd_inode->i_sem); 3489 mutex_lock(&bdev->bd_inode->i_mutex);
3490 i_size_write(bdev->bd_inode, mddev->array_size << 10); 3490 i_size_write(bdev->bd_inode, mddev->array_size << 10);
3491 up(&bdev->bd_inode->i_sem); 3491 mutex_unlock(&bdev->bd_inode->i_mutex);
3492 bdput(bdev); 3492 bdput(bdev);
3493 } 3493 }
3494 } 3494 }
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 9eb465727fc..9cb6dd0834b 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -25,7 +25,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
25 loff_t new = -1; 25 loff_t new = -1;
26 struct inode *inode = file->f_dentry->d_inode; 26 struct inode *inode = file->f_dentry->d_inode;
27 27
28 down(&inode->i_sem); 28 mutex_lock(&inode->i_mutex);
29 switch (whence) { 29 switch (whence) {
30 case 0: 30 case 0:
31 new = off; 31 new = off;
@@ -41,7 +41,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
41 new = -EINVAL; 41 new = -EINVAL;
42 else 42 else
43 file->f_pos = new; 43 file->f_pos = new;
44 up(&inode->i_sem); 44 mutex_unlock(&inode->i_mutex);
45 return new; 45 return new;
46} 46}
47 47
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 4ddc453023a..3cf945cc5b9 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -184,13 +184,13 @@ static void update_bus(struct dentry *bus)
184 bus->d_inode->i_gid = busgid; 184 bus->d_inode->i_gid = busgid;
185 bus->d_inode->i_mode = S_IFDIR | busmode; 185 bus->d_inode->i_mode = S_IFDIR | busmode;
186 186
187 down(&bus->d_inode->i_sem); 187 mutex_lock(&bus->d_inode->i_mutex);
188 188
189 list_for_each_entry(dev, &bus->d_subdirs, d_u.d_child) 189 list_for_each_entry(dev, &bus->d_subdirs, d_u.d_child)
190 if (dev->d_inode) 190 if (dev->d_inode)
191 update_dev(dev); 191 update_dev(dev);
192 192
193 up(&bus->d_inode->i_sem); 193 mutex_unlock(&bus->d_inode->i_mutex);
194} 194}
195 195
196static void update_sb(struct super_block *sb) 196static void update_sb(struct super_block *sb)
@@ -201,7 +201,7 @@ static void update_sb(struct super_block *sb)
201 if (!root) 201 if (!root)
202 return; 202 return;
203 203
204 down(&root->d_inode->i_sem); 204 mutex_lock(&root->d_inode->i_mutex);
205 205
206 list_for_each_entry(bus, &root->d_subdirs, d_u.d_child) { 206 list_for_each_entry(bus, &root->d_subdirs, d_u.d_child) {
207 if (bus->d_inode) { 207 if (bus->d_inode) {
@@ -219,7 +219,7 @@ static void update_sb(struct super_block *sb)
219 } 219 }
220 } 220 }
221 221
222 up(&root->d_inode->i_sem); 222 mutex_unlock(&root->d_inode->i_mutex);
223} 223}
224 224
225static int remount(struct super_block *sb, int *flags, char *data) 225static int remount(struct super_block *sb, int *flags, char *data)
@@ -333,10 +333,10 @@ static int usbfs_empty (struct dentry *dentry)
333static int usbfs_unlink (struct inode *dir, struct dentry *dentry) 333static int usbfs_unlink (struct inode *dir, struct dentry *dentry)
334{ 334{
335 struct inode *inode = dentry->d_inode; 335 struct inode *inode = dentry->d_inode;
336 down(&inode->i_sem); 336 mutex_lock(&inode->i_mutex);
337 dentry->d_inode->i_nlink--; 337 dentry->d_inode->i_nlink--;
338 dput(dentry); 338 dput(dentry);
339 up(&inode->i_sem); 339 mutex_unlock(&inode->i_mutex);
340 d_delete(dentry); 340 d_delete(dentry);
341 return 0; 341 return 0;
342} 342}
@@ -346,7 +346,7 @@ static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
346 int error = -ENOTEMPTY; 346 int error = -ENOTEMPTY;
347 struct inode * inode = dentry->d_inode; 347 struct inode * inode = dentry->d_inode;
348 348
349 down(&inode->i_sem); 349 mutex_lock(&inode->i_mutex);
350 dentry_unhash(dentry); 350 dentry_unhash(dentry);
351 if (usbfs_empty(dentry)) { 351 if (usbfs_empty(dentry)) {
352 dentry->d_inode->i_nlink -= 2; 352 dentry->d_inode->i_nlink -= 2;
@@ -355,7 +355,7 @@ static int usbfs_rmdir(struct inode *dir, struct dentry *dentry)
355 dir->i_nlink--; 355 dir->i_nlink--;
356 error = 0; 356 error = 0;
357 } 357 }
358 up(&inode->i_sem); 358 mutex_unlock(&inode->i_mutex);
359 if (!error) 359 if (!error)
360 d_delete(dentry); 360 d_delete(dentry);
361 dput(dentry); 361 dput(dentry);
@@ -380,7 +380,7 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
380{ 380{
381 loff_t retval = -EINVAL; 381 loff_t retval = -EINVAL;
382 382
383 down(&file->f_dentry->d_inode->i_sem); 383 mutex_lock(&file->f_dentry->d_inode->i_mutex);
384 switch(orig) { 384 switch(orig) {
385 case 0: 385 case 0:
386 if (offset > 0) { 386 if (offset > 0) {
@@ -397,7 +397,7 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
397 default: 397 default:
398 break; 398 break;
399 } 399 }
400 up(&file->f_dentry->d_inode->i_sem); 400 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
401 return retval; 401 return retval;
402} 402}
403 403
@@ -480,7 +480,7 @@ static int fs_create_by_name (const char *name, mode_t mode,
480 } 480 }
481 481
482 *dentry = NULL; 482 *dentry = NULL;
483 down(&parent->d_inode->i_sem); 483 mutex_lock(&parent->d_inode->i_mutex);
484 *dentry = lookup_one_len(name, parent, strlen(name)); 484 *dentry = lookup_one_len(name, parent, strlen(name));
485 if (!IS_ERR(dentry)) { 485 if (!IS_ERR(dentry)) {
486 if ((mode & S_IFMT) == S_IFDIR) 486 if ((mode & S_IFMT) == S_IFDIR)
@@ -489,7 +489,7 @@ static int fs_create_by_name (const char *name, mode_t mode,
489 error = usbfs_create (parent->d_inode, *dentry, mode); 489 error = usbfs_create (parent->d_inode, *dentry, mode);
490 } else 490 } else
491 error = PTR_ERR(dentry); 491 error = PTR_ERR(dentry);
492 up(&parent->d_inode->i_sem); 492 mutex_unlock(&parent->d_inode->i_mutex);
493 493
494 return error; 494 return error;
495} 495}
@@ -528,7 +528,7 @@ static void fs_remove_file (struct dentry *dentry)
528 if (!parent || !parent->d_inode) 528 if (!parent || !parent->d_inode)
529 return; 529 return;
530 530
531 down(&parent->d_inode->i_sem); 531 mutex_lock(&parent->d_inode->i_mutex);
532 if (usbfs_positive(dentry)) { 532 if (usbfs_positive(dentry)) {
533 if (dentry->d_inode) { 533 if (dentry->d_inode) {
534 if (S_ISDIR(dentry->d_inode->i_mode)) 534 if (S_ISDIR(dentry->d_inode->i_mode))
@@ -538,7 +538,7 @@ static void fs_remove_file (struct dentry *dentry)
538 dput(dentry); 538 dput(dentry);
539 } 539 }
540 } 540 }
541 up(&parent->d_inode->i_sem); 541 mutex_unlock(&parent->d_inode->i_mutex);
542} 542}
543 543
544/* --------------------------------------------------------------------- */ 544/* --------------------------------------------------------------------- */
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 0cea9782d7d..de59c58896d 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -1891,7 +1891,7 @@ static int fsync_sub(struct lun *curlun)
1891 return -EINVAL; 1891 return -EINVAL;
1892 1892
1893 inode = filp->f_dentry->d_inode; 1893 inode = filp->f_dentry->d_inode;
1894 down(&inode->i_sem); 1894 mutex_lock(&inode->i_mutex);
1895 current->flags |= PF_SYNCWRITE; 1895 current->flags |= PF_SYNCWRITE;
1896 rc = filemap_fdatawrite(inode->i_mapping); 1896 rc = filemap_fdatawrite(inode->i_mapping);
1897 err = filp->f_op->fsync(filp, filp->f_dentry, 1); 1897 err = filp->f_op->fsync(filp, filp->f_dentry, 1);
@@ -1901,7 +1901,7 @@ static int fsync_sub(struct lun *curlun)
1901 if (!rc) 1901 if (!rc)
1902 rc = err; 1902 rc = err;
1903 current->flags &= ~PF_SYNCWRITE; 1903 current->flags &= ~PF_SYNCWRITE;
1904 up(&inode->i_sem); 1904 mutex_unlock(&inode->i_mutex);
1905 VLDBG(curlun, "fdatasync -> %d\n", rc); 1905 VLDBG(curlun, "fdatasync -> %d\n", rc);
1906 return rc; 1906 return rc;
1907} 1907}
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 5c40980a5bd..c6c279de832 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -1562,10 +1562,10 @@ restart:
1562 spin_unlock_irq (&dev->lock); 1562 spin_unlock_irq (&dev->lock);
1563 1563
1564 /* break link to dcache */ 1564 /* break link to dcache */
1565 down (&parent->i_sem); 1565 mutex_lock (&parent->i_mutex);
1566 d_delete (dentry); 1566 d_delete (dentry);
1567 dput (dentry); 1567 dput (dentry);
1568 up (&parent->i_sem); 1568 mutex_unlock (&parent->i_mutex);
1569 1569
1570 /* fds may still be open */ 1570 /* fds may still be open */
1571 goto restart; 1571 goto restart;
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 9ebe881c678..44d439cb69f 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 a1ab1c0ed21..808134a5a2f 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 2241405ffc4..541b19e6fec 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 2568eb41cb3..9ccc7d8275b 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 e0df94c37b7..6e50346fb1e 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 55f0975a9b1..6466bc8a3dc 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 2a13a2bac8f..e10213b7541 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 9558f51bca5..3ebce9430f4 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 2391766e9c7..8f1a517f8b4 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 e6bc022568f..30b4630bd73 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 e48b539243a..b668ec61527 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 af1ffc9a15c..c26cd61f13a 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 6b274c6d428..6577c588de9 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 a86ac4aeaed..d4f1a2cddd4 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 1274422a538..b621521e09d 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 f2be44d4491..bfb8a230bac 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 3931e7f1e6b..30dbbd1df51 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 2a62b3dc20e..cb6d5bfbdfd 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 c49d6254379..5bfe40085fb 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 6af2f413029..239133d01d9 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 e977f8566d1..00de0a7312a 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 522fa70dd8e..8d6819846fc 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 0099462d427..f7a3b5fee27 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 3ac38266fc9..9ed132c9603 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 7c45acf9458..c3dbebdb989 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 430de9f63be..238199d82ce 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 eef1b81aa29..db0de5c621c 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 9b07c328a6f..d30876cf35f 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 5455916241f..923371b753a 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 05dedddf428..63d2980df5c 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 d499393a8ae..050a4927649 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 c7d316455fa..9fb51632303 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 fc98583cf04..983bcd02ac1 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 0217c3a0444..5591f9623aa 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 52930915bad..a44dc589739 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 8c41315a6e4..ff1b7d108bd 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 fd568caf7f7..e08767fd57b 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 2559ee10bed..fc3855a1aef 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 c0fd7b3eadc..dc21a5bd54d 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 9c50523382e..63c020e6589 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 300eae088d5..0a8f073435a 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 3e8fb61ad59..f0e353f5bc3 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 e9255198f76..a1554bead69 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 954cf893d50..be963a133aa 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 df4019f0456..bb36b430449 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 eda056bac25..9480a0526cd 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 795c3d1930f..b0690d4c890 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 72753389181..30f71acdc1c 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 8f2d5727546..9f5427c2d10 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 b24f4c4b2c5..bda7a08911a 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 351dbc3b6e4..5ea9eb93af6 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 833df2a4e9f..d0ef4182147 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 6c16db9e1a8..280e383fc84 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 465f797451e..6b9812db377 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 5fd60c10591..cf7828f2336 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 856e20ae826..57158fa75d9 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 72ae9e3306f..ca5f9f90d79 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 a91ba4dec93..d4ecc062771 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 04428042e5e..303c8d96457 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 fe373a2101d..149b3518166 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 75f3329e8a6..a3b3a9b5c2f 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 66aa0b938d6..acb030b61fb 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 612e04db4b9..d14d872646d 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 df3468a22fe..3f7a1a62165 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 b03579bc021..b6109329b60 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 7892a865b58..127e7d2cabd 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 a5e3a0ddbe5..ffa34b861bd 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 81fc00285f6..ba8bf8df6dc 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 42afb5bef11..397d9590c8f 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 c92e124f628..196e971c03c 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 02091eaac0b..f1895f0a278 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 a47ac9aac8b..2dc953504cc 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 7b7f2cb5f0e..383523011aa 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 d3678038217..49bd219275d 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 4013d7905e8..d0e3d849516 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 970a33f0329..c3133219941 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 de402fa915f..e38d6338a20 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 2ba11a9aa99..e9a42c711a9 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 bcc2156d4d2..386a532ee5a 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 14215a7db59..41c478bb1ff 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 279e9bc92ab..5675117ef22 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 864bf695568..b4c7f2bc55a 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
diff --git a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h
index 2914f7b0715..e71dd98dbca 100644
--- a/include/linux/ext3_fs_i.h
+++ b/include/linux/ext3_fs_i.h
@@ -87,7 +87,7 @@ struct ext3_inode_info {
87#ifdef CONFIG_EXT3_FS_XATTR 87#ifdef CONFIG_EXT3_FS_XATTR
88 /* 88 /*
89 * Extended attributes can be read independently of the main file 89 * Extended attributes can be read independently of the main file
90 * data. Taking i_sem even when reading would cause contention 90 * data. Taking i_mutex even when reading would cause contention
91 * between readers of EAs and writers of regular file data, so 91 * between readers of EAs and writers of regular file data, so
92 * instead we synchronize on xattr_sem when reading or changing 92 * instead we synchronize on xattr_sem when reading or changing
93 * EAs. 93 * EAs.
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4c82219b0fa..01654b218e4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -219,6 +219,7 @@ extern int dir_notify_enable;
219#include <linux/prio_tree.h> 219#include <linux/prio_tree.h>
220#include <linux/init.h> 220#include <linux/init.h>
221#include <linux/sched.h> 221#include <linux/sched.h>
222#include <linux/mutex.h>
222 223
223#include <asm/atomic.h> 224#include <asm/atomic.h>
224#include <asm/semaphore.h> 225#include <asm/semaphore.h>
@@ -484,7 +485,7 @@ struct inode {
484 unsigned long i_blocks; 485 unsigned long i_blocks;
485 unsigned short i_bytes; 486 unsigned short i_bytes;
486 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 487 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
487 struct semaphore i_sem; 488 struct mutex i_mutex;
488 struct rw_semaphore i_alloc_sem; 489 struct rw_semaphore i_alloc_sem;
489 struct inode_operations *i_op; 490 struct inode_operations *i_op;
490 struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 491 struct file_operations *i_fop; /* former ->i_op->default_file_ops */
@@ -1191,7 +1192,7 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc);
1191 * directory. The name should be stored in the @name (with the 1192 * directory. The name should be stored in the @name (with the
1192 * understanding that it is already pointing to a a %NAME_MAX+1 sized 1193 * understanding that it is already pointing to a a %NAME_MAX+1 sized
1193 * buffer. get_name() should return %0 on success, a negative error code 1194 * buffer. get_name() should return %0 on success, a negative error code
1194 * or error. @get_name will be called without @parent->i_sem held. 1195 * or error. @get_name will be called without @parent->i_mutex held.
1195 * 1196 *
1196 * get_parent: 1197 * get_parent:
1197 * @get_parent should find the parent directory for the given @child which 1198 * @get_parent should find the parent directory for the given @child which
@@ -1213,7 +1214,7 @@ int sync_inode(struct inode *inode, struct writeback_control *wbc);
1213 * nfsd_find_fh_dentry() in either the @obj or @parent parameters. 1214 * nfsd_find_fh_dentry() in either the @obj or @parent parameters.
1214 * 1215 *
1215 * Locking rules: 1216 * Locking rules:
1216 * get_parent is called with child->d_inode->i_sem down 1217 * get_parent is called with child->d_inode->i_mutex down
1217 * get_name is not (which is possibly inconsistent) 1218 * get_name is not (which is possibly inconsistent)
1218 */ 1219 */
1219 1220
diff --git a/include/linux/jffs2_fs_i.h b/include/linux/jffs2_fs_i.h
index ef85ab56302..ad565bf9dcc 100644
--- a/include/linux/jffs2_fs_i.h
+++ b/include/linux/jffs2_fs_i.h
@@ -8,11 +8,11 @@
8#include <asm/semaphore.h> 8#include <asm/semaphore.h>
9 9
10struct jffs2_inode_info { 10struct jffs2_inode_info {
11 /* We need an internal semaphore similar to inode->i_sem. 11 /* We need an internal mutex similar to inode->i_mutex.
12 Unfortunately, we can't used the existing one, because 12 Unfortunately, we can't used the existing one, because
13 either the GC would deadlock, or we'd have to release it 13 either the GC would deadlock, or we'd have to release it
14 before letting GC proceed. Or we'd have to put ugliness 14 before letting GC proceed. Or we'd have to put ugliness
15 into the GC code so it didn't attempt to obtain the i_sem 15 into the GC code so it didn't attempt to obtain the i_mutex
16 for the inode(s) which are already locked */ 16 for the inode(s) which are already locked */
17 struct semaphore sem; 17 struct semaphore sem;
18 18
diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
index bb842ea4103..0798b7781a6 100644
--- a/include/linux/nfsd/nfsfh.h
+++ b/include/linux/nfsd/nfsfh.h
@@ -294,7 +294,7 @@ fill_post_wcc(struct svc_fh *fhp)
294/* 294/*
295 * Lock a file handle/inode 295 * Lock a file handle/inode
296 * NOTE: both fh_lock and fh_unlock are done "by hand" in 296 * NOTE: both fh_lock and fh_unlock are done "by hand" in
297 * vfs.c:nfsd_rename as it needs to grab 2 i_sem's at once 297 * vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once
298 * so, any changes here should be reflected there. 298 * so, any changes here should be reflected there.
299 */ 299 */
300static inline void 300static inline void
@@ -317,7 +317,7 @@ fh_lock(struct svc_fh *fhp)
317 } 317 }
318 318
319 inode = dentry->d_inode; 319 inode = dentry->d_inode;
320 down(&inode->i_sem); 320 mutex_lock(&inode->i_mutex);
321 fill_pre_wcc(fhp); 321 fill_pre_wcc(fhp);
322 fhp->fh_locked = 1; 322 fhp->fh_locked = 1;
323} 323}
@@ -333,7 +333,7 @@ fh_unlock(struct svc_fh *fhp)
333 333
334 if (fhp->fh_locked) { 334 if (fhp->fh_locked) {
335 fill_post_wcc(fhp); 335 fill_post_wcc(fhp);
336 up(&fhp->fh_dentry->d_inode->i_sem); 336 mutex_unlock(&fhp->fh_dentry->d_inode->i_mutex);
337 fhp->fh_locked = 0; 337 fhp->fh_locked = 0;
338 } 338 }
339} 339}
diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
index 1767073df26..b12e59c7575 100644
--- a/include/linux/pipe_fs_i.h
+++ b/include/linux/pipe_fs_i.h
@@ -37,7 +37,7 @@ struct pipe_inode_info {
37 memory allocation, whereas PIPE_BUF makes atomicity guarantees. */ 37 memory allocation, whereas PIPE_BUF makes atomicity guarantees. */
38#define PIPE_SIZE PAGE_SIZE 38#define PIPE_SIZE PAGE_SIZE
39 39
40#define PIPE_SEM(inode) (&(inode).i_sem) 40#define PIPE_MUTEX(inode) (&(inode).i_mutex)
41#define PIPE_WAIT(inode) (&(inode).i_pipe->wait) 41#define PIPE_WAIT(inode) (&(inode).i_pipe->wait)
42#define PIPE_READERS(inode) ((inode).i_pipe->readers) 42#define PIPE_READERS(inode) ((inode).i_pipe->readers)
43#define PIPE_WRITERS(inode) ((inode).i_pipe->writers) 43#define PIPE_WRITERS(inode) ((inode).i_pipe->writers)
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 001ab82df05..e276c5ba2bb 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -1857,7 +1857,7 @@ void padd_item(char *item, int total_length, int length);
1857#define GET_BLOCK_CREATE 1 /* add anything you need to find block */ 1857#define GET_BLOCK_CREATE 1 /* add anything you need to find block */
1858#define GET_BLOCK_NO_HOLE 2 /* return -ENOENT for file holes */ 1858#define GET_BLOCK_NO_HOLE 2 /* return -ENOENT for file holes */
1859#define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */ 1859#define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */
1860#define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */ 1860#define GET_BLOCK_NO_IMUX 8 /* i_mutex is not held, don't preallocate */
1861#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */ 1861#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */
1862 1862
1863int restart_transaction(struct reiserfs_transaction_handle *th, 1863int restart_transaction(struct reiserfs_transaction_handle *th,
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index c8943b53d8e..a8aa6152eea 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -660,7 +660,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
660 if (fd < 0) 660 if (fd < 0)
661 goto out_putname; 661 goto out_putname;
662 662
663 down(&mqueue_mnt->mnt_root->d_inode->i_sem); 663 mutex_lock(&mqueue_mnt->mnt_root->d_inode->i_mutex);
664 dentry = lookup_one_len(name, mqueue_mnt->mnt_root, strlen(name)); 664 dentry = lookup_one_len(name, mqueue_mnt->mnt_root, strlen(name));
665 if (IS_ERR(dentry)) { 665 if (IS_ERR(dentry)) {
666 error = PTR_ERR(dentry); 666 error = PTR_ERR(dentry);
@@ -697,7 +697,7 @@ out_putfd:
697out_err: 697out_err:
698 fd = error; 698 fd = error;
699out_upsem: 699out_upsem:
700 up(&mqueue_mnt->mnt_root->d_inode->i_sem); 700 mutex_unlock(&mqueue_mnt->mnt_root->d_inode->i_mutex);
701out_putname: 701out_putname:
702 putname(name); 702 putname(name);
703 return fd; 703 return fd;
@@ -714,7 +714,7 @@ asmlinkage long sys_mq_unlink(const char __user *u_name)
714 if (IS_ERR(name)) 714 if (IS_ERR(name))
715 return PTR_ERR(name); 715 return PTR_ERR(name);
716 716
717 down(&mqueue_mnt->mnt_root->d_inode->i_sem); 717 mutex_lock(&mqueue_mnt->mnt_root->d_inode->i_mutex);
718 dentry = lookup_one_len(name, mqueue_mnt->mnt_root, strlen(name)); 718 dentry = lookup_one_len(name, mqueue_mnt->mnt_root, strlen(name));
719 if (IS_ERR(dentry)) { 719 if (IS_ERR(dentry)) {
720 err = PTR_ERR(dentry); 720 err = PTR_ERR(dentry);
@@ -735,7 +735,7 @@ out_err:
735 dput(dentry); 735 dput(dentry);
736 736
737out_unlock: 737out_unlock:
738 up(&mqueue_mnt->mnt_root->d_inode->i_sem); 738 mutex_unlock(&mqueue_mnt->mnt_root->d_inode->i_mutex);
739 putname(name); 739 putname(name);
740 if (inode) 740 if (inode)
741 iput(inode); 741 iput(inode);
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index eab64e23bca..2a75e44e1a4 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1513,7 +1513,7 @@ static int cpuset_add_file(struct dentry *dir, const struct cftype *cft)
1513 struct dentry *dentry; 1513 struct dentry *dentry;
1514 int error; 1514 int error;
1515 1515
1516 down(&dir->d_inode->i_sem); 1516 mutex_lock(&dir->d_inode->i_mutex);
1517 dentry = cpuset_get_dentry(dir, cft->name); 1517 dentry = cpuset_get_dentry(dir, cft->name);
1518 if (!IS_ERR(dentry)) { 1518 if (!IS_ERR(dentry)) {
1519 error = cpuset_create_file(dentry, 0644 | S_IFREG); 1519 error = cpuset_create_file(dentry, 0644 | S_IFREG);
@@ -1522,7 +1522,7 @@ static int cpuset_add_file(struct dentry *dir, const struct cftype *cft)
1522 dput(dentry); 1522 dput(dentry);
1523 } else 1523 } else
1524 error = PTR_ERR(dentry); 1524 error = PTR_ERR(dentry);
1525 up(&dir->d_inode->i_sem); 1525 mutex_unlock(&dir->d_inode->i_mutex);
1526 return error; 1526 return error;
1527} 1527}
1528 1528
@@ -1793,7 +1793,7 @@ static long cpuset_create(struct cpuset *parent, const char *name, int mode)
1793 1793
1794 /* 1794 /*
1795 * Release manage_sem before cpuset_populate_dir() because it 1795 * Release manage_sem before cpuset_populate_dir() because it
1796 * will down() this new directory's i_sem and if we race with 1796 * will down() this new directory's i_mutex and if we race with
1797 * another mkdir, we might deadlock. 1797 * another mkdir, we might deadlock.
1798 */ 1798 */
1799 up(&manage_sem); 1799 up(&manage_sem);
@@ -1812,7 +1812,7 @@ static int cpuset_mkdir(struct inode *dir, struct dentry *dentry, int mode)
1812{ 1812{
1813 struct cpuset *c_parent = dentry->d_parent->d_fsdata; 1813 struct cpuset *c_parent = dentry->d_parent->d_fsdata;
1814 1814
1815 /* the vfs holds inode->i_sem already */ 1815 /* the vfs holds inode->i_mutex already */
1816 return cpuset_create(c_parent, dentry->d_name.name, mode | S_IFDIR); 1816 return cpuset_create(c_parent, dentry->d_name.name, mode | S_IFDIR);
1817} 1817}
1818 1818
@@ -1823,7 +1823,7 @@ static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)
1823 struct cpuset *parent; 1823 struct cpuset *parent;
1824 char *pathbuf = NULL; 1824 char *pathbuf = NULL;
1825 1825
1826 /* the vfs holds both inode->i_sem already */ 1826 /* the vfs holds both inode->i_mutex already */
1827 1827
1828 down(&manage_sem); 1828 down(&manage_sem);
1829 cpuset_update_task_memory_state(); 1829 cpuset_update_task_memory_state();
diff --git a/mm/filemap.c b/mm/filemap.c
index 478f4c74cc3..5fca2737c97 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -61,7 +61,7 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
61 * ->swap_lock (exclusive_swap_page, others) 61 * ->swap_lock (exclusive_swap_page, others)
62 * ->mapping->tree_lock 62 * ->mapping->tree_lock
63 * 63 *
64 * ->i_sem 64 * ->i_mutex
65 * ->i_mmap_lock (truncate->unmap_mapping_range) 65 * ->i_mmap_lock (truncate->unmap_mapping_range)
66 * 66 *
67 * ->mmap_sem 67 * ->mmap_sem
@@ -73,9 +73,9 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
73 * ->lock_page (access_process_vm) 73 * ->lock_page (access_process_vm)
74 * 74 *
75 * ->mmap_sem 75 * ->mmap_sem
76 * ->i_sem (msync) 76 * ->i_mutex (msync)
77 * 77 *
78 * ->i_sem 78 * ->i_mutex
79 * ->i_alloc_sem (various) 79 * ->i_alloc_sem (various)
80 * 80 *
81 * ->inode_lock 81 * ->inode_lock
@@ -276,7 +276,7 @@ static int wait_on_page_writeback_range(struct address_space *mapping,
276 * integrity" operation. It waits upon in-flight writeout before starting and 276 * integrity" operation. It waits upon in-flight writeout before starting and
277 * waiting upon new writeout. If there was an IO error, return it. 277 * waiting upon new writeout. If there was an IO error, return it.
278 * 278 *
279 * We need to re-take i_sem during the generic_osync_inode list walk because 279 * We need to re-take i_mutex during the generic_osync_inode list walk because
280 * it is otherwise livelockable. 280 * it is otherwise livelockable.
281 */ 281 */
282int sync_page_range(struct inode *inode, struct address_space *mapping, 282int sync_page_range(struct inode *inode, struct address_space *mapping,
@@ -290,9 +290,9 @@ int sync_page_range(struct inode *inode, struct address_space *mapping,
290 return 0; 290 return 0;
291 ret = filemap_fdatawrite_range(mapping, pos, pos + count - 1); 291 ret = filemap_fdatawrite_range(mapping, pos, pos + count - 1);
292 if (ret == 0) { 292 if (ret == 0) {
293 down(&inode->i_sem); 293 mutex_lock(&inode->i_mutex);
294 ret = generic_osync_inode(inode, mapping, OSYNC_METADATA); 294 ret = generic_osync_inode(inode, mapping, OSYNC_METADATA);
295 up(&inode->i_sem); 295 mutex_unlock(&inode->i_mutex);
296 } 296 }
297 if (ret == 0) 297 if (ret == 0)
298 ret = wait_on_page_writeback_range(mapping, start, end); 298 ret = wait_on_page_writeback_range(mapping, start, end);
@@ -301,7 +301,7 @@ int sync_page_range(struct inode *inode, struct address_space *mapping,
301EXPORT_SYMBOL(sync_page_range); 301EXPORT_SYMBOL(sync_page_range);
302 302
303/* 303/*
304 * Note: Holding i_sem across sync_page_range_nolock is not a good idea 304 * Note: Holding i_mutex across sync_page_range_nolock is not a good idea
305 * as it forces O_SYNC writers to different parts of the same file 305 * as it forces O_SYNC writers to different parts of the same file
306 * to be serialised right until io completion. 306 * to be serialised right until io completion.
307 */ 307 */
@@ -1892,7 +1892,7 @@ generic_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
1892 /* 1892 /*
1893 * Sync the fs metadata but not the minor inode changes and 1893 * Sync the fs metadata but not the minor inode changes and
1894 * of course not the data as we did direct DMA for the IO. 1894 * of course not the data as we did direct DMA for the IO.
1895 * i_sem is held, which protects generic_osync_inode() from 1895 * i_mutex is held, which protects generic_osync_inode() from
1896 * livelocking. 1896 * livelocking.
1897 */ 1897 */
1898 if (written >= 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { 1898 if (written >= 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
@@ -2195,10 +2195,10 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const char __user *buf,
2195 2195
2196 BUG_ON(iocb->ki_pos != pos); 2196 BUG_ON(iocb->ki_pos != pos);
2197 2197
2198 down(&inode->i_sem); 2198 mutex_lock(&inode->i_mutex);
2199 ret = __generic_file_aio_write_nolock(iocb, &local_iov, 1, 2199 ret = __generic_file_aio_write_nolock(iocb, &local_iov, 1,
2200 &iocb->ki_pos); 2200 &iocb->ki_pos);
2201 up(&inode->i_sem); 2201 mutex_unlock(&inode->i_mutex);
2202 2202
2203 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { 2203 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2204 ssize_t err; 2204 ssize_t err;
@@ -2220,9 +2220,9 @@ ssize_t generic_file_write(struct file *file, const char __user *buf,
2220 struct iovec local_iov = { .iov_base = (void __user *)buf, 2220 struct iovec local_iov = { .iov_base = (void __user *)buf,
2221 .iov_len = count }; 2221 .iov_len = count };
2222 2222
2223 down(&inode->i_sem); 2223 mutex_lock(&inode->i_mutex);
2224 ret = __generic_file_write_nolock(file, &local_iov, 1, ppos); 2224 ret = __generic_file_write_nolock(file, &local_iov, 1, ppos);
2225 up(&inode->i_sem); 2225 mutex_unlock(&inode->i_mutex);
2226 2226
2227 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { 2227 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2228 ssize_t err; 2228 ssize_t err;
@@ -2256,9 +2256,9 @@ ssize_t generic_file_writev(struct file *file, const struct iovec *iov,
2256 struct inode *inode = mapping->host; 2256 struct inode *inode = mapping->host;
2257 ssize_t ret; 2257 ssize_t ret;
2258 2258
2259 down(&inode->i_sem); 2259 mutex_lock(&inode->i_mutex);
2260 ret = __generic_file_write_nolock(file, iov, nr_segs, ppos); 2260 ret = __generic_file_write_nolock(file, iov, nr_segs, ppos);
2261 up(&inode->i_sem); 2261 mutex_unlock(&inode->i_mutex);
2262 2262
2263 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { 2263 if (ret > 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) {
2264 int err; 2264 int err;
@@ -2272,7 +2272,7 @@ ssize_t generic_file_writev(struct file *file, const struct iovec *iov,
2272EXPORT_SYMBOL(generic_file_writev); 2272EXPORT_SYMBOL(generic_file_writev);
2273 2273
2274/* 2274/*
2275 * Called under i_sem for writes to S_ISREG files. Returns -EIO if something 2275 * Called under i_mutex for writes to S_ISREG files. Returns -EIO if something
2276 * went wrong during pagecache shootdown. 2276 * went wrong during pagecache shootdown.
2277 */ 2277 */
2278static ssize_t 2278static ssize_t
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c
index 9cf687e4a29..e2b34e95913 100644
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -338,7 +338,7 @@ __xip_file_write(struct file *filp, const char __user *buf,
338 *ppos = pos; 338 *ppos = pos;
339 /* 339 /*
340 * No need to use i_size_read() here, the i_size 340 * No need to use i_size_read() here, the i_size
341 * cannot change under us because we hold i_sem. 341 * cannot change under us because we hold i_mutex.
342 */ 342 */
343 if (pos > inode->i_size) { 343 if (pos > inode->i_size) {
344 i_size_write(inode, pos); 344 i_size_write(inode, pos);
@@ -358,7 +358,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len,
358 loff_t pos; 358 loff_t pos;
359 ssize_t ret; 359 ssize_t ret;
360 360
361 down(&inode->i_sem); 361 mutex_lock(&inode->i_mutex);
362 362
363 if (!access_ok(VERIFY_READ, buf, len)) { 363 if (!access_ok(VERIFY_READ, buf, len)) {
364 ret=-EFAULT; 364 ret=-EFAULT;
@@ -390,7 +390,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len,
390 out_backing: 390 out_backing:
391 current->backing_dev_info = NULL; 391 current->backing_dev_info = NULL;
392 out_up: 392 out_up:
393 up(&inode->i_sem); 393 mutex_unlock(&inode->i_mutex);
394 return ret; 394 return ret;
395} 395}
396EXPORT_SYMBOL_GPL(xip_file_write); 396EXPORT_SYMBOL_GPL(xip_file_write);
diff --git a/mm/memory.c b/mm/memory.c
index 3944fec3801..7a11ddd5060 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1784,13 +1784,13 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
1784 if (!inode->i_op || !inode->i_op->truncate_range) 1784 if (!inode->i_op || !inode->i_op->truncate_range)
1785 return -ENOSYS; 1785 return -ENOSYS;
1786 1786
1787 down(&inode->i_sem); 1787 mutex_lock(&inode->i_mutex);
1788 down_write(&inode->i_alloc_sem); 1788 down_write(&inode->i_alloc_sem);
1789 unmap_mapping_range(mapping, offset, (end - offset), 1); 1789 unmap_mapping_range(mapping, offset, (end - offset), 1);
1790 truncate_inode_pages_range(mapping, offset, end); 1790 truncate_inode_pages_range(mapping, offset, end);
1791 inode->i_op->truncate_range(inode, offset, end); 1791 inode->i_op->truncate_range(inode, offset, end);
1792 up_write(&inode->i_alloc_sem); 1792 up_write(&inode->i_alloc_sem);
1793 up(&inode->i_sem); 1793 mutex_unlock(&inode->i_mutex);
1794 1794
1795 return 0; 1795 return 0;
1796} 1796}
diff --git a/mm/msync.c b/mm/msync.c
index 1b5b6f662dc..3563a56e1a5 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -137,7 +137,7 @@ static int msync_interval(struct vm_area_struct *vma,
137 ret = filemap_fdatawrite(mapping); 137 ret = filemap_fdatawrite(mapping);
138 if (file->f_op && file->f_op->fsync) { 138 if (file->f_op && file->f_op->fsync) {
139 /* 139 /*
140 * We don't take i_sem here because mmap_sem 140 * We don't take i_mutex here because mmap_sem
141 * is already held. 141 * is already held.
142 */ 142 */
143 err = file->f_op->fsync(file,file->f_dentry,1); 143 err = file->f_op->fsync(file,file->f_dentry,1);
diff --git a/mm/rmap.c b/mm/rmap.c
index 66ec43053a4..dfbb89f99a1 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -20,13 +20,13 @@
20/* 20/*
21 * Lock ordering in mm: 21 * Lock ordering in mm:
22 * 22 *
23 * inode->i_sem (while writing or truncating, not reading or faulting) 23 * inode->i_mutex (while writing or truncating, not reading or faulting)
24 * inode->i_alloc_sem 24 * inode->i_alloc_sem
25 * 25 *
26 * When a page fault occurs in writing from user to file, down_read 26 * When a page fault occurs in writing from user to file, down_read
27 * of mmap_sem nests within i_sem; in sys_msync, i_sem nests within 27 * of mmap_sem nests within i_mutex; in sys_msync, i_mutex nests within
28 * down_read of mmap_sem; i_sem and down_write of mmap_sem are never 28 * down_read of mmap_sem; i_mutex and down_write of mmap_sem are never
29 * taken together; in truncation, i_sem is taken outermost. 29 * taken together; in truncation, i_mutex is taken outermost.
30 * 30 *
31 * mm->mmap_sem 31 * mm->mmap_sem
32 * page->flags PG_locked (lock_page) 32 * page->flags PG_locked (lock_page)
diff --git a/mm/shmem.c b/mm/shmem.c
index a1f2f02af72..343b3c0937e 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1370,7 +1370,7 @@ shmem_file_write(struct file *file, const char __user *buf, size_t count, loff_t
1370 if (!access_ok(VERIFY_READ, buf, count)) 1370 if (!access_ok(VERIFY_READ, buf, count))
1371 return -EFAULT; 1371 return -EFAULT;
1372 1372
1373 down(&inode->i_sem); 1373 mutex_lock(&inode->i_mutex);
1374 1374
1375 pos = *ppos; 1375 pos = *ppos;
1376 written = 0; 1376 written = 0;
@@ -1455,7 +1455,7 @@ shmem_file_write(struct file *file, const char __user *buf, size_t count, loff_t
1455 if (written) 1455 if (written)
1456 err = written; 1456 err = written;
1457out: 1457out:
1458 up(&inode->i_sem); 1458 mutex_unlock(&inode->i_mutex);
1459 return err; 1459 return err;
1460} 1460}
1461 1461
@@ -1491,7 +1491,7 @@ static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_
1491 1491
1492 /* 1492 /*
1493 * We must evaluate after, since reads (unlike writes) 1493 * We must evaluate after, since reads (unlike writes)
1494 * are called without i_sem protection against truncate 1494 * are called without i_mutex protection against truncate
1495 */ 1495 */
1496 nr = PAGE_CACHE_SIZE; 1496 nr = PAGE_CACHE_SIZE;
1497 i_size = i_size_read(inode); 1497 i_size = i_size_read(inode);
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 80f948a2028..6544565a7c0 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1187,9 +1187,9 @@ asmlinkage long sys_swapoff(const char __user * specialfile)
1187 set_blocksize(bdev, p->old_block_size); 1187 set_blocksize(bdev, p->old_block_size);
1188 bd_release(bdev); 1188 bd_release(bdev);
1189 } else { 1189 } else {
1190 down(&inode->i_sem); 1190 mutex_lock(&inode->i_mutex);
1191 inode->i_flags &= ~S_SWAPFILE; 1191 inode->i_flags &= ~S_SWAPFILE;
1192 up(&inode->i_sem); 1192 mutex_unlock(&inode->i_mutex);
1193 } 1193 }
1194 filp_close(swap_file, NULL); 1194 filp_close(swap_file, NULL);
1195 err = 0; 1195 err = 0;
@@ -1406,7 +1406,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
1406 p->bdev = bdev; 1406 p->bdev = bdev;
1407 } else if (S_ISREG(inode->i_mode)) { 1407 } else if (S_ISREG(inode->i_mode)) {
1408 p->bdev = inode->i_sb->s_bdev; 1408 p->bdev = inode->i_sb->s_bdev;
1409 down(&inode->i_sem); 1409 mutex_lock(&inode->i_mutex);
1410 did_down = 1; 1410 did_down = 1;
1411 if (IS_SWAPFILE(inode)) { 1411 if (IS_SWAPFILE(inode)) {
1412 error = -EBUSY; 1412 error = -EBUSY;
@@ -1596,7 +1596,7 @@ out:
1596 if (did_down) { 1596 if (did_down) {
1597 if (!error) 1597 if (!error)
1598 inode->i_flags |= S_SWAPFILE; 1598 inode->i_flags |= S_SWAPFILE;
1599 up(&inode->i_sem); 1599 mutex_unlock(&inode->i_mutex);
1600 } 1600 }
1601 return error; 1601 return error;
1602} 1602}
diff --git a/mm/truncate.c b/mm/truncate.c
index b1a463d0fe7..6cb3fff25f6 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -196,7 +196,7 @@ EXPORT_SYMBOL(truncate_inode_pages_range);
196 * @mapping: mapping to truncate 196 * @mapping: mapping to truncate
197 * @lstart: offset from which to truncate 197 * @lstart: offset from which to truncate
198 * 198 *
199 * Called under (and serialised by) inode->i_sem. 199 * Called under (and serialised by) inode->i_mutex.
200 */ 200 */
201void truncate_inode_pages(struct address_space *mapping, loff_t lstart) 201void truncate_inode_pages(struct address_space *mapping, loff_t lstart)
202{ 202{
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index e14c1cae746..9764c80ab0b 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -69,13 +69,13 @@ rpc_timeout_upcall_queue(void *data)
69 struct rpc_inode *rpci = (struct rpc_inode *)data; 69 struct rpc_inode *rpci = (struct rpc_inode *)data;
70 struct inode *inode = &rpci->vfs_inode; 70 struct inode *inode = &rpci->vfs_inode;
71 71
72 down(&inode->i_sem); 72 mutex_lock(&inode->i_mutex);
73 if (rpci->ops == NULL) 73 if (rpci->ops == NULL)
74 goto out; 74 goto out;
75 if (rpci->nreaders == 0 && !list_empty(&rpci->pipe)) 75 if (rpci->nreaders == 0 && !list_empty(&rpci->pipe))
76 __rpc_purge_upcall(inode, -ETIMEDOUT); 76 __rpc_purge_upcall(inode, -ETIMEDOUT);
77out: 77out:
78 up(&inode->i_sem); 78 mutex_unlock(&inode->i_mutex);
79} 79}
80 80
81int 81int
@@ -84,7 +84,7 @@ rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
84 struct rpc_inode *rpci = RPC_I(inode); 84 struct rpc_inode *rpci = RPC_I(inode);
85 int res = -EPIPE; 85 int res = -EPIPE;
86 86
87 down(&inode->i_sem); 87 mutex_lock(&inode->i_mutex);
88 if (rpci->ops == NULL) 88 if (rpci->ops == NULL)
89 goto out; 89 goto out;
90 if (rpci->nreaders) { 90 if (rpci->nreaders) {
@@ -100,7 +100,7 @@ rpc_queue_upcall(struct inode *inode, struct rpc_pipe_msg *msg)
100 res = 0; 100 res = 0;
101 } 101 }
102out: 102out:
103 up(&inode->i_sem); 103 mutex_unlock(&inode->i_mutex);
104 wake_up(&rpci->waitq); 104 wake_up(&rpci->waitq);
105 return res; 105 return res;
106} 106}
@@ -116,7 +116,7 @@ rpc_close_pipes(struct inode *inode)
116{ 116{
117 struct rpc_inode *rpci = RPC_I(inode); 117 struct rpc_inode *rpci = RPC_I(inode);
118 118
119 down(&inode->i_sem); 119 mutex_lock(&inode->i_mutex);
120 if (rpci->ops != NULL) { 120 if (rpci->ops != NULL) {
121 rpci->nreaders = 0; 121 rpci->nreaders = 0;
122 __rpc_purge_list(rpci, &rpci->in_upcall, -EPIPE); 122 __rpc_purge_list(rpci, &rpci->in_upcall, -EPIPE);
@@ -127,7 +127,7 @@ rpc_close_pipes(struct inode *inode)
127 rpci->ops = NULL; 127 rpci->ops = NULL;
128 } 128 }
129 rpc_inode_setowner(inode, NULL); 129 rpc_inode_setowner(inode, NULL);
130 up(&inode->i_sem); 130 mutex_unlock(&inode->i_mutex);
131 cancel_delayed_work(&rpci->queue_timeout); 131 cancel_delayed_work(&rpci->queue_timeout);
132 flush_scheduled_work(); 132 flush_scheduled_work();
133} 133}
@@ -154,7 +154,7 @@ rpc_pipe_open(struct inode *inode, struct file *filp)
154 struct rpc_inode *rpci = RPC_I(inode); 154 struct rpc_inode *rpci = RPC_I(inode);
155 int res = -ENXIO; 155 int res = -ENXIO;
156 156
157 down(&inode->i_sem); 157 mutex_lock(&inode->i_mutex);
158 if (rpci->ops != NULL) { 158 if (rpci->ops != NULL) {
159 if (filp->f_mode & FMODE_READ) 159 if (filp->f_mode & FMODE_READ)
160 rpci->nreaders ++; 160 rpci->nreaders ++;
@@ -162,7 +162,7 @@ rpc_pipe_open(struct inode *inode, struct file *filp)
162 rpci->nwriters ++; 162 rpci->nwriters ++;
163 res = 0; 163 res = 0;
164 } 164 }
165 up(&inode->i_sem); 165 mutex_unlock(&inode->i_mutex);
166 return res; 166 return res;
167} 167}
168 168
@@ -172,7 +172,7 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
172 struct rpc_inode *rpci = RPC_I(inode); 172 struct rpc_inode *rpci = RPC_I(inode);
173 struct rpc_pipe_msg *msg; 173 struct rpc_pipe_msg *msg;
174 174
175 down(&inode->i_sem); 175 mutex_lock(&inode->i_mutex);
176 if (rpci->ops == NULL) 176 if (rpci->ops == NULL)
177 goto out; 177 goto out;
178 msg = (struct rpc_pipe_msg *)filp->private_data; 178 msg = (struct rpc_pipe_msg *)filp->private_data;
@@ -190,7 +190,7 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
190 if (rpci->ops->release_pipe) 190 if (rpci->ops->release_pipe)
191 rpci->ops->release_pipe(inode); 191 rpci->ops->release_pipe(inode);
192out: 192out:
193 up(&inode->i_sem); 193 mutex_unlock(&inode->i_mutex);
194 return 0; 194 return 0;
195} 195}
196 196
@@ -202,7 +202,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
202 struct rpc_pipe_msg *msg; 202 struct rpc_pipe_msg *msg;
203 int res = 0; 203 int res = 0;
204 204
205 down(&inode->i_sem); 205 mutex_lock(&inode->i_mutex);
206 if (rpci->ops == NULL) { 206 if (rpci->ops == NULL) {
207 res = -EPIPE; 207 res = -EPIPE;
208 goto out_unlock; 208 goto out_unlock;
@@ -229,7 +229,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
229 rpci->ops->destroy_msg(msg); 229 rpci->ops->destroy_msg(msg);
230 } 230 }
231out_unlock: 231out_unlock:
232 up(&inode->i_sem); 232 mutex_unlock(&inode->i_mutex);
233 return res; 233 return res;
234} 234}
235 235
@@ -240,11 +240,11 @@ rpc_pipe_write(struct file *filp, const char __user *buf, size_t len, loff_t *of
240 struct rpc_inode *rpci = RPC_I(inode); 240 struct rpc_inode *rpci = RPC_I(inode);
241 int res; 241 int res;
242 242
243 down(&inode->i_sem); 243 mutex_lock(&inode->i_mutex);
244 res = -EPIPE; 244 res = -EPIPE;
245 if (rpci->ops != NULL) 245 if (rpci->ops != NULL)
246 res = rpci->ops->downcall(filp, buf, len); 246 res = rpci->ops->downcall(filp, buf, len);
247 up(&inode->i_sem); 247 mutex_unlock(&inode->i_mutex);
248 return res; 248 return res;
249} 249}
250 250
@@ -322,7 +322,7 @@ rpc_info_open(struct inode *inode, struct file *file)
322 322
323 if (!ret) { 323 if (!ret) {
324 struct seq_file *m = file->private_data; 324 struct seq_file *m = file->private_data;
325 down(&inode->i_sem); 325 mutex_lock(&inode->i_mutex);
326 clnt = RPC_I(inode)->private; 326 clnt = RPC_I(inode)->private;
327 if (clnt) { 327 if (clnt) {
328 atomic_inc(&clnt->cl_users); 328 atomic_inc(&clnt->cl_users);
@@ -331,7 +331,7 @@ rpc_info_open(struct inode *inode, struct file *file)
331 single_release(inode, file); 331 single_release(inode, file);
332 ret = -EINVAL; 332 ret = -EINVAL;
333 } 333 }
334 up(&inode->i_sem); 334 mutex_unlock(&inode->i_mutex);
335 } 335 }
336 return ret; 336 return ret;
337} 337}
@@ -491,7 +491,7 @@ rpc_depopulate(struct dentry *parent)
491 struct dentry *dentry, *dvec[10]; 491 struct dentry *dentry, *dvec[10];
492 int n = 0; 492 int n = 0;
493 493
494 down(&dir->i_sem); 494 mutex_lock(&dir->i_mutex);
495repeat: 495repeat:
496 spin_lock(&dcache_lock); 496 spin_lock(&dcache_lock);
497 list_for_each_safe(pos, next, &parent->d_subdirs) { 497 list_for_each_safe(pos, next, &parent->d_subdirs) {
@@ -519,7 +519,7 @@ repeat:
519 } while (n); 519 } while (n);
520 goto repeat; 520 goto repeat;
521 } 521 }
522 up(&dir->i_sem); 522 mutex_unlock(&dir->i_mutex);
523} 523}
524 524
525static int 525static int
@@ -532,7 +532,7 @@ rpc_populate(struct dentry *parent,
532 struct dentry *dentry; 532 struct dentry *dentry;
533 int mode, i; 533 int mode, i;
534 534
535 down(&dir->i_sem); 535 mutex_lock(&dir->i_mutex);
536 for (i = start; i < eof; i++) { 536 for (i = start; i < eof; i++) {
537 dentry = d_alloc_name(parent, files[i].name); 537 dentry = d_alloc_name(parent, files[i].name);
538 if (!dentry) 538 if (!dentry)
@@ -552,10 +552,10 @@ rpc_populate(struct dentry *parent,
552 dir->i_nlink++; 552 dir->i_nlink++;
553 d_add(dentry, inode); 553 d_add(dentry, inode);
554 } 554 }
555 up(&dir->i_sem); 555 mutex_unlock(&dir->i_mutex);
556 return 0; 556 return 0;
557out_bad: 557out_bad:
558 up(&dir->i_sem); 558 mutex_unlock(&dir->i_mutex);
559 printk(KERN_WARNING "%s: %s failed to populate directory %s\n", 559 printk(KERN_WARNING "%s: %s failed to populate directory %s\n",
560 __FILE__, __FUNCTION__, parent->d_name.name); 560 __FILE__, __FUNCTION__, parent->d_name.name);
561 return -ENOMEM; 561 return -ENOMEM;
@@ -609,7 +609,7 @@ rpc_lookup_negative(char *path, struct nameidata *nd)
609 if ((error = rpc_lookup_parent(path, nd)) != 0) 609 if ((error = rpc_lookup_parent(path, nd)) != 0)
610 return ERR_PTR(error); 610 return ERR_PTR(error);
611 dir = nd->dentry->d_inode; 611 dir = nd->dentry->d_inode;
612 down(&dir->i_sem); 612 mutex_lock(&dir->i_mutex);
613 dentry = lookup_hash(nd); 613 dentry = lookup_hash(nd);
614 if (IS_ERR(dentry)) 614 if (IS_ERR(dentry))
615 goto out_err; 615 goto out_err;
@@ -620,7 +620,7 @@ rpc_lookup_negative(char *path, struct nameidata *nd)
620 } 620 }
621 return dentry; 621 return dentry;
622out_err: 622out_err:
623 up(&dir->i_sem); 623 mutex_unlock(&dir->i_mutex);
624 rpc_release_path(nd); 624 rpc_release_path(nd);
625 return dentry; 625 return dentry;
626} 626}
@@ -646,7 +646,7 @@ rpc_mkdir(char *path, struct rpc_clnt *rpc_client)
646 if (error) 646 if (error)
647 goto err_depopulate; 647 goto err_depopulate;
648out: 648out:
649 up(&dir->i_sem); 649 mutex_unlock(&dir->i_mutex);
650 rpc_release_path(&nd); 650 rpc_release_path(&nd);
651 return dentry; 651 return dentry;
652err_depopulate: 652err_depopulate:
@@ -671,7 +671,7 @@ rpc_rmdir(char *path)
671 if ((error = rpc_lookup_parent(path, &nd)) != 0) 671 if ((error = rpc_lookup_parent(path, &nd)) != 0)
672 return error; 672 return error;
673 dir = nd.dentry->d_inode; 673 dir = nd.dentry->d_inode;
674 down(&dir->i_sem); 674 mutex_lock(&dir->i_mutex);
675 dentry = lookup_hash(&nd); 675 dentry = lookup_hash(&nd);
676 if (IS_ERR(dentry)) { 676 if (IS_ERR(dentry)) {
677 error = PTR_ERR(dentry); 677 error = PTR_ERR(dentry);
@@ -681,7 +681,7 @@ rpc_rmdir(char *path)
681 error = __rpc_rmdir(dir, dentry); 681 error = __rpc_rmdir(dir, dentry);
682 dput(dentry); 682 dput(dentry);
683out_release: 683out_release:
684 up(&dir->i_sem); 684 mutex_unlock(&dir->i_mutex);
685 rpc_release_path(&nd); 685 rpc_release_path(&nd);
686 return error; 686 return error;
687} 687}
@@ -710,7 +710,7 @@ rpc_mkpipe(char *path, void *private, struct rpc_pipe_ops *ops, int flags)
710 rpci->ops = ops; 710 rpci->ops = ops;
711 inode_dir_notify(dir, DN_CREATE); 711 inode_dir_notify(dir, DN_CREATE);
712out: 712out:
713 up(&dir->i_sem); 713 mutex_unlock(&dir->i_mutex);
714 rpc_release_path(&nd); 714 rpc_release_path(&nd);
715 return dentry; 715 return dentry;
716err_dput: 716err_dput:
@@ -732,7 +732,7 @@ rpc_unlink(char *path)
732 if ((error = rpc_lookup_parent(path, &nd)) != 0) 732 if ((error = rpc_lookup_parent(path, &nd)) != 0)
733 return error; 733 return error;
734 dir = nd.dentry->d_inode; 734 dir = nd.dentry->d_inode;
735 down(&dir->i_sem); 735 mutex_lock(&dir->i_mutex);
736 dentry = lookup_hash(&nd); 736 dentry = lookup_hash(&nd);
737 if (IS_ERR(dentry)) { 737 if (IS_ERR(dentry)) {
738 error = PTR_ERR(dentry); 738 error = PTR_ERR(dentry);
@@ -746,7 +746,7 @@ rpc_unlink(char *path)
746 dput(dentry); 746 dput(dentry);
747 inode_dir_notify(dir, DN_DELETE); 747 inode_dir_notify(dir, DN_DELETE);
748out_release: 748out_release:
749 up(&dir->i_sem); 749 mutex_unlock(&dir->i_mutex);
750 rpc_release_path(&nd); 750 rpc_release_path(&nd);
751 return error; 751 return error;
752} 752}
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 5f6ae79b8b1..1b5989b1b67 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -784,7 +784,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
784 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); 784 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
785 if (err) 785 if (err)
786 goto out_mknod_dput; 786 goto out_mknod_dput;
787 up(&nd.dentry->d_inode->i_sem); 787 mutex_unlock(&nd.dentry->d_inode->i_mutex);
788 dput(nd.dentry); 788 dput(nd.dentry);
789 nd.dentry = dentry; 789 nd.dentry = dentry;
790 790
@@ -823,7 +823,7 @@ out:
823out_mknod_dput: 823out_mknod_dput:
824 dput(dentry); 824 dput(dentry);
825out_mknod_unlock: 825out_mknod_unlock:
826 up(&nd.dentry->d_inode->i_sem); 826 mutex_unlock(&nd.dentry->d_inode->i_mutex);
827 path_release(&nd); 827 path_release(&nd);
828out_mknod_parent: 828out_mknod_parent:
829 if (err==-EEXIST) 829 if (err==-EEXIST)
diff --git a/security/inode.c b/security/inode.c
index a5964502ae3..0f77b022366 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -172,7 +172,7 @@ static int create_by_name(const char *name, mode_t mode,
172 return -EFAULT; 172 return -EFAULT;
173 } 173 }
174 174
175 down(&parent->d_inode->i_sem); 175 mutex_lock(&parent->d_inode->i_mutex);
176 *dentry = lookup_one_len(name, parent, strlen(name)); 176 *dentry = lookup_one_len(name, parent, strlen(name));
177 if (!IS_ERR(dentry)) { 177 if (!IS_ERR(dentry)) {
178 if ((mode & S_IFMT) == S_IFDIR) 178 if ((mode & S_IFMT) == S_IFDIR)
@@ -181,7 +181,7 @@ static int create_by_name(const char *name, mode_t mode,
181 error = create(parent->d_inode, *dentry, mode); 181 error = create(parent->d_inode, *dentry, mode);
182 } else 182 } else
183 error = PTR_ERR(dentry); 183 error = PTR_ERR(dentry);
184 up(&parent->d_inode->i_sem); 184 mutex_unlock(&parent->d_inode->i_mutex);
185 185
186 return error; 186 return error;
187} 187}
@@ -302,7 +302,7 @@ void securityfs_remove(struct dentry *dentry)
302 if (!parent || !parent->d_inode) 302 if (!parent || !parent->d_inode)
303 return; 303 return;
304 304
305 down(&parent->d_inode->i_sem); 305 mutex_lock(&parent->d_inode->i_mutex);
306 if (positive(dentry)) { 306 if (positive(dentry)) {
307 if (dentry->d_inode) { 307 if (dentry->d_inode) {
308 if (S_ISDIR(dentry->d_inode->i_mode)) 308 if (S_ISDIR(dentry->d_inode->i_mode))
@@ -312,7 +312,7 @@ void securityfs_remove(struct dentry *dentry)
312 dput(dentry); 312 dput(dentry);
313 } 313 }
314 } 314 }
315 up(&parent->d_inode->i_sem); 315 mutex_unlock(&parent->d_inode->i_mutex);
316 simple_release_fs(&mount, &mount_count); 316 simple_release_fs(&mount, &mount_count);
317} 317}
318EXPORT_SYMBOL_GPL(securityfs_remove); 318EXPORT_SYMBOL_GPL(securityfs_remove);
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 16df1246a13..7fd072392c7 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2135,9 +2135,7 @@ static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size
2135 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 2135 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2136 if (substream == NULL) 2136 if (substream == NULL)
2137 return -ENXIO; 2137 return -ENXIO;
2138 up(&file->f_dentry->d_inode->i_sem);
2139 result = snd_pcm_oss_write1(substream, buf, count); 2138 result = snd_pcm_oss_write1(substream, buf, count);
2140 down(&file->f_dentry->d_inode->i_sem);
2141#ifdef OSS_DEBUG 2139#ifdef OSS_DEBUG
2142 printk("pcm_oss: write %li bytes (wrote %li bytes)\n", (long)count, (long)result); 2140 printk("pcm_oss: write %li bytes (wrote %li bytes)\n", (long)count, (long)result);
2143#endif 2141#endif
diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c
index 9ee6c177db0..40b4f679c80 100644
--- a/sound/core/seq/seq_memory.c
+++ b/sound/core/seq/seq_memory.c
@@ -32,10 +32,6 @@
32#include "seq_info.h" 32#include "seq_info.h"
33#include "seq_lock.h" 33#include "seq_lock.h"
34 34
35/* semaphore in struct file record */
36#define semaphore_of(fp) ((fp)->f_dentry->d_inode->i_sem)
37
38
39static inline int snd_seq_pool_available(struct snd_seq_pool *pool) 35static inline int snd_seq_pool_available(struct snd_seq_pool *pool)
40{ 36{
41 return pool->total_elements - atomic_read(&pool->counter); 37 return pool->total_elements - atomic_read(&pool->counter);