Commit 088545f6 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make btrfs_dirty_pages take btrfs_inode

There is a single use of the generic vfs_inode so let's take btrfs_inode
as a parameter and remove couple of redundant BTRFS_I() calls.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent c2566f22
...@@ -3029,7 +3029,7 @@ int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path, ...@@ -3029,7 +3029,7 @@ int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path,
int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode, u64 start, u64 end); struct btrfs_inode *inode, u64 start, u64 end);
int btrfs_release_file(struct inode *inode, struct file *file); int btrfs_release_file(struct inode *inode, struct file *file);
int btrfs_dirty_pages(struct 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); struct extent_state **cached);
int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end);
......
...@@ -500,18 +500,18 @@ static int btrfs_find_new_delalloc_bytes(struct btrfs_inode *inode, ...@@ -500,18 +500,18 @@ static int btrfs_find_new_delalloc_bytes(struct btrfs_inode *inode,
* this also makes the decision about creating an inline extent vs * this also makes the decision about creating an inline extent vs
* doing real data extents, marking pages dirty and delalloc as required. * doing real data extents, marking pages dirty and delalloc as required.
*/ */
int btrfs_dirty_pages(struct 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) struct extent_state **cached)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = inode->root->fs_info;
int err = 0; int err = 0;
int i; int i;
u64 num_bytes; u64 num_bytes;
u64 start_pos; u64 start_pos;
u64 end_of_last_block; u64 end_of_last_block;
u64 end_pos = pos + write_bytes; u64 end_pos = pos + write_bytes;
loff_t isize = i_size_read(inode); loff_t isize = i_size_read(&inode->vfs_inode);
unsigned int extra_bits = 0; unsigned int extra_bits = 0;
start_pos = pos & ~((u64) fs_info->sectorsize - 1); start_pos = pos & ~((u64) fs_info->sectorsize - 1);
...@@ -524,13 +524,13 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages, ...@@ -524,13 +524,13 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
* The pages may have already been dirty, clear out old accounting so * The pages may have already been dirty, clear out old accounting so
* we can set things up properly * we can set things up properly
*/ */
clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, end_of_last_block, clear_extent_bit(&inode->io_tree, start_pos, end_of_last_block,
EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
0, 0, cached); 0, 0, cached);
if (!btrfs_is_free_space_inode(BTRFS_I(inode))) { if (!btrfs_is_free_space_inode(inode)) {
if (start_pos >= isize && if (start_pos >= isize &&
!(BTRFS_I(inode)->flags & BTRFS_INODE_PREALLOC)) { !(inode->flags & BTRFS_INODE_PREALLOC)) {
/* /*
* There can't be any extents following eof in this case * There can't be any extents following eof in this case
* so just set the delalloc new bit for the range * so just set the delalloc new bit for the range
...@@ -538,15 +538,14 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages, ...@@ -538,15 +538,14 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
*/ */
extra_bits |= EXTENT_DELALLOC_NEW; extra_bits |= EXTENT_DELALLOC_NEW;
} else { } else {
err = btrfs_find_new_delalloc_bytes(BTRFS_I(inode), err = btrfs_find_new_delalloc_bytes(inode, start_pos,
start_pos,
num_bytes, cached); num_bytes, cached);
if (err) if (err)
return err; return err;
} }
} }
err = btrfs_set_extent_delalloc(BTRFS_I(inode), start_pos, end_of_last_block, err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block,
extra_bits, cached); extra_bits, cached);
if (err) if (err)
return err; return err;
...@@ -564,7 +563,7 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages, ...@@ -564,7 +563,7 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
* at this time. * at this time.
*/ */
if (end_pos > isize) if (end_pos > isize)
i_size_write(inode, end_pos); i_size_write(&inode->vfs_inode, end_pos);
return 0; return 0;
} }
...@@ -1795,8 +1794,9 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb, ...@@ -1795,8 +1794,9 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
fs_info->sectorsize); fs_info->sectorsize);
if (copied > 0) if (copied > 0)
ret = btrfs_dirty_pages(inode, pages, dirty_pages, ret = btrfs_dirty_pages(BTRFS_I(inode), pages,
pos, copied, &cached_state); dirty_pages, pos, copied,
&cached_state);
/* /*
* If we have not locked the extent range, because the range's * If we have not locked the extent range, because the range's
......
...@@ -1334,8 +1334,9 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode, ...@@ -1334,8 +1334,9 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
io_ctl_zero_remaining_pages(io_ctl); io_ctl_zero_remaining_pages(io_ctl);
/* Everything is written out, now we dirty the pages in the file. */ /* Everything is written out, now we dirty the pages in the file. */
ret = btrfs_dirty_pages(inode, io_ctl->pages, io_ctl->num_pages, 0, ret = btrfs_dirty_pages(BTRFS_I(inode), io_ctl->pages,
i_size_read(inode), &cached_state); io_ctl->num_pages, 0, i_size_read(inode),
&cached_state);
if (ret) if (ret)
goto out_nospc; goto out_nospc;
......
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