aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2016-07-19 04:50:36 -0400
committerDavid Sterba <dsterba@suse.com>2016-09-26 11:59:49 -0400
commitba8b04c1d4adbc66f3653e3de5bd6c74a9a003bf (patch)
tree0fb557927464d5888a77949675a890dbf93e029b
parent897a41b1167955bd543bb252fd3f06f5844f2177 (diff)
btrfs: extend btrfs_set_extent_delalloc and its friends to support in-band dedupe and subpage size patchset
Extend btrfs_set_extent_delalloc() and extent_clear_unlock_delalloc() parameters for both in-band dedupe and subpage sector size patchset. This should reduce conflict of both patchset and the effort to rebase them. Cc: Chandan Rajendra <chandan@linux.vnet.ibm.com> Cc: David Sterba <dsterba@suse.cz> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/extent_io.c2
-rw-r--r--fs/btrfs/extent_io.h2
-rw-r--r--fs/btrfs/file.c2
-rw-r--r--fs/btrfs/inode.c40
-rw-r--r--fs/btrfs/relocation.c2
-rw-r--r--fs/btrfs/tests/inode-tests.c12
7 files changed, 37 insertions, 25 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index ae496e41692a..176a61967a8a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3119,7 +3119,7 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput);
3119int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput, 3119int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput,
3120 int nr); 3120 int nr);
3121int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, 3121int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
3122 struct extent_state **cached_state); 3122 struct extent_state **cached_state, int dedupe);
3123int btrfs_create_subvol_root(struct btrfs_trans_handle *trans, 3123int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
3124 struct btrfs_root *new_root, 3124 struct btrfs_root *new_root,
3125 struct btrfs_root *parent_root, 3125 struct btrfs_root *parent_root,
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index f12a0f90d6e4..e26e3feca500 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1730,7 +1730,7 @@ out_failed:
1730} 1730}
1731 1731
1732void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end, 1732void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
1733 struct page *locked_page, 1733 u64 delalloc_end, struct page *locked_page,
1734 unsigned clear_bits, 1734 unsigned clear_bits,
1735 unsigned long page_ops) 1735 unsigned long page_ops)
1736{ 1736{
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 28cd88fccc7e..60536f3bf434 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -413,7 +413,7 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset,
413void extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end); 413void extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end);
414void extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end); 414void extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end);
415void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end, 415void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
416 struct page *locked_page, 416 u64 delalloc_end, struct page *locked_page,
417 unsigned bits_to_clear, 417 unsigned bits_to_clear,
418 unsigned long page_ops); 418 unsigned long page_ops);
419struct bio * 419struct bio *
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index fea31a4a6e36..f1f1ae6ff08b 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -503,7 +503,7 @@ int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode,
503 503
504 end_of_last_block = start_pos + num_bytes - 1; 504 end_of_last_block = start_pos + num_bytes - 1;
505 err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block, 505 err = btrfs_set_extent_delalloc(inode, start_pos, end_of_last_block,
506 cached); 506 cached, 0);
507 if (err) 507 if (err)
508 return err; 508 return err;
509 509
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e6811c42e41e..8c63752b0a96 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -560,8 +560,9 @@ cont:
560 * we don't need to create any more async work items. 560 * we don't need to create any more async work items.
561 * Unlock and free up our temp pages. 561 * Unlock and free up our temp pages.
562 */ 562 */
563 extent_clear_unlock_delalloc(inode, start, end, NULL, 563 extent_clear_unlock_delalloc(inode, start, end, end,
564 clear_flags, PAGE_UNLOCK | 564 NULL, clear_flags,
565 PAGE_UNLOCK |
565 PAGE_CLEAR_DIRTY | 566 PAGE_CLEAR_DIRTY |
566 PAGE_SET_WRITEBACK | 567 PAGE_SET_WRITEBACK |
567 page_error_op | 568 page_error_op |
@@ -837,6 +838,8 @@ retry:
837 extent_clear_unlock_delalloc(inode, async_extent->start, 838 extent_clear_unlock_delalloc(inode, async_extent->start,
838 async_extent->start + 839 async_extent->start +
839 async_extent->ram_size - 1, 840 async_extent->ram_size - 1,
841 async_extent->start +
842 async_extent->ram_size - 1,
840 NULL, EXTENT_LOCKED | EXTENT_DELALLOC, 843 NULL, EXTENT_LOCKED | EXTENT_DELALLOC,
841 PAGE_UNLOCK | PAGE_CLEAR_DIRTY | 844 PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
842 PAGE_SET_WRITEBACK); 845 PAGE_SET_WRITEBACK);
@@ -856,7 +859,8 @@ retry:
856 tree->ops->writepage_end_io_hook(p, start, end, 859 tree->ops->writepage_end_io_hook(p, start, end,
857 NULL, 0); 860 NULL, 0);
858 p->mapping = NULL; 861 p->mapping = NULL;
859 extent_clear_unlock_delalloc(inode, start, end, NULL, 0, 862 extent_clear_unlock_delalloc(inode, start, end, end,
863 NULL, 0,
860 PAGE_END_WRITEBACK | 864 PAGE_END_WRITEBACK |
861 PAGE_SET_ERROR); 865 PAGE_SET_ERROR);
862 free_async_extent_pages(async_extent); 866 free_async_extent_pages(async_extent);
@@ -873,6 +877,8 @@ out_free:
873 extent_clear_unlock_delalloc(inode, async_extent->start, 877 extent_clear_unlock_delalloc(inode, async_extent->start,
874 async_extent->start + 878 async_extent->start +
875 async_extent->ram_size - 1, 879 async_extent->ram_size - 1,
880 async_extent->start +
881 async_extent->ram_size - 1,
876 NULL, EXTENT_LOCKED | EXTENT_DELALLOC | 882 NULL, EXTENT_LOCKED | EXTENT_DELALLOC |
877 EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING, 883 EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING,
878 PAGE_UNLOCK | PAGE_CLEAR_DIRTY | 884 PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
@@ -966,7 +972,8 @@ static noinline int cow_file_range(struct inode *inode,
966 ret = cow_file_range_inline(root, inode, start, end, 0, 0, 972 ret = cow_file_range_inline(root, inode, start, end, 0, 0,
967 NULL); 973 NULL);
968 if (ret == 0) { 974 if (ret == 0) {
969 extent_clear_unlock_delalloc(inode, start, end, NULL, 975 extent_clear_unlock_delalloc(inode, start, end,
976 delalloc_end, NULL,
970 EXTENT_LOCKED | EXTENT_DELALLOC | 977 EXTENT_LOCKED | EXTENT_DELALLOC |
971 EXTENT_DEFRAG, PAGE_UNLOCK | 978 EXTENT_DEFRAG, PAGE_UNLOCK |
972 PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK | 979 PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK |
@@ -1062,7 +1069,8 @@ static noinline int cow_file_range(struct inode *inode,
1062 op |= PAGE_SET_PRIVATE2; 1069 op |= PAGE_SET_PRIVATE2;
1063 1070
1064 extent_clear_unlock_delalloc(inode, start, 1071 extent_clear_unlock_delalloc(inode, start,
1065 start + ram_size - 1, locked_page, 1072 start + ram_size - 1,
1073 delalloc_end, locked_page,
1066 EXTENT_LOCKED | EXTENT_DELALLOC, 1074 EXTENT_LOCKED | EXTENT_DELALLOC,
1067 op); 1075 op);
1068 disk_num_bytes -= cur_alloc_size; 1076 disk_num_bytes -= cur_alloc_size;
@@ -1079,7 +1087,8 @@ out_reserve:
1079 btrfs_dec_block_group_reservations(root->fs_info, ins.objectid); 1087 btrfs_dec_block_group_reservations(root->fs_info, ins.objectid);
1080 btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1); 1088 btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1);
1081out_unlock: 1089out_unlock:
1082 extent_clear_unlock_delalloc(inode, start, end, locked_page, 1090 extent_clear_unlock_delalloc(inode, start, end, delalloc_end,
1091 locked_page,
1083 EXTENT_LOCKED | EXTENT_DO_ACCOUNTING | 1092 EXTENT_LOCKED | EXTENT_DO_ACCOUNTING |
1084 EXTENT_DELALLOC | EXTENT_DEFRAG, 1093 EXTENT_DELALLOC | EXTENT_DEFRAG,
1085 PAGE_UNLOCK | PAGE_CLEAR_DIRTY | 1094 PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
@@ -1258,7 +1267,8 @@ static noinline int run_delalloc_nocow(struct inode *inode,
1258 1267
1259 path = btrfs_alloc_path(); 1268 path = btrfs_alloc_path();
1260 if (!path) { 1269 if (!path) {
1261 extent_clear_unlock_delalloc(inode, start, end, locked_page, 1270 extent_clear_unlock_delalloc(inode, start, end, end,
1271 locked_page,
1262 EXTENT_LOCKED | EXTENT_DELALLOC | 1272 EXTENT_LOCKED | EXTENT_DELALLOC |
1263 EXTENT_DO_ACCOUNTING | 1273 EXTENT_DO_ACCOUNTING |
1264 EXTENT_DEFRAG, PAGE_UNLOCK | 1274 EXTENT_DEFRAG, PAGE_UNLOCK |
@@ -1276,7 +1286,8 @@ static noinline int run_delalloc_nocow(struct inode *inode,
1276 trans = btrfs_join_transaction(root); 1286 trans = btrfs_join_transaction(root);
1277 1287
1278 if (IS_ERR(trans)) { 1288 if (IS_ERR(trans)) {
1279 extent_clear_unlock_delalloc(inode, start, end, locked_page, 1289 extent_clear_unlock_delalloc(inode, start, end, end,
1290 locked_page,
1280 EXTENT_LOCKED | EXTENT_DELALLOC | 1291 EXTENT_LOCKED | EXTENT_DELALLOC |
1281 EXTENT_DO_ACCOUNTING | 1292 EXTENT_DO_ACCOUNTING |
1282 EXTENT_DEFRAG, PAGE_UNLOCK | 1293 EXTENT_DEFRAG, PAGE_UNLOCK |
@@ -1490,7 +1501,7 @@ out_check:
1490 } 1501 }
1491 1502
1492 extent_clear_unlock_delalloc(inode, cur_offset, 1503 extent_clear_unlock_delalloc(inode, cur_offset,
1493 cur_offset + num_bytes - 1, 1504 cur_offset + num_bytes - 1, end,
1494 locked_page, EXTENT_LOCKED | 1505 locked_page, EXTENT_LOCKED |
1495 EXTENT_DELALLOC | 1506 EXTENT_DELALLOC |
1496 EXTENT_CLEAR_DATA_RESV, 1507 EXTENT_CLEAR_DATA_RESV,
@@ -1522,7 +1533,7 @@ error:
1522 ret = err; 1533 ret = err;
1523 1534
1524 if (ret && cur_offset < end) 1535 if (ret && cur_offset < end)
1525 extent_clear_unlock_delalloc(inode, cur_offset, end, 1536 extent_clear_unlock_delalloc(inode, cur_offset, end, end,
1526 locked_page, EXTENT_LOCKED | 1537 locked_page, EXTENT_LOCKED |
1527 EXTENT_DELALLOC | EXTENT_DEFRAG | 1538 EXTENT_DELALLOC | EXTENT_DEFRAG |
1528 EXTENT_DO_ACCOUNTING, PAGE_UNLOCK | 1539 EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
@@ -1988,7 +1999,7 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
1988} 1999}
1989 2000
1990int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, 2001int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
1991 struct extent_state **cached_state) 2002 struct extent_state **cached_state, int dedupe)
1992{ 2003{
1993 WARN_ON((end & (PAGE_SIZE - 1)) == 0); 2004 WARN_ON((end & (PAGE_SIZE - 1)) == 0);
1994 return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end, 2005 return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end,
@@ -2052,7 +2063,8 @@ again:
2052 goto out; 2063 goto out;
2053 } 2064 }
2054 2065
2055 btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state); 2066 btrfs_set_extent_delalloc(inode, page_start, page_end, &cached_state,
2067 0);
2056 ClearPageChecked(page); 2068 ClearPageChecked(page);
2057 set_page_dirty(page); 2069 set_page_dirty(page);
2058out: 2070out:
@@ -4757,7 +4769,7 @@ again:
4757 0, 0, &cached_state, GFP_NOFS); 4769 0, 0, &cached_state, GFP_NOFS);
4758 4770
4759 ret = btrfs_set_extent_delalloc(inode, block_start, block_end, 4771 ret = btrfs_set_extent_delalloc(inode, block_start, block_end,
4760 &cached_state); 4772 &cached_state, 0);
4761 if (ret) { 4773 if (ret) {
4762 unlock_extent_cached(io_tree, block_start, block_end, 4774 unlock_extent_cached(io_tree, block_start, block_end,
4763 &cached_state, GFP_NOFS); 4775 &cached_state, GFP_NOFS);
@@ -9054,7 +9066,7 @@ again:
9054 0, 0, &cached_state, GFP_NOFS); 9066 0, 0, &cached_state, GFP_NOFS);
9055 9067
9056 ret = btrfs_set_extent_delalloc(inode, page_start, end, 9068 ret = btrfs_set_extent_delalloc(inode, page_start, end,
9057 &cached_state); 9069 &cached_state, 0);
9058 if (ret) { 9070 if (ret) {
9059 unlock_extent_cached(io_tree, page_start, page_end, 9071 unlock_extent_cached(io_tree, page_start, page_end,
9060 &cached_state, GFP_NOFS); 9072 &cached_state, GFP_NOFS);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index c0c13dc6fe12..7d53f2acb09e 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3203,7 +3203,7 @@ static int relocate_file_extent_cluster(struct inode *inode,
3203 nr++; 3203 nr++;
3204 } 3204 }
3205 3205
3206 btrfs_set_extent_delalloc(inode, page_start, page_end, NULL); 3206 btrfs_set_extent_delalloc(inode, page_start, page_end, NULL, 0);
3207 set_page_dirty(page); 3207 set_page_dirty(page);
3208 3208
3209 unlock_extent(&BTRFS_I(inode)->io_tree, 3209 unlock_extent(&BTRFS_I(inode)->io_tree,
diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c
index 9f72aeda9220..0bf46808ce8f 100644
--- a/fs/btrfs/tests/inode-tests.c
+++ b/fs/btrfs/tests/inode-tests.c
@@ -968,7 +968,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
968 /* [BTRFS_MAX_EXTENT_SIZE] */ 968 /* [BTRFS_MAX_EXTENT_SIZE] */
969 BTRFS_I(inode)->outstanding_extents++; 969 BTRFS_I(inode)->outstanding_extents++;
970 ret = btrfs_set_extent_delalloc(inode, 0, BTRFS_MAX_EXTENT_SIZE - 1, 970 ret = btrfs_set_extent_delalloc(inode, 0, BTRFS_MAX_EXTENT_SIZE - 1,
971 NULL); 971 NULL, 0);
972 if (ret) { 972 if (ret) {
973 test_msg("btrfs_set_extent_delalloc returned %d\n", ret); 973 test_msg("btrfs_set_extent_delalloc returned %d\n", ret);
974 goto out; 974 goto out;
@@ -984,7 +984,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
984 BTRFS_I(inode)->outstanding_extents++; 984 BTRFS_I(inode)->outstanding_extents++;
985 ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE, 985 ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE,
986 BTRFS_MAX_EXTENT_SIZE + sectorsize - 1, 986 BTRFS_MAX_EXTENT_SIZE + sectorsize - 1,
987 NULL); 987 NULL, 0);
988 if (ret) { 988 if (ret) {
989 test_msg("btrfs_set_extent_delalloc returned %d\n", ret); 989 test_msg("btrfs_set_extent_delalloc returned %d\n", ret);
990 goto out; 990 goto out;
@@ -1019,7 +1019,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
1019 ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE >> 1, 1019 ret = btrfs_set_extent_delalloc(inode, BTRFS_MAX_EXTENT_SIZE >> 1,
1020 (BTRFS_MAX_EXTENT_SIZE >> 1) 1020 (BTRFS_MAX_EXTENT_SIZE >> 1)
1021 + sectorsize - 1, 1021 + sectorsize - 1,
1022 NULL); 1022 NULL, 0);
1023 if (ret) { 1023 if (ret) {
1024 test_msg("btrfs_set_extent_delalloc returned %d\n", ret); 1024 test_msg("btrfs_set_extent_delalloc returned %d\n", ret);
1025 goto out; 1025 goto out;
@@ -1042,7 +1042,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
1042 ret = btrfs_set_extent_delalloc(inode, 1042 ret = btrfs_set_extent_delalloc(inode,
1043 BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize, 1043 BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize,
1044 (BTRFS_MAX_EXTENT_SIZE << 1) + 3 * sectorsize - 1, 1044 (BTRFS_MAX_EXTENT_SIZE << 1) + 3 * sectorsize - 1,
1045 NULL); 1045 NULL, 0);
1046 if (ret) { 1046 if (ret) {
1047 test_msg("btrfs_set_extent_delalloc returned %d\n", ret); 1047 test_msg("btrfs_set_extent_delalloc returned %d\n", ret);
1048 goto out; 1048 goto out;
@@ -1060,7 +1060,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
1060 BTRFS_I(inode)->outstanding_extents++; 1060 BTRFS_I(inode)->outstanding_extents++;
1061 ret = btrfs_set_extent_delalloc(inode, 1061 ret = btrfs_set_extent_delalloc(inode,
1062 BTRFS_MAX_EXTENT_SIZE + sectorsize, 1062 BTRFS_MAX_EXTENT_SIZE + sectorsize,
1063 BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, NULL); 1063 BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, NULL, 0);
1064 if (ret) { 1064 if (ret) {
1065 test_msg("btrfs_set_extent_delalloc returned %d\n", ret); 1065 test_msg("btrfs_set_extent_delalloc returned %d\n", ret);
1066 goto out; 1066 goto out;
@@ -1097,7 +1097,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
1097 BTRFS_I(inode)->outstanding_extents++; 1097 BTRFS_I(inode)->outstanding_extents++;
1098 ret = btrfs_set_extent_delalloc(inode, 1098 ret = btrfs_set_extent_delalloc(inode,
1099 BTRFS_MAX_EXTENT_SIZE + sectorsize, 1099 BTRFS_MAX_EXTENT_SIZE + sectorsize,
1100 BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, NULL); 1100 BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, NULL, 0);
1101 if (ret) { 1101 if (ret) {
1102 test_msg("btrfs_set_extent_delalloc returned %d\n", ret); 1102 test_msg("btrfs_set_extent_delalloc returned %d\n", ret);
1103 goto out; 1103 goto out;