aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r--fs/btrfs/ordered-data.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 81369827e514..966b413a33b8 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -67,7 +67,7 @@ static void ordered_data_tree_panic(struct inode *inode, int errno,
67{ 67{
68 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 68 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
69 btrfs_panic(fs_info, errno, "Inconsistency in ordered tree at offset " 69 btrfs_panic(fs_info, errno, "Inconsistency in ordered tree at offset "
70 "%llu\n", (unsigned long long)offset); 70 "%llu\n", offset);
71} 71}
72 72
73/* 73/*
@@ -205,6 +205,7 @@ static int __btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
205 entry->bytes_left = len; 205 entry->bytes_left = len;
206 entry->inode = igrab(inode); 206 entry->inode = igrab(inode);
207 entry->compress_type = compress_type; 207 entry->compress_type = compress_type;
208 entry->truncated_len = (u64)-1;
208 if (type != BTRFS_ORDERED_IO_DONE && type != BTRFS_ORDERED_COMPLETE) 209 if (type != BTRFS_ORDERED_IO_DONE && type != BTRFS_ORDERED_COMPLETE)
209 set_bit(type, &entry->flags); 210 set_bit(type, &entry->flags);
210 211
@@ -336,14 +337,12 @@ int btrfs_dec_test_first_ordered_pending(struct inode *inode,
336 *file_offset = dec_end; 337 *file_offset = dec_end;
337 if (dec_start > dec_end) { 338 if (dec_start > dec_end) {
338 printk(KERN_CRIT "bad ordering dec_start %llu end %llu\n", 339 printk(KERN_CRIT "bad ordering dec_start %llu end %llu\n",
339 (unsigned long long)dec_start, 340 dec_start, dec_end);
340 (unsigned long long)dec_end);
341 } 341 }
342 to_dec = dec_end - dec_start; 342 to_dec = dec_end - dec_start;
343 if (to_dec > entry->bytes_left) { 343 if (to_dec > entry->bytes_left) {
344 printk(KERN_CRIT "bad ordered accounting left %llu size %llu\n", 344 printk(KERN_CRIT "bad ordered accounting left %llu size %llu\n",
345 (unsigned long long)entry->bytes_left, 345 entry->bytes_left, to_dec);
346 (unsigned long long)to_dec);
347 } 346 }
348 entry->bytes_left -= to_dec; 347 entry->bytes_left -= to_dec;
349 if (!uptodate) 348 if (!uptodate)
@@ -403,8 +402,7 @@ have_entry:
403 402
404 if (io_size > entry->bytes_left) { 403 if (io_size > entry->bytes_left) {
405 printk(KERN_CRIT "bad ordered accounting left %llu size %llu\n", 404 printk(KERN_CRIT "bad ordered accounting left %llu size %llu\n",
406 (unsigned long long)entry->bytes_left, 405 entry->bytes_left, io_size);
407 (unsigned long long)io_size);
408 } 406 }
409 entry->bytes_left -= io_size; 407 entry->bytes_left -= io_size;
410 if (!uptodate) 408 if (!uptodate)
@@ -671,7 +669,7 @@ int btrfs_run_ordered_operations(struct btrfs_trans_handle *trans,
671 INIT_LIST_HEAD(&splice); 669 INIT_LIST_HEAD(&splice);
672 INIT_LIST_HEAD(&works); 670 INIT_LIST_HEAD(&works);
673 671
674 mutex_lock(&root->fs_info->ordered_operations_mutex); 672 mutex_lock(&root->fs_info->ordered_extent_flush_mutex);
675 spin_lock(&root->fs_info->ordered_root_lock); 673 spin_lock(&root->fs_info->ordered_root_lock);
676 list_splice_init(&cur_trans->ordered_operations, &splice); 674 list_splice_init(&cur_trans->ordered_operations, &splice);
677 while (!list_empty(&splice)) { 675 while (!list_empty(&splice)) {
@@ -718,7 +716,7 @@ out:
718 list_del_init(&work->list); 716 list_del_init(&work->list);
719 btrfs_wait_and_free_delalloc_work(work); 717 btrfs_wait_and_free_delalloc_work(work);
720 } 718 }
721 mutex_unlock(&root->fs_info->ordered_operations_mutex); 719 mutex_unlock(&root->fs_info->ordered_extent_flush_mutex);
722 return ret; 720 return ret;
723} 721}
724 722
@@ -923,12 +921,16 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
923 struct btrfs_ordered_extent *test; 921 struct btrfs_ordered_extent *test;
924 int ret = 1; 922 int ret = 1;
925 923
926 if (ordered) 924 spin_lock_irq(&tree->lock);
925 if (ordered) {
927 offset = entry_end(ordered); 926 offset = entry_end(ordered);
928 else 927 if (test_bit(BTRFS_ORDERED_TRUNCATED, &ordered->flags))
928 offset = min(offset,
929 ordered->file_offset +
930 ordered->truncated_len);
931 } else {
929 offset = ALIGN(offset, BTRFS_I(inode)->root->sectorsize); 932 offset = ALIGN(offset, BTRFS_I(inode)->root->sectorsize);
930 933 }
931 spin_lock_irq(&tree->lock);
932 disk_i_size = BTRFS_I(inode)->disk_i_size; 934 disk_i_size = BTRFS_I(inode)->disk_i_size;
933 935
934 /* truncate file */ 936 /* truncate file */