[1/2] Btrfs: use cached state when dirtying pages during buffered write
diff mbox

Message ID 20171031185540.30649-1-fdmanana@kernel.org
State New
Headers show

Commit Message

Filipe Manana Oct. 31, 2017, 6:55 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

During a buffered IO write, we can have an extent state that we got when
we locked the range (if the range starts at an offset lower than eof), so
always pass it to btrfs_dirty_pages() so that setting the delalloc bit
in the range does not need to do a full search in the inode's io tree,
saving time and reducing the amount of time we hold the io tree's lock.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba Nov. 6, 2017, 3:50 p.m. UTC | #1
On Tue, Oct 31, 2017 at 06:55:40PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> During a buffered IO write, we can have an extent state that we got when
> we locked the range (if the range starts at an offset lower than eof), so
> always pass it to btrfs_dirty_pages() so that setting the delalloc bit
> in the range does not need to do a full search in the inode's io tree,
> saving time and reducing the amount of time we hold the io tree's lock.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: David Sterba <dsterba@suse.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index e0d15c0d1641..aaab1838cece 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1755,7 +1755,7 @@  static noinline ssize_t __btrfs_buffered_write(struct file *file,
 
 		if (copied > 0)
 			ret = btrfs_dirty_pages(inode, pages, dirty_pages,
-						pos, copied, NULL);
+						pos, copied, &cached_state);
 		if (need_unlock)
 			unlock_extent_cached(&BTRFS_I(inode)->io_tree,
 					     lockstart, lockend, &cached_state,