Commit 1ef30be1 authored by Josef Bacik's avatar Josef Bacik

Btrfs: do not call btrfs_update_inode in endio if nothing changed

In the DIO code we often don't update the i_disk_size because the i_size isn't
updated until after the DIO is completed, so basically we are allocating a path,
doing a search, and updating the inode item for no reason since nothing changed.
btrfs_ordered_update_i_size will return 1 if it didn't update i_disk_size, so
only run btrfs_update_inode if btrfs_ordered_update_i_size returns 0.  Thanks,
Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
parent 12ddb96c
...@@ -1769,9 +1769,12 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) ...@@ -1769,9 +1769,12 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end)
add_pending_csums(trans, inode, ordered_extent->file_offset, add_pending_csums(trans, inode, ordered_extent->file_offset,
&ordered_extent->list); &ordered_extent->list);
btrfs_ordered_update_i_size(inode, 0, ordered_extent); ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent);
ret = btrfs_update_inode(trans, root, inode); if (!ret) {
BUG_ON(ret); ret = btrfs_update_inode(trans, root, inode);
BUG_ON(ret);
}
ret = 0;
out: out:
if (nolock) { if (nolock) {
if (trans) if (trans)
...@@ -5865,8 +5868,10 @@ static void btrfs_endio_direct_write(struct bio *bio, int err) ...@@ -5865,8 +5868,10 @@ static void btrfs_endio_direct_write(struct bio *bio, int err)
} }
add_pending_csums(trans, inode, ordered->file_offset, &ordered->list); add_pending_csums(trans, inode, ordered->file_offset, &ordered->list);
btrfs_ordered_update_i_size(inode, 0, ordered); ret = btrfs_ordered_update_i_size(inode, 0, ordered);
btrfs_update_inode(trans, root, inode); if (!ret)
btrfs_update_inode(trans, root, inode);
ret = 0;
out_unlock: out_unlock:
unlock_extent_cached(&BTRFS_I(inode)->io_tree, ordered->file_offset, unlock_extent_cached(&BTRFS_I(inode)->io_tree, ordered->file_offset,
ordered->file_offset + ordered->len - 1, ordered->file_offset + ordered->len - 1,
......
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