Commit 2cff578c authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Make lock_and_cleanup_extent_if_need take btrfs_inode

Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 85b7ab67
...@@ -1415,13 +1415,13 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages, ...@@ -1415,13 +1415,13 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages,
* the other < 0 number - Something wrong happens * the other < 0 number - Something wrong happens
*/ */
static noinline int static noinline int
lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages, lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
size_t num_pages, loff_t pos, size_t num_pages, loff_t pos,
size_t write_bytes, size_t write_bytes,
u64 *lockstart, u64 *lockend, u64 *lockstart, u64 *lockend,
struct extent_state **cached_state) struct extent_state **cached_state)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
u64 start_pos; u64 start_pos;
u64 last_pos; u64 last_pos;
int i; int i;
...@@ -1432,30 +1432,30 @@ lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages, ...@@ -1432,30 +1432,30 @@ lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages,
+ round_up(pos + write_bytes - start_pos, + round_up(pos + write_bytes - start_pos,
fs_info->sectorsize) - 1; fs_info->sectorsize) - 1;
if (start_pos < inode->i_size) { if (start_pos < inode->vfs_inode.i_size) {
struct btrfs_ordered_extent *ordered; struct btrfs_ordered_extent *ordered;
lock_extent_bits(&BTRFS_I(inode)->io_tree, lock_extent_bits(&inode->io_tree, start_pos, last_pos,
start_pos, last_pos, cached_state); cached_state);
ordered = btrfs_lookup_ordered_range(BTRFS_I(inode), start_pos, ordered = btrfs_lookup_ordered_range(inode, start_pos,
last_pos - start_pos + 1); last_pos - start_pos + 1);
if (ordered && if (ordered &&
ordered->file_offset + ordered->len > start_pos && ordered->file_offset + ordered->len > start_pos &&
ordered->file_offset <= last_pos) { ordered->file_offset <= last_pos) {
unlock_extent_cached(&BTRFS_I(inode)->io_tree, unlock_extent_cached(&inode->io_tree, start_pos,
start_pos, last_pos, last_pos, cached_state, GFP_NOFS);
cached_state, GFP_NOFS);
for (i = 0; i < num_pages; i++) { for (i = 0; i < num_pages; i++) {
unlock_page(pages[i]); unlock_page(pages[i]);
put_page(pages[i]); put_page(pages[i]);
} }
btrfs_start_ordered_extent(inode, ordered, 1); btrfs_start_ordered_extent(&inode->vfs_inode,
ordered, 1);
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
return -EAGAIN; return -EAGAIN;
} }
if (ordered) if (ordered)
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, clear_extent_bit(&inode->io_tree, start_pos,
last_pos, EXTENT_DIRTY | EXTENT_DELALLOC | last_pos, EXTENT_DIRTY | EXTENT_DELALLOC |
EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
0, 0, cached_state, GFP_NOFS); 0, 0, cached_state, GFP_NOFS);
...@@ -1626,8 +1626,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, ...@@ -1626,8 +1626,8 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
if (ret) if (ret)
break; break;
ret = lock_and_cleanup_extent_if_need(inode, pages, num_pages, ret = lock_and_cleanup_extent_if_need(BTRFS_I(inode), pages,
pos, write_bytes, &lockstart, num_pages, pos, write_bytes, &lockstart,
&lockend, &cached_state); &lockend, &cached_state);
if (ret < 0) { if (ret < 0) {
if (ret == -EAGAIN) if (ret == -EAGAIN)
......
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