aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-07-29 11:20:47 -0400
committerChris Mason <chris.mason@fusionio.com>2013-09-01 08:04:38 -0400
commitc2790a2e2bc824084717fde031a8e0d370fc8650 (patch)
tree60e3b32889e7a7368a11ed80ca233d638ea245d7 /fs/btrfs/inode.c
parent8068a47e2a77ecae27cfd0298e8732756f565ed1 (diff)
Btrfs: cleanup arguments to extent_clear_unlock_delalloc
This patch removes the io_tree argument for extent_clear_unlock_delalloc since we always use &BTRFS_I(inode)->io_tree, and it separates out the extent tree operations from the page operations. This way we just pass in the extent bits we want to clear and then pass in the operations we want done to the pages. This is because I'm going to fix what extent bits we clear in some cases and rather than add a bunch of new flags we'll just use the actual extent bits we want to clear. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c162
1 files changed, 65 insertions, 97 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b47330c8e02c..d6c915d82b4a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -489,13 +489,13 @@ cont:
489 * we don't need to create any more async work items. 489 * we don't need to create any more async work items.
490 * Unlock and free up our temp pages. 490 * Unlock and free up our temp pages.
491 */ 491 */
492 extent_clear_unlock_delalloc(inode, 492 extent_clear_unlock_delalloc(inode, start, end, NULL,
493 &BTRFS_I(inode)->io_tree, 493 EXTENT_DIRTY |
494 start, end, NULL, 494 EXTENT_DELALLOC,
495 EXTENT_CLEAR_UNLOCK_PAGE | EXTENT_CLEAR_DIRTY | 495 PAGE_UNLOCK |
496 EXTENT_CLEAR_DELALLOC | 496 PAGE_CLEAR_DIRTY |
497 EXTENT_SET_WRITEBACK | EXTENT_END_WRITEBACK); 497 PAGE_SET_WRITEBACK |
498 498 PAGE_END_WRITEBACK);
499 btrfs_end_transaction(trans, root); 499 btrfs_end_transaction(trans, root);
500 goto free_pages_out; 500 goto free_pages_out;
501 } 501 }
@@ -592,13 +592,10 @@ free_pages_out:
592 goto out; 592 goto out;
593 593
594cleanup_and_out: 594cleanup_and_out:
595 extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree, 595 extent_clear_unlock_delalloc(inode, start, end, NULL,
596 start, end, NULL, 596 EXTENT_DIRTY | EXTENT_DELALLOC,
597 EXTENT_CLEAR_UNLOCK_PAGE | 597 PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
598 EXTENT_CLEAR_DIRTY | 598 PAGE_SET_WRITEBACK | PAGE_END_WRITEBACK);
599 EXTENT_CLEAR_DELALLOC |
600 EXTENT_SET_WRITEBACK |
601 EXTENT_END_WRITEBACK);
602 if (!trans || IS_ERR(trans)) 599 if (!trans || IS_ERR(trans))
603 btrfs_error(root->fs_info, ret, "Failed to join transaction"); 600 btrfs_error(root->fs_info, ret, "Failed to join transaction");
604 else 601 else
@@ -770,16 +767,12 @@ retry:
770 /* 767 /*
771 * clear dirty, set writeback and unlock the pages. 768 * clear dirty, set writeback and unlock the pages.
772 */ 769 */
773 extent_clear_unlock_delalloc(inode, 770 extent_clear_unlock_delalloc(inode, async_extent->start,
774 &BTRFS_I(inode)->io_tree,
775 async_extent->start,
776 async_extent->start + 771 async_extent->start +
777 async_extent->ram_size - 1, 772 async_extent->ram_size - 1,
778 NULL, EXTENT_CLEAR_UNLOCK_PAGE | 773 NULL, EXTENT_LOCKED | EXTENT_DELALLOC |
779 EXTENT_CLEAR_UNLOCK | 774 EXTENT_DIRTY, PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
780 EXTENT_CLEAR_DELALLOC | 775 PAGE_SET_WRITEBACK);
781 EXTENT_CLEAR_DIRTY | EXTENT_SET_WRITEBACK);
782
783 ret = btrfs_submit_compressed_write(inode, 776 ret = btrfs_submit_compressed_write(inode,
784 async_extent->start, 777 async_extent->start,
785 async_extent->ram_size, 778 async_extent->ram_size,
@@ -798,16 +791,13 @@ out:
798out_free_reserve: 791out_free_reserve:
799 btrfs_free_reserved_extent(root, ins.objectid, ins.offset); 792 btrfs_free_reserved_extent(root, ins.objectid, ins.offset);
800out_free: 793out_free:
801 extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree, 794 extent_clear_unlock_delalloc(inode, async_extent->start,
802 async_extent->start,
803 async_extent->start + 795 async_extent->start +
804 async_extent->ram_size - 1, 796 async_extent->ram_size - 1,
805 NULL, EXTENT_CLEAR_UNLOCK_PAGE | 797 NULL, EXTENT_LOCKED | EXTENT_DELALLOC |
806 EXTENT_CLEAR_UNLOCK | 798 EXTENT_DIRTY, PAGE_UNLOCK |
807 EXTENT_CLEAR_DELALLOC | 799 PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK |
808 EXTENT_CLEAR_DIRTY | 800 PAGE_END_WRITEBACK);
809 EXTENT_SET_WRITEBACK |
810 EXTENT_END_WRITEBACK);
811 kfree(async_extent); 801 kfree(async_extent);
812 goto again; 802 goto again;
813} 803}
@@ -892,15 +882,11 @@ static noinline int __cow_file_range(struct btrfs_trans_handle *trans,
892 ret = cow_file_range_inline(trans, root, inode, 882 ret = cow_file_range_inline(trans, root, inode,
893 start, end, 0, 0, NULL); 883 start, end, 0, 0, NULL);
894 if (ret == 0) { 884 if (ret == 0) {
895 extent_clear_unlock_delalloc(inode, 885 extent_clear_unlock_delalloc(inode, start, end, NULL,
896 &BTRFS_I(inode)->io_tree, 886 EXTENT_LOCKED | EXTENT_DELALLOC |
897 start, end, NULL, 887 EXTENT_DIRTY, PAGE_UNLOCK |
898 EXTENT_CLEAR_UNLOCK_PAGE | 888 PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK |
899 EXTENT_CLEAR_UNLOCK | 889 PAGE_END_WRITEBACK);
900 EXTENT_CLEAR_DELALLOC |
901 EXTENT_CLEAR_DIRTY |
902 EXTENT_SET_WRITEBACK |
903 EXTENT_END_WRITEBACK);
904 890
905 *nr_written = *nr_written + 891 *nr_written = *nr_written +
906 (end - start + PAGE_CACHE_SIZE) / PAGE_CACHE_SIZE; 892 (end - start + PAGE_CACHE_SIZE) / PAGE_CACHE_SIZE;
@@ -990,13 +976,13 @@ static noinline int __cow_file_range(struct btrfs_trans_handle *trans,
990 * Do set the Private2 bit so we know this page was properly 976 * Do set the Private2 bit so we know this page was properly
991 * setup for writepage 977 * setup for writepage
992 */ 978 */
993 op = unlock ? EXTENT_CLEAR_UNLOCK_PAGE : 0; 979 op = unlock ? PAGE_UNLOCK : 0;
994 op |= EXTENT_CLEAR_UNLOCK | EXTENT_CLEAR_DELALLOC | 980 op |= PAGE_SET_PRIVATE2;
995 EXTENT_SET_PRIVATE2;
996 981
997 extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree, 982 extent_clear_unlock_delalloc(inode, start,
998 start, start + ram_size - 1, 983 start + ram_size - 1, locked_page,
999 locked_page, op); 984 EXTENT_LOCKED | EXTENT_DELALLOC,
985 op);
1000 disk_num_bytes -= cur_alloc_size; 986 disk_num_bytes -= cur_alloc_size;
1001 num_bytes -= cur_alloc_size; 987 num_bytes -= cur_alloc_size;
1002 alloc_hint = ins.objectid + ins.offset; 988 alloc_hint = ins.objectid + ins.offset;
@@ -1008,16 +994,11 @@ out:
1008out_reserve: 994out_reserve:
1009 btrfs_free_reserved_extent(root, ins.objectid, ins.offset); 995 btrfs_free_reserved_extent(root, ins.objectid, ins.offset);
1010out_unlock: 996out_unlock:
1011 extent_clear_unlock_delalloc(inode, 997 extent_clear_unlock_delalloc(inode, start, end, locked_page,
1012 &BTRFS_I(inode)->io_tree, 998 EXTENT_LOCKED | EXTENT_DIRTY |
1013 start, end, locked_page, 999 EXTENT_DELALLOC, PAGE_UNLOCK |
1014 EXTENT_CLEAR_UNLOCK_PAGE | 1000 PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK |
1015 EXTENT_CLEAR_UNLOCK | 1001 PAGE_END_WRITEBACK);
1016 EXTENT_CLEAR_DELALLOC |
1017 EXTENT_CLEAR_DIRTY |
1018 EXTENT_SET_WRITEBACK |
1019 EXTENT_END_WRITEBACK);
1020
1021 goto out; 1002 goto out;
1022} 1003}
1023 1004
@@ -1033,15 +1014,12 @@ static noinline int cow_file_range(struct inode *inode,
1033 1014
1034 trans = btrfs_join_transaction(root); 1015 trans = btrfs_join_transaction(root);
1035 if (IS_ERR(trans)) { 1016 if (IS_ERR(trans)) {
1036 extent_clear_unlock_delalloc(inode, 1017 extent_clear_unlock_delalloc(inode, start, end, locked_page,
1037 &BTRFS_I(inode)->io_tree, 1018 EXTENT_LOCKED | EXTENT_DELALLOC |
1038 start, end, locked_page, 1019 EXTENT_DIRTY, PAGE_UNLOCK |
1039 EXTENT_CLEAR_UNLOCK_PAGE | 1020 PAGE_CLEAR_DIRTY |
1040 EXTENT_CLEAR_UNLOCK | 1021 PAGE_SET_WRITEBACK |
1041 EXTENT_CLEAR_DELALLOC | 1022 PAGE_END_WRITEBACK);
1042 EXTENT_CLEAR_DIRTY |
1043 EXTENT_SET_WRITEBACK |
1044 EXTENT_END_WRITEBACK);
1045 return PTR_ERR(trans); 1023 return PTR_ERR(trans);
1046 } 1024 }
1047 trans->block_rsv = &root->fs_info->delalloc_block_rsv; 1025 trans->block_rsv = &root->fs_info->delalloc_block_rsv;
@@ -1221,15 +1199,12 @@ static noinline int run_delalloc_nocow(struct inode *inode,
1221 1199
1222 path = btrfs_alloc_path(); 1200 path = btrfs_alloc_path();
1223 if (!path) { 1201 if (!path) {
1224 extent_clear_unlock_delalloc(inode, 1202 extent_clear_unlock_delalloc(inode, start, end, locked_page,
1225 &BTRFS_I(inode)->io_tree, 1203 EXTENT_LOCKED | EXTENT_DELALLOC |
1226 start, end, locked_page, 1204 EXTENT_DIRTY, PAGE_UNLOCK |
1227 EXTENT_CLEAR_UNLOCK_PAGE | 1205 PAGE_CLEAR_DIRTY |
1228 EXTENT_CLEAR_UNLOCK | 1206 PAGE_SET_WRITEBACK |
1229 EXTENT_CLEAR_DELALLOC | 1207 PAGE_END_WRITEBACK);
1230 EXTENT_CLEAR_DIRTY |
1231 EXTENT_SET_WRITEBACK |
1232 EXTENT_END_WRITEBACK);
1233 return -ENOMEM; 1208 return -ENOMEM;
1234 } 1209 }
1235 1210
@@ -1241,15 +1216,12 @@ static noinline int run_delalloc_nocow(struct inode *inode,
1241 trans = btrfs_join_transaction(root); 1216 trans = btrfs_join_transaction(root);
1242 1217
1243 if (IS_ERR(trans)) { 1218 if (IS_ERR(trans)) {
1244 extent_clear_unlock_delalloc(inode, 1219 extent_clear_unlock_delalloc(inode, start, end, locked_page,
1245 &BTRFS_I(inode)->io_tree, 1220 EXTENT_LOCKED | EXTENT_DELALLOC |
1246 start, end, locked_page, 1221 EXTENT_DIRTY, PAGE_UNLOCK |
1247 EXTENT_CLEAR_UNLOCK_PAGE | 1222 PAGE_CLEAR_DIRTY |
1248 EXTENT_CLEAR_UNLOCK | 1223 PAGE_SET_WRITEBACK |
1249 EXTENT_CLEAR_DELALLOC | 1224 PAGE_END_WRITEBACK);
1250 EXTENT_CLEAR_DIRTY |
1251 EXTENT_SET_WRITEBACK |
1252 EXTENT_END_WRITEBACK);
1253 btrfs_free_path(path); 1225 btrfs_free_path(path);
1254 return PTR_ERR(trans); 1226 return PTR_ERR(trans);
1255 } 1227 }
@@ -1428,11 +1400,11 @@ out_check:
1428 } 1400 }
1429 } 1401 }
1430 1402
1431 extent_clear_unlock_delalloc(inode, &BTRFS_I(inode)->io_tree, 1403 extent_clear_unlock_delalloc(inode, cur_offset,
1432 cur_offset, cur_offset + num_bytes - 1, 1404 cur_offset + num_bytes - 1,
1433 locked_page, EXTENT_CLEAR_UNLOCK_PAGE | 1405 locked_page, EXTENT_LOCKED |
1434 EXTENT_CLEAR_UNLOCK | EXTENT_CLEAR_DELALLOC | 1406 EXTENT_DELALLOC, PAGE_UNLOCK |
1435 EXTENT_SET_PRIVATE2); 1407 PAGE_SET_PRIVATE2);
1436 cur_offset = extent_end; 1408 cur_offset = extent_end;
1437 if (cur_offset > end) 1409 if (cur_offset > end)
1438 break; 1410 break;
@@ -1460,16 +1432,12 @@ error:
1460 ret = err; 1432 ret = err;
1461 1433
1462 if (ret && cur_offset < end) 1434 if (ret && cur_offset < end)
1463 extent_clear_unlock_delalloc(inode, 1435 extent_clear_unlock_delalloc(inode, cur_offset, end,
1464 &BTRFS_I(inode)->io_tree, 1436 locked_page, EXTENT_LOCKED |
1465 cur_offset, end, locked_page, 1437 EXTENT_DELALLOC | EXTENT_DIRTY,
1466 EXTENT_CLEAR_UNLOCK_PAGE | 1438 PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
1467 EXTENT_CLEAR_UNLOCK | 1439 PAGE_SET_WRITEBACK |
1468 EXTENT_CLEAR_DELALLOC | 1440 PAGE_END_WRITEBACK);
1469 EXTENT_CLEAR_DIRTY |
1470 EXTENT_SET_WRITEBACK |
1471 EXTENT_END_WRITEBACK);
1472
1473 btrfs_free_path(path); 1441 btrfs_free_path(path);
1474 return ret; 1442 return ret;
1475} 1443}