Commit cef2daba authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: pass a btrfs_inode to btrfs_fdatawrite_range()

Instead of passing a (VFS) inode pointer argument, pass a btrfs_inode
instead, as this is generally what we do for internal APIs, making it
more consistent with most of the code base. This will later allow to
help to remove a lot of BTRFS_I() calls in btrfs_sync_file().
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 4d0120a5
...@@ -1625,7 +1625,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from) ...@@ -1625,7 +1625,7 @@ static ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
* able to read what was just written. * able to read what was just written.
*/ */
endbyte = pos + written_buffered - 1; endbyte = pos + written_buffered - 1;
ret = btrfs_fdatawrite_range(inode, pos, endbyte); ret = btrfs_fdatawrite_range(BTRFS_I(inode), pos, endbyte);
if (ret) if (ret)
goto out; goto out;
ret = filemap_fdatawait_range(inode->i_mapping, pos, endbyte); ret = filemap_fdatawait_range(inode->i_mapping, pos, endbyte);
...@@ -1738,7 +1738,7 @@ int btrfs_release_file(struct inode *inode, struct file *filp) ...@@ -1738,7 +1738,7 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
return 0; return 0;
} }
static int start_ordered_ops(struct inode *inode, loff_t start, loff_t end) static int start_ordered_ops(struct btrfs_inode *inode, loff_t start, loff_t end)
{ {
int ret; int ret;
struct blk_plug plug; struct blk_plug plug;
...@@ -1825,7 +1825,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -1825,7 +1825,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
* multi-task, and make the performance up. See * multi-task, and make the performance up. See
* btrfs_wait_ordered_range for an explanation of the ASYNC check. * btrfs_wait_ordered_range for an explanation of the ASYNC check.
*/ */
ret = start_ordered_ops(inode, start, end); ret = start_ordered_ops(BTRFS_I(inode), start, end);
if (ret) if (ret)
goto out; goto out;
...@@ -1851,7 +1851,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ...@@ -1851,7 +1851,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
* So trigger writeback for any eventual new dirty pages and then we * So trigger writeback for any eventual new dirty pages and then we
* wait for all ordered extents to complete below. * wait for all ordered extents to complete below.
*/ */
ret = start_ordered_ops(inode, start, end); ret = start_ordered_ops(BTRFS_I(inode), start, end);
if (ret) { if (ret) {
btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP); btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_MMAP);
goto out; goto out;
...@@ -4045,8 +4045,9 @@ const struct file_operations btrfs_file_operations = { ...@@ -4045,8 +4045,9 @@ const struct file_operations btrfs_file_operations = {
.fop_flags = FOP_BUFFER_RASYNC | FOP_BUFFER_WASYNC, .fop_flags = FOP_BUFFER_RASYNC | FOP_BUFFER_WASYNC,
}; };
int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end) int btrfs_fdatawrite_range(struct btrfs_inode *inode, loff_t start, loff_t end)
{ {
struct address_space *mapping = inode->vfs_inode.i_mapping;
int ret; int ret;
/* /*
...@@ -4063,10 +4064,9 @@ int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end) ...@@ -4063,10 +4064,9 @@ int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end)
* know better and pull this out at some point in the future, it is * know better and pull this out at some point in the future, it is
* right and you are wrong. * right and you are wrong.
*/ */
ret = filemap_fdatawrite_range(inode->i_mapping, start, end); ret = filemap_fdatawrite_range(mapping, start, end);
if (!ret && test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT, if (!ret && test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT, &inode->runtime_flags))
&BTRFS_I(inode)->runtime_flags)) ret = filemap_fdatawrite_range(mapping, start, end);
ret = filemap_fdatawrite_range(inode->i_mapping, start, end);
return ret; return ret;
} }
...@@ -37,7 +37,7 @@ int btrfs_release_file(struct inode *inode, struct file *file); ...@@ -37,7 +37,7 @@ int btrfs_release_file(struct inode *inode, struct file *file);
int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages, int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages,
size_t num_pages, loff_t pos, size_t write_bytes, size_t num_pages, loff_t pos, size_t write_bytes,
struct extent_state **cached, bool noreserve); struct extent_state **cached, bool noreserve);
int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); int btrfs_fdatawrite_range(struct btrfs_inode *inode, loff_t start, loff_t end);
int btrfs_check_nocow_lock(struct btrfs_inode *inode, loff_t pos, int btrfs_check_nocow_lock(struct btrfs_inode *inode, loff_t pos,
size_t *write_bytes, bool nowait); size_t *write_bytes, bool nowait);
void btrfs_check_nocow_unlock(struct btrfs_inode *inode); void btrfs_check_nocow_unlock(struct btrfs_inode *inode);
......
...@@ -1483,7 +1483,7 @@ static int __btrfs_write_out_cache(struct inode *inode, ...@@ -1483,7 +1483,7 @@ static int __btrfs_write_out_cache(struct inode *inode,
io_ctl->entries = entries; io_ctl->entries = entries;
io_ctl->bitmaps = bitmaps; io_ctl->bitmaps = bitmaps;
ret = btrfs_fdatawrite_range(inode, 0, (u64)-1); ret = btrfs_fdatawrite_range(BTRFS_I(inode), 0, (u64)-1);
if (ret) if (ret)
goto out; goto out;
......
...@@ -859,7 +859,7 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len) ...@@ -859,7 +859,7 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
/* start IO across the range first to instantiate any delalloc /* start IO across the range first to instantiate any delalloc
* extents * extents
*/ */
ret = btrfs_fdatawrite_range(inode, start, orig_end); ret = btrfs_fdatawrite_range(BTRFS_I(inode), start, orig_end);
if (ret) if (ret)
return ret; return ret;
......
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