Skip to content

Commit

Permalink
wrappers for ->i_mutex access
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro committed Jan 22, 2016
1 parent 57b8f11 commit 5955102
Show file tree
Hide file tree
Showing 177 changed files with 908 additions and 883 deletions.
4 changes: 2 additions & 2 deletions arch/powerpc/platforms/cell/spufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1799,9 +1799,9 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int data
struct inode *inode = file_inode(file);
int err = filemap_write_and_wait_range(inode->i_mapping, start, end);
if (!err) {
mutex_lock(&inode->i_mutex);
inode_lock(inode);
err = spufs_mfc_flush(file, NULL);
mutex_unlock(&inode->i_mutex);
inode_unlock(inode);
}
return err;
}
Expand Down
12 changes: 6 additions & 6 deletions arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static void spufs_prune_dir(struct dentry *dir)
{
struct dentry *dentry, *tmp;

mutex_lock(&d_inode(dir)->i_mutex);
inode_lock(d_inode(dir));
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
spin_lock(&dentry->d_lock);
if (simple_positive(dentry)) {
Expand All @@ -180,7 +180,7 @@ static void spufs_prune_dir(struct dentry *dir)
}
}
shrink_dcache_parent(dir);
mutex_unlock(&d_inode(dir)->i_mutex);
inode_unlock(d_inode(dir));
}

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

mutex_lock_nested(&parent->i_mutex, I_MUTEX_PARENT);
inode_lock_nested(parent, I_MUTEX_PARENT);
ret = spufs_rmdir(parent, dir);
mutex_unlock(&parent->i_mutex);
inode_unlock(parent);
WARN_ON(ret);

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

mutex_lock(&inode->i_mutex);
inode_lock(inode);

dget(dentry);
inc_nlink(dir);
Expand All @@ -291,7 +291,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
if (ret)
spufs_rmdir(dir, dentry);

mutex_unlock(&inode->i_mutex);
inode_unlock(inode);

return ret;
}
Expand Down
8 changes: 4 additions & 4 deletions arch/s390/hypfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void hypfs_remove(struct dentry *dentry)
struct dentry *parent;

parent = dentry->d_parent;
mutex_lock(&d_inode(parent)->i_mutex);
inode_lock(d_inode(parent));
if (simple_positive(dentry)) {
if (d_is_dir(dentry))
simple_rmdir(d_inode(parent), dentry);
Expand All @@ -76,7 +76,7 @@ static void hypfs_remove(struct dentry *dentry)
}
d_delete(dentry);
dput(dentry);
mutex_unlock(&d_inode(parent)->i_mutex);
inode_unlock(d_inode(parent));
}

static void hypfs_delete_tree(struct dentry *root)
Expand Down Expand Up @@ -331,7 +331,7 @@ static struct dentry *hypfs_create_file(struct dentry *parent, const char *name,
struct dentry *dentry;
struct inode *inode;

mutex_lock(&d_inode(parent)->i_mutex);
inode_lock(d_inode(parent));
dentry = lookup_one_len(name, parent, strlen(name));
if (IS_ERR(dentry)) {
dentry = ERR_PTR(-ENOMEM);
Expand Down Expand Up @@ -359,7 +359,7 @@ static struct dentry *hypfs_create_file(struct dentry *parent, const char *name,
d_instantiate(dentry, inode);
dget(dentry);
fail:
mutex_unlock(&d_inode(parent)->i_mutex);
inode_unlock(d_inode(parent));
return dentry;
}

Expand Down
4 changes: 2 additions & 2 deletions block/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,12 @@ static int blkdev_daxset(struct block_device *bdev, unsigned long argp)
if (arg && !blkdev_dax_capable(bdev))
return -ENOTTY;

mutex_lock(&bdev->bd_inode->i_mutex);
inode_lock(bdev->bd_inode);
if (bdev->bd_map_count == 0)
inode_set_flags(bdev->bd_inode, arg, S_DAX);
else
rc = -EBUSY;
mutex_unlock(&bdev->bd_inode->i_mutex);
inode_unlock(bdev->bd_inode);
return rc;
}
#else
Expand Down
12 changes: 6 additions & 6 deletions drivers/base/devtmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
newattrs.ia_uid = uid;
newattrs.ia_gid = gid;
newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
mutex_lock(&d_inode(dentry)->i_mutex);
inode_lock(d_inode(dentry));
notify_change(dentry, &newattrs, NULL);
mutex_unlock(&d_inode(dentry)->i_mutex);
inode_unlock(d_inode(dentry));

/* mark as kernel-created inode */
d_inode(dentry)->i_private = &thread;
Expand All @@ -244,7 +244,7 @@ static int dev_rmdir(const char *name)
err = -ENOENT;
}
dput(dentry);
mutex_unlock(&d_inode(parent.dentry)->i_mutex);
inode_unlock(d_inode(parent.dentry));
path_put(&parent);
return err;
}
Expand Down Expand Up @@ -321,9 +321,9 @@ static int handle_remove(const char *nodename, struct device *dev)
newattrs.ia_mode = stat.mode & ~0777;
newattrs.ia_valid =
ATTR_UID|ATTR_GID|ATTR_MODE;
mutex_lock(&d_inode(dentry)->i_mutex);
inode_lock(d_inode(dentry));
notify_change(dentry, &newattrs, NULL);
mutex_unlock(&d_inode(dentry)->i_mutex);
inode_unlock(d_inode(dentry));
err = vfs_unlink(d_inode(parent.dentry), dentry, NULL);
if (!err || err == -ENOENT)
deleted = 1;
Expand All @@ -332,7 +332,7 @@ static int handle_remove(const char *nodename, struct device *dev)
err = -ENOENT;
}
dput(dentry);
mutex_unlock(&d_inode(parent.dentry)->i_mutex);
inode_unlock(d_inode(parent.dentry));

path_put(&parent);
if (deleted && strchr(nodename, '/'))
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/aoe/aoecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,9 +964,9 @@ aoecmd_sleepwork(struct work_struct *work)
ssize = get_capacity(d->gd);
bd = bdget_disk(d->gd, 0);
if (bd) {
mutex_lock(&bd->bd_inode->i_mutex);
inode_lock(bd->bd_inode);
i_size_write(bd->bd_inode, (loff_t)ssize<<9);
mutex_unlock(&bd->bd_inode->i_mutex);
inode_unlock(bd->bd_inode);
bdput(bd);
}
spin_lock_irq(&d->lock);
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/drbd/drbd_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,12 @@ static int drbd_single_open(struct file *file, int (*show)(struct seq_file *, vo
if (!parent || d_really_is_negative(parent))
goto out;
/* serialize with d_delete() */
mutex_lock(&d_inode(parent)->i_mutex);
inode_lock(d_inode(parent));
/* Make sure the object is still alive */
if (simple_positive(file->f_path.dentry)
&& kref_get_unless_zero(kref))
ret = 0;
mutex_unlock(&d_inode(parent)->i_mutex);
inode_unlock(d_inode(parent));
if (!ret) {
ret = single_open(file, show, data);
if (ret)
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
{
loff_t ret;

mutex_lock(&file_inode(file)->i_mutex);
inode_lock(file_inode(file));
switch (orig) {
case SEEK_CUR:
offset += file->f_pos;
Expand All @@ -706,7 +706,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
default:
ret = -EINVAL;
}
mutex_unlock(&file_inode(file)->i_mutex);
inode_unlock(file_inode(file));
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/char/ps3flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ static int ps3flash_fsync(struct file *file, loff_t start, loff_t end, int datas
{
struct inode *inode = file_inode(file);
int err;
mutex_lock(&inode->i_mutex);
inode_lock(inode);
err = ps3flash_writeback(ps3flash_dev);
mutex_unlock(&inode->i_mutex);
inode_unlock(inode);
return err;
}

Expand Down
12 changes: 6 additions & 6 deletions drivers/infiniband/hw/qib/qib_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ static int create_file(const char *name, umode_t mode,
{
int error;

mutex_lock(&d_inode(parent)->i_mutex);
inode_lock(d_inode(parent));
*dentry = lookup_one_len(name, parent, strlen(name));
if (!IS_ERR(*dentry))
error = qibfs_mknod(d_inode(parent), *dentry,
mode, fops, data);
else
error = PTR_ERR(*dentry);
mutex_unlock(&d_inode(parent)->i_mutex);
inode_unlock(d_inode(parent));

return error;
}
Expand Down Expand Up @@ -481,7 +481,7 @@ static int remove_device_files(struct super_block *sb,
int ret, i;

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

Expand All @@ -491,7 +491,7 @@ static int remove_device_files(struct super_block *sb,
goto bail;
}

mutex_lock(&d_inode(dir)->i_mutex);
inode_lock(d_inode(dir));
remove_file(dir, "counters");
remove_file(dir, "counter_names");
remove_file(dir, "portcounter_names");
Expand All @@ -506,13 +506,13 @@ static int remove_device_files(struct super_block *sb,
}
}
remove_file(dir, "flash");
mutex_unlock(&d_inode(dir)->i_mutex);
inode_unlock(d_inode(dir));
ret = simple_rmdir(d_inode(root), dir);
d_delete(dir);
dput(dir);

bail:
mutex_unlock(&d_inode(root)->i_mutex);
inode_unlock(d_inode(root));
dput(root);
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/mtd/ubi/cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ static int vol_cdev_fsync(struct file *file, loff_t start, loff_t end,
struct ubi_device *ubi = desc->vol->ubi;
struct inode *inode = file_inode(file);
int err;
mutex_lock(&inode->i_mutex);
inode_lock(inode);
err = ubi_sync(ubi->ubi_num);
mutex_unlock(&inode->i_mutex);
inode_unlock(inode);
return err;
}

Expand Down
16 changes: 8 additions & 8 deletions drivers/oprofile/oprofilefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,22 @@ static int __oprofilefs_create_file(struct dentry *root, char const *name,
struct dentry *dentry;
struct inode *inode;

mutex_lock(&d_inode(root)->i_mutex);
inode_lock(d_inode(root));
dentry = d_alloc_name(root, name);
if (!dentry) {
mutex_unlock(&d_inode(root)->i_mutex);
inode_unlock(d_inode(root));
return -ENOMEM;
}
inode = oprofilefs_get_inode(root->d_sb, S_IFREG | perm);
if (!inode) {
dput(dentry);
mutex_unlock(&d_inode(root)->i_mutex);
inode_unlock(d_inode(root));
return -ENOMEM;
}
inode->i_fop = fops;
inode->i_private = priv;
d_add(dentry, inode);
mutex_unlock(&d_inode(root)->i_mutex);
inode_unlock(d_inode(root));
return 0;
}

Expand Down Expand Up @@ -215,22 +215,22 @@ struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name)
struct dentry *dentry;
struct inode *inode;

mutex_lock(&d_inode(parent)->i_mutex);
inode_lock(d_inode(parent));
dentry = d_alloc_name(parent, name);
if (!dentry) {
mutex_unlock(&d_inode(parent)->i_mutex);
inode_unlock(d_inode(parent));
return NULL;
}
inode = oprofilefs_get_inode(parent->d_sb, S_IFDIR | 0755);
if (!inode) {
dput(dentry);
mutex_unlock(&d_inode(parent)->i_mutex);
inode_unlock(d_inode(parent));
return NULL;
}
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
d_add(dentry, inode);
mutex_unlock(&d_inode(parent)->i_mutex);
inode_unlock(d_inode(parent));
return dentry;
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/staging/lustre/lustre/llite/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin)
int api32 = ll_need_32bit_api(sbi);
loff_t ret = -EINVAL;

mutex_lock(&inode->i_mutex);
inode_lock(inode);
switch (origin) {
case SEEK_SET:
break;
Expand Down Expand Up @@ -1896,7 +1896,7 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin)
goto out;

out:
mutex_unlock(&inode->i_mutex);
inode_unlock(inode);
return ret;
}

Expand Down
Loading

0 comments on commit 5955102

Please sign in to comment.