Commit 72e7e6ed authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: make btrfs_finish_ordered_io btrfs_inode-centric

Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
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 50743398
...@@ -2717,11 +2717,11 @@ static int insert_ordered_extent_file_extent(struct btrfs_trans_handle *trans, ...@@ -2717,11 +2717,11 @@ static int insert_ordered_extent_file_extent(struct btrfs_trans_handle *trans,
*/ */
static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
{ {
struct inode *inode = ordered_extent->inode; struct btrfs_inode *inode = BTRFS_I(ordered_extent->inode);
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_root *root = inode->root;
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_trans_handle *trans = NULL; struct btrfs_trans_handle *trans = NULL;
struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; struct extent_io_tree *io_tree = &inode->io_tree;
struct extent_state *cached_state = NULL; struct extent_state *cached_state = NULL;
u64 start, end; u64 start, end;
int compress_type = 0; int compress_type = 0;
...@@ -2740,14 +2740,14 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2740,14 +2740,14 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
!test_bit(BTRFS_ORDERED_DIRECT, &ordered_extent->flags)) !test_bit(BTRFS_ORDERED_DIRECT, &ordered_extent->flags))
clear_bits |= EXTENT_DELALLOC_NEW; clear_bits |= EXTENT_DELALLOC_NEW;
freespace_inode = btrfs_is_free_space_inode(BTRFS_I(inode)); freespace_inode = btrfs_is_free_space_inode(inode);
if (test_bit(BTRFS_ORDERED_IOERR, &ordered_extent->flags)) { if (test_bit(BTRFS_ORDERED_IOERR, &ordered_extent->flags)) {
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
btrfs_free_io_failure_record(BTRFS_I(inode), start, end); btrfs_free_io_failure_record(inode, start, end);
if (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags)) { if (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags)) {
truncated = true; truncated = true;
...@@ -2760,7 +2760,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2760,7 +2760,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {
BUG_ON(!list_empty(&ordered_extent->list)); /* Logic error */ BUG_ON(!list_empty(&ordered_extent->list)); /* Logic error */
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0); btrfs_inode_safe_disk_i_size_write(inode, 0);
if (freespace_inode) if (freespace_inode)
trans = btrfs_join_transaction_spacecache(root); trans = btrfs_join_transaction_spacecache(root);
else else
...@@ -2770,8 +2770,8 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2770,8 +2770,8 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
trans = NULL; trans = NULL;
goto out; goto out;
} }
trans->block_rsv = &BTRFS_I(inode)->block_rsv; trans->block_rsv = &inode->block_rsv;
ret = btrfs_update_inode_fallback(trans, root, inode); ret = btrfs_update_inode_fallback(trans, root, &inode->vfs_inode);
if (ret) /* -ENOMEM or corruption */ if (ret) /* -ENOMEM or corruption */
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
...@@ -2790,13 +2790,13 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2790,13 +2790,13 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
goto out; goto out;
} }
trans->block_rsv = &BTRFS_I(inode)->block_rsv; trans->block_rsv = &inode->block_rsv;
if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags)) if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags))
compress_type = ordered_extent->compress_type; compress_type = ordered_extent->compress_type;
if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) {
BUG_ON(compress_type); BUG_ON(compress_type);
ret = btrfs_mark_extent_written(trans, BTRFS_I(inode), ret = btrfs_mark_extent_written(trans, inode,
ordered_extent->file_offset, ordered_extent->file_offset,
ordered_extent->file_offset + ordered_extent->file_offset +
logical_len); logical_len);
...@@ -2810,8 +2810,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2810,8 +2810,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
ordered_extent->disk_num_bytes); ordered_extent->disk_num_bytes);
} }
} }
unpin_extent_cache(&BTRFS_I(inode)->extent_tree, unpin_extent_cache(&inode->extent_tree, ordered_extent->file_offset,
ordered_extent->file_offset,
ordered_extent->num_bytes, trans->transid); ordered_extent->num_bytes, trans->transid);
if (ret < 0) { if (ret < 0) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -2831,19 +2830,19 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2831,19 +2830,19 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
*/ */
if ((clear_bits & EXTENT_DELALLOC_NEW) && if ((clear_bits & EXTENT_DELALLOC_NEW) &&
!test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags)) !test_bit(BTRFS_ORDERED_TRUNCATED, &ordered_extent->flags))
clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, clear_extent_bit(&inode->io_tree, start, end,
EXTENT_DELALLOC_NEW | EXTENT_ADD_INODE_BYTES, EXTENT_DELALLOC_NEW | EXTENT_ADD_INODE_BYTES,
0, 0, &cached_state); 0, 0, &cached_state);
btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), 0); btrfs_inode_safe_disk_i_size_write(inode, 0);
ret = btrfs_update_inode_fallback(trans, root, inode); ret = btrfs_update_inode_fallback(trans, root, &inode->vfs_inode);
if (ret) { /* -ENOMEM or corruption */ if (ret) { /* -ENOMEM or corruption */
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
ret = 0; ret = 0;
out: out:
clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, clear_bits, clear_extent_bit(&inode->io_tree, start, end, clear_bits,
(clear_bits & EXTENT_LOCKED) ? 1 : 0, 0, (clear_bits & EXTENT_LOCKED) ? 1 : 0, 0,
&cached_state); &cached_state);
...@@ -2858,7 +2857,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2858,7 +2857,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
clear_extent_uptodate(io_tree, unwritten_start, end, NULL); clear_extent_uptodate(io_tree, unwritten_start, end, NULL);
/* Drop the cache for the part of the extent we didn't write. */ /* Drop the cache for the part of the extent we didn't write. */
btrfs_drop_extent_cache(BTRFS_I(inode), unwritten_start, end, 0); btrfs_drop_extent_cache(inode, unwritten_start, end, 0);
/* /*
* If the ordered extent had an IOERR or something else went * If the ordered extent had an IOERR or something else went
...@@ -2893,7 +2892,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2893,7 +2892,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
* This needs to be done to make sure anybody waiting knows we are done * This needs to be done to make sure anybody waiting knows we are done
* updating everything for this ordered extent. * updating everything for this ordered extent.
*/ */
btrfs_remove_ordered_extent(BTRFS_I(inode), ordered_extent); btrfs_remove_ordered_extent(inode, ordered_extent);
/* once for us */ /* once for us */
btrfs_put_ordered_extent(ordered_extent); btrfs_put_ordered_extent(ordered_extent);
......
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