Skip to content

Commit 5955102

Browse files
author
Al Viro
committed
wrappers for ->i_mutex access
parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested}, inode_foo(inode) being mutex_foo(&inode->i_mutex). Please, use those for access to ->i_mutex; over the coming cycle ->i_mutex will become rwsem, with ->lookup() done with it held only shared. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 57b8f11 commit 5955102

177 files changed

Lines changed: 908 additions & 883 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/powerpc/platforms/cell/spufs/file.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,9 +1799,9 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int data
17991799
struct inode *inode = file_inode(file);
18001800
int err = filemap_write_and_wait_range(inode->i_mapping, start, end);
18011801
if (!err) {
1802-
mutex_lock(&inode->i_mutex);
1802+
inode_lock(inode);
18031803
err = spufs_mfc_flush(file, NULL);
1804-
mutex_unlock(&inode->i_mutex);
1804+
inode_unlock(inode);
18051805
}
18061806
return err;
18071807
}

‎arch/powerpc/platforms/cell/spufs/inode.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static void spufs_prune_dir(struct dentry *dir)
163163
{
164164
struct dentry *dentry, *tmp;
165165

166-
mutex_lock(&d_inode(dir)->i_mutex);
166+
inode_lock(d_inode(dir));
167167
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
168168
spin_lock(&dentry->d_lock);
169169
if (simple_positive(dentry)) {
@@ -180,7 +180,7 @@ static void spufs_prune_dir(struct dentry *dir)
180180
}
181181
}
182182
shrink_dcache_parent(dir);
183-
mutex_unlock(&d_inode(dir)->i_mutex);
183+
inode_unlock(d_inode(dir));
184184
}
185185

186186
/* Caller must hold parent->i_mutex */
@@ -225,9 +225,9 @@ static int spufs_dir_close(struct inode *inode, struct file *file)
225225
parent = d_inode(dir->d_parent);
226226
ctx = SPUFS_I(d_inode(dir))->i_ctx;
227227

228-
mutex_lock_nested(&parent->i_mutex, I_MUTEX_PARENT);
228+
inode_lock_nested(parent, I_MUTEX_PARENT);
229229
ret = spufs_rmdir(parent, dir);
230-
mutex_unlock(&parent->i_mutex);
230+
inode_unlock(parent);
231231
WARN_ON(ret);
232232

233233
return dcache_dir_close(inode, file);
@@ -270,7 +270,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
270270
inode->i_op = &simple_dir_inode_operations;
271271
inode->i_fop = &simple_dir_operations;
272272

273-
mutex_lock(&inode->i_mutex);
273+
inode_lock(inode);
274274

275275
dget(dentry);
276276
inc_nlink(dir);
@@ -291,7 +291,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
291291
if (ret)
292292
spufs_rmdir(dir, dentry);
293293

294-
mutex_unlock(&inode->i_mutex);
294+
inode_unlock(inode);
295295

296296
return ret;
297297
}

‎arch/s390/hypfs/inode.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void hypfs_remove(struct dentry *dentry)
6767
struct dentry *parent;
6868

6969
parent = dentry->d_parent;
70-
mutex_lock(&d_inode(parent)->i_mutex);
70+
inode_lock(d_inode(parent));
7171
if (simple_positive(dentry)) {
7272
if (d_is_dir(dentry))
7373
simple_rmdir(d_inode(parent), dentry);
@@ -76,7 +76,7 @@ static void hypfs_remove(struct dentry *dentry)
7676
}
7777
d_delete(dentry);
7878
dput(dentry);
79-
mutex_unlock(&d_inode(parent)->i_mutex);
79+
inode_unlock(d_inode(parent));
8080
}
8181

8282
static void hypfs_delete_tree(struct dentry *root)
@@ -331,7 +331,7 @@ static struct dentry *hypfs_create_file(struct dentry *parent, const char *name,
331331
struct dentry *dentry;
332332
struct inode *inode;
333333

334-
mutex_lock(&d_inode(parent)->i_mutex);
334+
inode_lock(d_inode(parent));
335335
dentry = lookup_one_len(name, parent, strlen(name));
336336
if (IS_ERR(dentry)) {
337337
dentry = ERR_PTR(-ENOMEM);
@@ -359,7 +359,7 @@ static struct dentry *hypfs_create_file(struct dentry *parent, const char *name,
359359
d_instantiate(dentry, inode);
360360
dget(dentry);
361361
fail:
362-
mutex_unlock(&d_inode(parent)->i_mutex);
362+
inode_unlock(d_inode(parent));
363363
return dentry;
364364
}
365365

‎block/ioctl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,12 @@ static int blkdev_daxset(struct block_device *bdev, unsigned long argp)
455455
if (arg && !blkdev_dax_capable(bdev))
456456
return -ENOTTY;
457457

458-
mutex_lock(&bdev->bd_inode->i_mutex);
458+
inode_lock(bdev->bd_inode);
459459
if (bdev->bd_map_count == 0)
460460
inode_set_flags(bdev->bd_inode, arg, S_DAX);
461461
else
462462
rc = -EBUSY;
463-
mutex_unlock(&bdev->bd_inode->i_mutex);
463+
inode_unlock(bdev->bd_inode);
464464
return rc;
465465
}
466466
#else

‎drivers/base/devtmpfs.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
215215
newattrs.ia_uid = uid;
216216
newattrs.ia_gid = gid;
217217
newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
218-
mutex_lock(&d_inode(dentry)->i_mutex);
218+
inode_lock(d_inode(dentry));
219219
notify_change(dentry, &newattrs, NULL);
220-
mutex_unlock(&d_inode(dentry)->i_mutex);
220+
inode_unlock(d_inode(dentry));
221221

222222
/* mark as kernel-created inode */
223223
d_inode(dentry)->i_private = &thread;
@@ -244,7 +244,7 @@ static int dev_rmdir(const char *name)
244244
err = -ENOENT;
245245
}
246246
dput(dentry);
247-
mutex_unlock(&d_inode(parent.dentry)->i_mutex);
247+
inode_unlock(d_inode(parent.dentry));
248248
path_put(&parent);
249249
return err;
250250
}
@@ -321,9 +321,9 @@ static int handle_remove(const char *nodename, struct device *dev)
321321
newattrs.ia_mode = stat.mode & ~0777;
322322
newattrs.ia_valid =
323323
ATTR_UID|ATTR_GID|ATTR_MODE;
324-
mutex_lock(&d_inode(dentry)->i_mutex);
324+
inode_lock(d_inode(dentry));
325325
notify_change(dentry, &newattrs, NULL);
326-
mutex_unlock(&d_inode(dentry)->i_mutex);
326+
inode_unlock(d_inode(dentry));
327327
err = vfs_unlink(d_inode(parent.dentry), dentry, NULL);
328328
if (!err || err == -ENOENT)
329329
deleted = 1;
@@ -332,7 +332,7 @@ static int handle_remove(const char *nodename, struct device *dev)
332332
err = -ENOENT;
333333
}
334334
dput(dentry);
335-
mutex_unlock(&d_inode(parent.dentry)->i_mutex);
335+
inode_unlock(d_inode(parent.dentry));
336336

337337
path_put(&parent);
338338
if (deleted && strchr(nodename, '/'))

‎drivers/block/aoe/aoecmd.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,9 +964,9 @@ aoecmd_sleepwork(struct work_struct *work)
964964
ssize = get_capacity(d->gd);
965965
bd = bdget_disk(d->gd, 0);
966966
if (bd) {
967-
mutex_lock(&bd->bd_inode->i_mutex);
967+
inode_lock(bd->bd_inode);
968968
i_size_write(bd->bd_inode, (loff_t)ssize<<9);
969-
mutex_unlock(&bd->bd_inode->i_mutex);
969+
inode_unlock(bd->bd_inode);
970970
bdput(bd);
971971
}
972972
spin_lock_irq(&d->lock);

‎drivers/block/drbd/drbd_debugfs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,12 @@ static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, vo
434434
if (!parent || d_really_is_negative(parent))
435435
goto out;
436436
/* serialize with d_delete() */
437-
mutex_lock(&d_inode(parent)->i_mutex);
437+
inode_lock(d_inode(parent));
438438
/* Make sure the object is still alive */
439439
if (simple_positive(file->f_path.dentry)
440440
&& kref_get_unless_zero(kref))
441441
ret = 0;
442-
mutex_unlock(&d_inode(parent)->i_mutex);
442+
inode_unlock(d_inode(parent));
443443
if (!ret) {
444444
ret = single_open(file, show, data);
445445
if (ret)

‎drivers/char/mem.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
689689
{
690690
loff_t ret;
691691

692-
mutex_lock(&file_inode(file)->i_mutex);
692+
inode_lock(file_inode(file));
693693
switch (orig) {
694694
case SEEK_CUR:
695695
offset += file->f_pos;
@@ -706,7 +706,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
706706
default:
707707
ret = -EINVAL;
708708
}
709-
mutex_unlock(&file_inode(file)->i_mutex);
709+
inode_unlock(file_inode(file));
710710
return ret;
711711
}
712712

‎drivers/char/ps3flash.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ static int ps3flash_fsync(struct file *file, loff_t start, loff_t end, int datas
290290
{
291291
struct inode *inode = file_inode(file);
292292
int err;
293-
mutex_lock(&inode->i_mutex);
293+
inode_lock(inode);
294294
err = ps3flash_writeback(ps3flash_dev);
295-
mutex_unlock(&inode->i_mutex);
295+
inode_unlock(inode);
296296
return err;
297297
}
298298

‎drivers/infiniband/hw/qib/qib_fs.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ static int create_file(const char *name, umode_t mode,
8989
{
9090
int error;
9191

92-
mutex_lock(&d_inode(parent)->i_mutex);
92+
inode_lock(d_inode(parent));
9393
*dentry = lookup_one_len(name, parent, strlen(name));
9494
if (!IS_ERR(*dentry))
9595
error = qibfs_mknod(d_inode(parent), *dentry,
9696
mode, fops, data);
9797
else
9898
error = PTR_ERR(*dentry);
99-
mutex_unlock(&d_inode(parent)->i_mutex);
99+
inode_unlock(d_inode(parent));
100100

101101
return error;
102102
}
@@ -481,7 +481,7 @@ static int remove_device_files(struct super_block *sb,
481481
int ret, i;
482482

483483
root = dget(sb->s_root);
484-
mutex_lock(&d_inode(root)->i_mutex);
484+
inode_lock(d_inode(root));
485485
snprintf(unit, sizeof(unit), "%u", dd->unit);
486486
dir = lookup_one_len(unit, root, strlen(unit));
487487

@@ -491,7 +491,7 @@ static int remove_device_files(struct super_block *sb,
491491
goto bail;
492492
}
493493

494-
mutex_lock(&d_inode(dir)->i_mutex);
494+
inode_lock(d_inode(dir));
495495
remove_file(dir, "counters");
496496
remove_file(dir, "counter_names");
497497
remove_file(dir, "portcounter_names");
@@ -506,13 +506,13 @@ static int remove_device_files(struct super_block *sb,
506506
}
507507
}
508508
remove_file(dir, "flash");
509-
mutex_unlock(&d_inode(dir)->i_mutex);
509+
inode_unlock(d_inode(dir));
510510
ret = simple_rmdir(d_inode(root), dir);
511511
d_delete(dir);
512512
dput(dir);
513513

514514
bail:
515-
mutex_unlock(&d_inode(root)->i_mutex);
515+
inode_unlock(d_inode(root));
516516
dput(root);
517517
return ret;
518518
}

0 commit comments

Comments
 (0)