Commit 29b6352b authored by David Sterba's avatar David Sterba

btrfs: pass btrfs_inode to btrfs_inode_lock

The function is for internal interfaces so we should use the
btrfs_inode.
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent d9dcae67
...@@ -545,7 +545,7 @@ enum btrfs_ilock_type { ...@@ -545,7 +545,7 @@ enum btrfs_ilock_type {
ENUM_BIT(BTRFS_ILOCK_MMAP), ENUM_BIT(BTRFS_ILOCK_MMAP),
}; };
int btrfs_inode_lock(struct inode *inode, unsigned int ilock_flags); int btrfs_inode_lock(struct btrfs_inode *inode, unsigned int ilock_flags);
void btrfs_inode_unlock(struct inode *inode, unsigned int ilock_flags); void btrfs_inode_unlock(struct inode *inode, unsigned int ilock_flags);
void btrfs_update_inode_bytes(struct btrfs_inode *inode, const u64 add_bytes, void btrfs_update_inode_bytes(struct btrfs_inode *inode, const u64 add_bytes,
const u64 del_bytes); const u64 del_bytes);
......
...@@ -1295,7 +1295,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra, ...@@ -1295,7 +1295,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
(SZ_256K >> PAGE_SHIFT)) << PAGE_SHIFT) - 1; (SZ_256K >> PAGE_SHIFT)) << PAGE_SHIFT) - 1;
cluster_end = min(cluster_end, last_byte); cluster_end = min(cluster_end, last_byte);
btrfs_inode_lock(inode, 0); btrfs_inode_lock(BTRFS_I(inode), 0);
if (IS_SWAPFILE(inode)) { if (IS_SWAPFILE(inode)) {
ret = -ETXTBSY; ret = -ETXTBSY;
btrfs_inode_unlock(inode, 0); btrfs_inode_unlock(inode, 0);
...@@ -1351,7 +1351,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra, ...@@ -1351,7 +1351,7 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
ret = sectors_defragged; ret = sectors_defragged;
} }
if (do_compress) { if (do_compress) {
btrfs_inode_lock(inode, 0); btrfs_inode_lock(BTRFS_I(inode), 0);
BTRFS_I(inode)->defrag_compress = BTRFS_COMPRESS_NONE; BTRFS_I(inode)->defrag_compress = BTRFS_COMPRESS_NONE;
btrfs_inode_unlock(inode, 0); btrfs_inode_unlock(inode, 0);
} }
......
...@@ -1647,7 +1647,7 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode, ...@@ -1647,7 +1647,7 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode,
* item->readdir_list. * item->readdir_list.
*/ */
btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED); btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
btrfs_inode_lock(inode, 0); btrfs_inode_lock(BTRFS_I(inode), 0);
mutex_lock(&delayed_node->mutex); mutex_lock(&delayed_node->mutex);
item = __btrfs_first_delayed_insertion_item(delayed_node); item = __btrfs_first_delayed_insertion_item(delayed_node);
......
...@@ -1193,7 +1193,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb, ...@@ -1193,7 +1193,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
if (nowait) if (nowait)
ilock_flags |= BTRFS_ILOCK_TRY; ilock_flags |= BTRFS_ILOCK_TRY;
ret = btrfs_inode_lock(inode, ilock_flags); ret = btrfs_inode_lock(BTRFS_I(inode), ilock_flags);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1468,7 +1468,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1468,7 +1468,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
ilock_flags |= BTRFS_ILOCK_SHARED; ilock_flags |= BTRFS_ILOCK_SHARED;
relock: relock:
err = btrfs_inode_lock(inode, ilock_flags); err = btrfs_inode_lock(BTRFS_I(inode), ilock_flags);
if (err < 0) if (err < 0)
return err; return err;
...@@ -1616,7 +1616,7 @@ static ssize_t btrfs_encoded_write(struct kiocb *iocb, struct iov_iter *from, ...@@ -1616,7 +1616,7 @@ static ssize_t btrfs_encoded_write(struct kiocb *iocb, struct iov_iter *from,
loff_t count; loff_t count;
ssize_t ret; ssize_t ret;
btrfs_inode_lock(inode, 0); btrfs_inode_lock(BTRFS_I(inode), 0);
count = encoded->len; count = encoded->len;
ret = generic_write_checks_count(iocb, &count); ret = generic_write_checks_count(iocb, &count);
if (ret == 0 && count != encoded->len) { if (ret == 0 && count != encoded->len) {
...@@ -1806,7 +1806,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -1806,7 +1806,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
if (ret) if (ret)
goto out; goto out;
btrfs_inode_lock(inode, BTRFS_ILOCK_MMAP); btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
atomic_inc(&root->log_batch); atomic_inc(&root->log_batch);
...@@ -2596,7 +2596,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len) ...@@ -2596,7 +2596,7 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
bool truncated_block = false; bool truncated_block = false;
bool updated_inode = false; bool updated_inode = false;
btrfs_inode_lock(inode, BTRFS_ILOCK_MMAP); btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
ret = btrfs_wait_ordered_range(inode, offset, len); ret = btrfs_wait_ordered_range(inode, offset, len);
if (ret) if (ret)
...@@ -3054,7 +3054,7 @@ static long btrfs_fallocate(struct file *file, int mode, ...@@ -3054,7 +3054,7 @@ static long btrfs_fallocate(struct file *file, int mode,
if (mode & FALLOC_FL_PUNCH_HOLE) if (mode & FALLOC_FL_PUNCH_HOLE)
return btrfs_punch_hole(file, offset, len); return btrfs_punch_hole(file, offset, len);
btrfs_inode_lock(inode, BTRFS_ILOCK_MMAP); btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + len > inode->i_size) { if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + len > inode->i_size) {
ret = inode_newsize_ok(inode, offset + len); ret = inode_newsize_ok(inode, offset + len);
...@@ -3691,7 +3691,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence) ...@@ -3691,7 +3691,7 @@ static loff_t btrfs_file_llseek(struct file *file, loff_t offset, int whence)
return generic_file_llseek(file, offset, whence); return generic_file_llseek(file, offset, whence);
case SEEK_DATA: case SEEK_DATA:
case SEEK_HOLE: case SEEK_HOLE:
btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED); btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
offset = find_desired_extent(BTRFS_I(inode), offset, whence); offset = find_desired_extent(BTRFS_I(inode), offset, whence);
btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED); btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
break; break;
...@@ -3748,7 +3748,7 @@ static ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to) ...@@ -3748,7 +3748,7 @@ static ssize_t btrfs_direct_read(struct kiocb *iocb, struct iov_iter *to)
if (check_direct_read(btrfs_sb(inode->i_sb), to, iocb->ki_pos)) if (check_direct_read(btrfs_sb(inode->i_sb), to, iocb->ki_pos))
return 0; return 0;
btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED); btrfs_inode_lock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
again: again:
/* /*
* This is similar to what we do for direct IO writes, see the comment * This is similar to what we do for direct IO writes, see the comment
......
...@@ -172,27 +172,27 @@ static void __cold btrfs_print_data_csum_error(struct btrfs_inode *inode, ...@@ -172,27 +172,27 @@ static void __cold btrfs_print_data_csum_error(struct btrfs_inode *inode,
* return -EAGAIN * return -EAGAIN
* BTRFS_ILOCK_MMAP - acquire a write lock on the i_mmap_lock * BTRFS_ILOCK_MMAP - acquire a write lock on the i_mmap_lock
*/ */
int btrfs_inode_lock(struct inode *inode, unsigned int ilock_flags) int btrfs_inode_lock(struct btrfs_inode *inode, unsigned int ilock_flags)
{ {
if (ilock_flags & BTRFS_ILOCK_SHARED) { if (ilock_flags & BTRFS_ILOCK_SHARED) {
if (ilock_flags & BTRFS_ILOCK_TRY) { if (ilock_flags & BTRFS_ILOCK_TRY) {
if (!inode_trylock_shared(inode)) if (!inode_trylock_shared(&inode->vfs_inode))
return -EAGAIN; return -EAGAIN;
else else
return 0; return 0;
} }
inode_lock_shared(inode); inode_lock_shared(&inode->vfs_inode);
} else { } else {
if (ilock_flags & BTRFS_ILOCK_TRY) { if (ilock_flags & BTRFS_ILOCK_TRY) {
if (!inode_trylock(inode)) if (!inode_trylock(&inode->vfs_inode))
return -EAGAIN; return -EAGAIN;
else else
return 0; return 0;
} }
inode_lock(inode); inode_lock(&inode->vfs_inode);
} }
if (ilock_flags & BTRFS_ILOCK_MMAP) if (ilock_flags & BTRFS_ILOCK_MMAP)
down_write(&BTRFS_I(inode)->i_mmap_lock); down_write(&inode->i_mmap_lock);
return 0; return 0;
} }
...@@ -10529,7 +10529,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter, ...@@ -10529,7 +10529,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
file_accessed(iocb->ki_filp); file_accessed(iocb->ki_filp);
btrfs_inode_lock(&inode->vfs_inode, BTRFS_ILOCK_SHARED); btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED);
if (iocb->ki_pos >= inode->vfs_inode.i_size) { if (iocb->ki_pos >= inode->vfs_inode.i_size) {
btrfs_inode_unlock(&inode->vfs_inode, BTRFS_ILOCK_SHARED); btrfs_inode_unlock(&inode->vfs_inode, BTRFS_ILOCK_SHARED);
......
...@@ -2528,7 +2528,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, ...@@ -2528,7 +2528,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
goto out_dput; goto out_dput;
} }
btrfs_inode_lock(inode, 0); btrfs_inode_lock(BTRFS_I(inode), 0);
err = btrfs_delete_subvolume(dir, dentry); err = btrfs_delete_subvolume(dir, dentry);
btrfs_inode_unlock(inode, 0); btrfs_inode_unlock(inode, 0);
if (!err) if (!err)
......
...@@ -893,7 +893,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off, ...@@ -893,7 +893,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
return -EINVAL; return -EINVAL;
if (same_inode) { if (same_inode) {
btrfs_inode_lock(src_inode, BTRFS_ILOCK_MMAP); btrfs_inode_lock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
} else { } else {
lock_two_nondirectories(src_inode, dst_inode); lock_two_nondirectories(src_inode, dst_inode);
btrfs_double_mmap_lock(src_inode, dst_inode); btrfs_double_mmap_lock(src_inode, dst_inode);
......
...@@ -2874,7 +2874,7 @@ static noinline_for_stack int prealloc_file_extent_cluster( ...@@ -2874,7 +2874,7 @@ static noinline_for_stack int prealloc_file_extent_cluster(
if (ret) if (ret)
return ret; return ret;
btrfs_inode_lock(&inode->vfs_inode, 0); btrfs_inode_lock(inode, 0);
for (nr = 0; nr < cluster->nr; nr++) { for (nr = 0; nr < cluster->nr; nr++) {
struct extent_state *cached_state = NULL; struct extent_state *cached_state = NULL;
......
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