Commit 64708539 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: use btrfs_inode_lock/btrfs_inode_unlock inode lock helpers

A few places we intermix btrfs_inode_lock with a inode_unlock, and some
places we just use inode_lock/inode_unlock instead of btrfs_inode_lock.

None of these places are using this incorrectly, but as we adjust some
of these callers it would be nice to keep everything consistent, so
convert everybody to use btrfs_inode_lock/btrfs_inode_unlock.
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 8318ba79
......@@ -1573,8 +1573,8 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode,
* We can only do one readdir with delayed items at a time because of
* item->readdir_list.
*/
inode_unlock_shared(inode);
inode_lock(inode);
btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
btrfs_inode_lock(inode, 0);
mutex_lock(&delayed_node->mutex);
item = __btrfs_first_delayed_insertion_item(delayed_node);
......
......@@ -2122,7 +2122,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
if (ret)
goto out;
inode_lock(inode);
btrfs_inode_lock(inode, 0);
atomic_inc(&root->log_batch);
......@@ -2154,7 +2154,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
*/
ret = start_ordered_ops(inode, start, end);
if (ret) {
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
goto out;
}
......@@ -2255,7 +2255,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
* file again, but that will end up using the synchronization
* inside btrfs_sync_log to keep things safe.
*/
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
if (ret != BTRFS_NO_LOG_SYNC) {
if (!ret) {
......@@ -2285,7 +2285,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
out_release_extents:
btrfs_release_log_ctx_extents(&ctx);
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
goto out;
}
......@@ -2867,7 +2867,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
if (ret)
return ret;
inode_lock(inode);
btrfs_inode_lock(inode, 0);
ino_size = round_up(inode->i_size, fs_info->sectorsize);
ret = find_first_non_hole(BTRFS_I(inode), &offset, &len);
if (ret < 0)
......@@ -2907,7 +2907,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
truncated_block = true;
ret = btrfs_truncate_block(BTRFS_I(inode), offset, 0, 0);
if (ret) {
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
return ret;
}
}
......@@ -3008,7 +3008,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
ret = ret2;
}
}
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
return ret;
}
......@@ -3376,7 +3376,7 @@ static long btrfs_fallocate(struct file *file, int mode,
if (mode & FALLOC_FL_ZERO_RANGE) {
ret = btrfs_zero_range(inode, offset, len, mode);
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
return ret;
}
......@@ -3486,7 +3486,7 @@ static long btrfs_fallocate(struct file *file, int mode,
unlock_extent_cached(&BTRFS_I(inode)->io_tree, alloc_start, locked_end,
&cached_state);
out:
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
/* Let go of our reservation. */
if (ret != 0 && !(mode & FALLOC_FL_ZERO_RANGE))
btrfs_free_reserved_data_space(BTRFS_I(inode), data_reserved,
......
......@@ -226,7 +226,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
if (ret)
return ret;
inode_lock(inode);
btrfs_inode_lock(inode, 0);
fsflags = btrfs_mask_fsflags_for_type(inode, fsflags);
old_fsflags = btrfs_inode_flags_to_fsflags(binode->flags);
......@@ -353,7 +353,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
out_end_trans:
btrfs_end_transaction(trans);
out_unlock:
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
mnt_drop_write_file(file);
return ret;
}
......@@ -449,7 +449,7 @@ static int btrfs_ioctl_fssetxattr(struct file *file, void __user *arg)
if (ret)
return ret;
inode_lock(inode);
btrfs_inode_lock(inode, 0);
old_flags = binode->flags;
old_i_flags = inode->i_flags;
......@@ -501,7 +501,7 @@ static int btrfs_ioctl_fssetxattr(struct file *file, void __user *arg)
inode->i_flags = old_i_flags;
}
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
mnt_drop_write_file(file);
return ret;
......@@ -1014,7 +1014,7 @@ static noinline int btrfs_mksubvol(const struct path *parent,
out_dput:
dput(dentry);
out_unlock:
inode_unlock(dir);
btrfs_inode_unlock(dir, 0);
return error;
}
......@@ -1612,7 +1612,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
ra_index += cluster;
}
inode_lock(inode);
btrfs_inode_lock(inode, 0);
if (IS_SWAPFILE(inode)) {
ret = -ETXTBSY;
} else {
......@@ -1621,13 +1621,13 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
ret = cluster_pages_for_defrag(inode, pages, i, cluster);
}
if (ret < 0) {
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
goto out_ra;
}
defrag_count += ret;
balance_dirty_pages_ratelimited(inode->i_mapping);
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
if (newer_than) {
if (newer_off == (u64)-1)
......@@ -1675,9 +1675,9 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
out_ra:
if (do_compress) {
inode_lock(inode);
btrfs_inode_lock(inode, 0);
BTRFS_I(inode)->defrag_compress = BTRFS_COMPRESS_NONE;
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
}
if (!file)
kfree(ra);
......@@ -3112,9 +3112,9 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
goto out_dput;
}
inode_lock(inode);
btrfs_inode_lock(inode, 0);
err = btrfs_delete_subvolume(dir, dentry);
inode_unlock(inode);
btrfs_inode_unlock(inode, 0);
if (!err) {
fsnotify_rmdir(dir, dentry);
d_delete(dentry);
......@@ -3123,7 +3123,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
out_dput:
dput(dentry);
out_unlock_dir:
inode_unlock(dir);
btrfs_inode_unlock(dir, 0);
free_subvol_name:
kfree(subvol_name_ptr);
free_parent:
......
......@@ -833,7 +833,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
return -EINVAL;
if (same_inode)
inode_lock(src_inode);
btrfs_inode_lock(src_inode, 0);
else
lock_two_nondirectories(src_inode, dst_inode);
......@@ -849,7 +849,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
out_unlock:
if (same_inode)
inode_unlock(src_inode);
btrfs_inode_unlock(src_inode, 0);
else
unlock_two_nondirectories(src_inode, dst_inode);
......
......@@ -2578,7 +2578,7 @@ static noinline_for_stack int prealloc_file_extent_cluster(
return btrfs_end_transaction(trans);
}
inode_lock(&inode->vfs_inode);
btrfs_inode_lock(&inode->vfs_inode, 0);
for (nr = 0; nr < cluster->nr; nr++) {
start = cluster->boundary[nr] - offset;
if (nr + 1 < cluster->nr)
......@@ -2596,7 +2596,7 @@ static noinline_for_stack int prealloc_file_extent_cluster(
if (ret)
break;
}
inode_unlock(&inode->vfs_inode);
btrfs_inode_unlock(&inode->vfs_inode, 0);
if (cur_offset < prealloc_end)
btrfs_free_reserved_data_space_noquota(inode->root->fs_info,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment