diff options
author | Filipe Manana <fdmanana@suse.com> | 2014-10-10 04:43:11 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-11-20 20:14:28 -0500 |
commit | 728404dacfddb5364d7256d821a2ea482159cbe7 (patch) | |
tree | adb45931cbe6104ad888f4cc2d43aa0951f8b8d0 /fs/btrfs/ordered-data.c | |
parent | 075bdbdbe9f21d68950ba5b187f80a4a23105365 (diff) |
Btrfs: add helper btrfs_fdatawrite_range
To avoid duplicating this double filemap_fdatawrite_range() call for
inodes with async extents (compressed writes) so often.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r-- | fs/btrfs/ordered-data.c | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index ac734ec4cc20..1401b1af4f06 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
@@ -725,30 +725,10 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len) | |||
725 | /* start IO across the range first to instantiate any delalloc | 725 | /* start IO across the range first to instantiate any delalloc |
726 | * extents | 726 | * extents |
727 | */ | 727 | */ |
728 | ret = filemap_fdatawrite_range(inode->i_mapping, start, orig_end); | 728 | ret = btrfs_fdatawrite_range(inode, start, orig_end); |
729 | if (ret) | 729 | if (ret) |
730 | return ret; | 730 | return ret; |
731 | /* | 731 | |
732 | * So with compression we will find and lock a dirty page and clear the | ||
733 | * first one as dirty, setup an async extent, and immediately return | ||
734 | * with the entire range locked but with nobody actually marked with | ||
735 | * writeback. So we can't just filemap_write_and_wait_range() and | ||
736 | * expect it to work since it will just kick off a thread to do the | ||
737 | * actual work. So we need to call filemap_fdatawrite_range _again_ | ||
738 | * since it will wait on the page lock, which won't be unlocked until | ||
739 | * after the pages have been marked as writeback and so we're good to go | ||
740 | * from there. We have to do this otherwise we'll miss the ordered | ||
741 | * extents and that results in badness. Please Josef, do not think you | ||
742 | * know better and pull this out at some point in the future, it is | ||
743 | * right and you are wrong. | ||
744 | */ | ||
745 | if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT, | ||
746 | &BTRFS_I(inode)->runtime_flags)) { | ||
747 | ret = filemap_fdatawrite_range(inode->i_mapping, start, | ||
748 | orig_end); | ||
749 | if (ret) | ||
750 | return ret; | ||
751 | } | ||
752 | ret = filemap_fdatawait_range(inode->i_mapping, start, orig_end); | 732 | ret = filemap_fdatawait_range(inode->i_mapping, start, orig_end); |
753 | if (ret) | 733 | if (ret) |
754 | return ret; | 734 | return ret; |