a | b | |
---|
0 | 0 | | diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c |
---|
... | |
---|
1 | | - | index 3f180b857e20..eea7d68fdcf2 100644 |
---|
| 1 | + | index 3f180b857e20..1e7f2e2ba4f0 100644 |
---|
... | |
---|
2 | 2 | | --- a/fs/btrfs/inode.c |
---|
3 | 3 | | +++ b/fs/btrfs/inode.c |
---|
... | |
---|
4 | | - | @@ -2928,7 +2928,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) |
---|
4 | | - | int compress_type = 0; |
---|
4 | | - | int ret = 0; |
---|
4 | | - | u64 logical_len = ordered_extent->len; |
---|
4 | | - | - bool nolock; |
---|
4 | | - | + bool nolock = false; |
---|
4 | | - | bool truncated = false; |
---|
4 | | - | bool range_locked = false; |
---|
4 | | - | bool clear_new_delalloc_bytes = false; |
---|
4 | | - | @@ -2939,7 +2939,16 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) |
---|
4 | | - | !test_bit(BTRFS_ORDERED_DIRECT, &ordered_extent->flags)) |
---|
4 | | - | clear_new_delalloc_bytes = true; |
---|
| 4 | + | @@ -2912,6 +2912,26 @@ static void btrfs_release_delalloc_bytes(struct btrfs_fs_info *fs_info, |
---|
| 4 | + | btrfs_put_block_group(cache); |
---|
| 4 | + | } |
---|
... | |
---|
16 | 16 | | |
---|
... | |
---|
17 | | - | - nolock = btrfs_is_free_space_inode(BTRFS_I(inode)); |
---|
17 | | - | + if (btrfs_is_free_space_inode(BTRFS_I(inode))) { |
---|
17 | | - | + nolock = true; |
---|
17 | | - | + } else if (btrfs_test_opt(fs_info, FLUSHONCOMMIT)) { |
---|
17 | | - | + spin_lock(&fs_info->trans_lock); |
---|
17 | | - | + if (fs_info->running_transaction && |
---|
17 | | - | + (fs_info->running_transaction->state >= |
---|
17 | | - | + TRANS_STATE_COMMIT_START)) |
---|
17 | | - | + nolock = true; |
---|
17 | | - | + spin_unlock(&fs_info->trans_lock); |
---|
17 | | - | + } |
---|
| 17 | + | +static struct btrfs_trans_handle *finish_io_join_trans(struct inode *inode) |
---|
| 17 | + | +{ |
---|
| 17 | + | + struct btrfs_root *root = BTRFS_I(inode)->root; |
---|
| 17 | + | + bool nolock = false; |
---|
| 17 | + | + |
---|
| 17 | + | + if (btrfs_is_free_space_inode(BTRFS_I(inode))) { |
---|
| 17 | + | + nolock = true; |
---|
| 17 | + | + } else if (btrfs_test_opt(fs_info, FLUSHONCOMMIT)) { |
---|
| 17 | + | + spin_lock(&fs_info->trans_lock); |
---|
| 17 | + | + if (fs_info->running_transaction) |
---|
| 17 | + | + nolock = true; |
---|
| 17 | + | + spin_unlock(&fs_info->trans_lock); |
---|
| 17 | + | + } |
---|
| 17 | + | + |
---|
| 17 | + | + if (nolock) |
---|
| 17 | + | + return btrfs_join_transaction_nolock(root); |
---|
| 17 | + | + |
---|
| 17 | + | + return btrfs_join_transaction(root); |
---|
| 17 | + | +} |
---|
| 17 | + | + |
---|
| 17 | + | /* as ordered data IO finishes, this gets called so we can finish |
---|
| 17 | + | * an ordered extent if the range of bytes in the file it covers are |
---|
| 17 | + | * fully written. |
---|
| 17 | + | @@ -2928,7 +2948,6 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) |
---|
| 17 | + | int compress_type = 0; |
---|
| 17 | + | int ret = 0; |
---|
| 17 | + | u64 logical_len = ordered_extent->len; |
---|
| 17 | + | - bool nolock; |
---|
| 17 | + | bool truncated = false; |
---|
| 17 | + | bool range_locked = false; |
---|
| 17 | + | bool clear_new_delalloc_bytes = false; |
---|
| 17 | + | @@ -2939,8 +2958,6 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) |
---|
| 17 | + | !test_bit(BTRFS_ORDERED_DIRECT, &ordered_extent->flags)) |
---|
| 17 | + | clear_new_delalloc_bytes = true; |
---|
... | |
---|
28 | 28 | | |
---|
... | |
---|
29 | | - | if (test_bit(BTRFS_ORDERED_IOERR, &ordered_extent->flags)) { |
---|
29 | | - | ret = -EIO; |
---|
| 29 | + | - nolock = btrfs_is_free_space_inode(BTRFS_I(inode)); |
---|
| 29 | + | - |
---|
| 29 | + | if (test_bit(BTRFS_ORDERED_IOERR, &ordered_extent->flags)) { |
---|
| 29 | + | ret = -EIO; |
---|
| 29 | + | goto out; |
---|
| 29 | + | @@ -2970,10 +2987,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) |
---|
| 29 | + | btrfs_qgroup_free_data(inode, NULL, ordered_extent->file_offset, |
---|
| 29 | + | ordered_extent->len); |
---|
| 29 | + | btrfs_ordered_update_i_size(inode, 0, ordered_extent); |
---|
| 29 | + | - if (nolock) |
---|
| 29 | + | - trans = btrfs_join_transaction_nolock(root); |
---|
| 29 | + | - else |
---|
| 29 | + | - trans = btrfs_join_transaction(root); |
---|
| 29 | + | + trans = finish_io_join_trans(inode); |
---|
| 29 | + | if (IS_ERR(trans)) { |
---|
| 29 | + | ret = PTR_ERR(trans); |
---|
| 29 | + | trans = NULL; |
---|
| 29 | + | @@ -3005,10 +3019,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) |
---|
| 29 | + | EXTENT_DEFRAG, 0, 0, &cached_state); |
---|
| 29 | + | } |
---|
| 29 | + | |
---|
| 29 | + | - if (nolock) |
---|
| 29 | + | - trans = btrfs_join_transaction_nolock(root); |
---|
| 29 | + | - else |
---|
| 29 | + | - trans = btrfs_join_transaction(root); |
---|
| 29 | + | + trans = finish_io_join_trans(inode); |
---|
| 29 | + | if (IS_ERR(trans)) { |
---|
| 29 | + | ret = PTR_ERR(trans); |
---|
| 29 | + | trans = NULL; |
---|
... | |
---|
31 | 31 | | diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c |
---|
... | |
---|
32 | | - | index acdad6d658f5..42d756267e9a 100644 |
---|
| 32 | + | index acdad6d658f5..d776990fe8e5 100644 |
---|
... | |
---|
33 | 33 | | --- a/fs/btrfs/transaction.c |
---|
34 | 34 | | +++ b/fs/btrfs/transaction.c |
---|
35 | 35 | | @@ -1888,17 +1888,8 @@ static void btrfs_cleanup_pending_block_groups(struct btrfs_trans_handle *trans) |
---|
... | |
---|