aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2012-05-02 13:52:09 -0400
committerJosef Bacik <josef@redhat.com>2012-05-30 10:23:33 -0400
commit4e89915220e2f1341c757b610d0f0c3821f3a65f (patch)
tree5c70b0fab1d05a924ce316e8ba632b95b6555c16 /fs/btrfs/ordered-data.c
parentf60d16a8923201bb27ad7c09016abab2818cf8ce (diff)
Btrfs: do not check delalloc when updating disk_i_size
We are checking delalloc to see if it is ok to update the i_size. There are 2 cases it stops us from updating 1) If there is delalloc between our current disk_i_size and this ordered extent 2) If there is delalloc between our current ordered extent and the next ordered extent These tests are racy however since we can set delalloc for these ranges at any time. Also for the first case if we notice there is delalloc between disk_i_size and our ordered extent we will not update disk_i_size and assume that when that delalloc bit gets written out it will update everything properly. However if we crash before that we will have file extents outside of our i_size, which is not good, so this test is dangerous as well as racy. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r--fs/btrfs/ordered-data.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 9807750c625..9565c028916 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -751,7 +751,6 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
751 struct btrfs_ordered_extent *ordered) 751 struct btrfs_ordered_extent *ordered)
752{ 752{
753 struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree; 753 struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree;
754 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
755 u64 disk_i_size; 754 u64 disk_i_size;
756 u64 new_i_size; 755 u64 new_i_size;
757 u64 i_size_test; 756 u64 i_size_test;
@@ -785,14 +784,6 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
785 } 784 }
786 785
787 /* 786 /*
788 * we can't update the disk_isize if there are delalloc bytes
789 * between disk_i_size and this ordered extent
790 */
791 if (test_range_bit(io_tree, disk_i_size, offset - 1,
792 EXTENT_DELALLOC, 0, NULL)) {
793 goto out;
794 }
795 /*
796 * walk backward from this ordered extent to disk_i_size. 787 * walk backward from this ordered extent to disk_i_size.
797 * if we find an ordered extent then we can't update disk i_size 788 * if we find an ordered extent then we can't update disk i_size
798 * yet 789 * yet
@@ -853,15 +844,11 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
853 844
854 /* 845 /*
855 * i_size_test is the end of a region after this ordered 846 * i_size_test is the end of a region after this ordered
856 * extent where there are no ordered extents. As long as there 847 * extent where there are no ordered extents, we can safely set
857 * are no delalloc bytes in this area, it is safe to update 848 * disk_i_size to this.
858 * disk_i_size to the end of the region.
859 */ 849 */
860 if (i_size_test > offset && 850 if (i_size_test > offset)
861 !test_range_bit(io_tree, offset, i_size_test - 1,
862 EXTENT_DELALLOC, 0, NULL)) {
863 new_i_size = min_t(u64, i_size_test, i_size); 851 new_i_size = min_t(u64, i_size_test, i_size);
864 }
865 BTRFS_I(inode)->disk_i_size = new_i_size; 852 BTRFS_I(inode)->disk_i_size = new_i_size;
866 ret = 0; 853 ret = 0;
867out: 854out: