aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorWang Xiaoguang <wangxg.fnst@cn.fujitsu.com>2016-07-10 23:05:29 -0400
committerDavid Sterba <dsterba@suse.com>2016-07-26 07:52:25 -0400
commitdda3245eca18c73413a854a834c41fc770feb0dd (patch)
tree9004d9180ec0c8542257ae5859b6b1f51ff15fac /fs/btrfs/inode.c
parentf5daf2c780f2ddfddbf98f2eb668f026c4dd2e5d (diff)
btrfs: expand cow_file_range() to support in-band dedup and subpage-blocksize
Extract cow_file_range() new parameters for both in-band dedupe and subpage sector size patchset. This should make conflict of both patchset to minimal, and reduce the effort needed to rebase them. Cc: Chandan Rajendra <chandan@linux.vnet.ibm.com> Cc: David Sterba <dsterba@suse.cz> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index be854649c51b..0612231aaeba 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -60,6 +60,7 @@
60#include "hash.h" 60#include "hash.h"
61#include "props.h" 61#include "props.h"
62#include "qgroup.h" 62#include "qgroup.h"
63#include "dedupe.h"
63 64
64struct btrfs_iget_args { 65struct btrfs_iget_args {
65 struct btrfs_key *location; 66 struct btrfs_key *location;
@@ -105,8 +106,9 @@ static int btrfs_truncate(struct inode *inode);
105static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent); 106static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);
106static noinline int cow_file_range(struct inode *inode, 107static noinline int cow_file_range(struct inode *inode,
107 struct page *locked_page, 108 struct page *locked_page,
108 u64 start, u64 end, int *page_started, 109 u64 start, u64 end, u64 delalloc_end,
109 unsigned long *nr_written, int unlock); 110 int *page_started, unsigned long *nr_written,
111 int unlock, struct btrfs_dedupe_hash *hash);
110static struct extent_map *create_pinned_em(struct inode *inode, u64 start, 112static struct extent_map *create_pinned_em(struct inode *inode, u64 start,
111 u64 len, u64 orig_start, 113 u64 len, u64 orig_start,
112 u64 block_start, u64 block_len, 114 u64 block_start, u64 block_len,
@@ -710,7 +712,10 @@ retry:
710 async_extent->start, 712 async_extent->start,
711 async_extent->start + 713 async_extent->start +
712 async_extent->ram_size - 1, 714 async_extent->ram_size - 1,
713 &page_started, &nr_written, 0); 715 async_extent->start +
716 async_extent->ram_size - 1,
717 &page_started, &nr_written, 0,
718 NULL);
714 719
715 /* JDM XXX */ 720 /* JDM XXX */
716 721
@@ -923,9 +928,9 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start,
923 */ 928 */
924static noinline int cow_file_range(struct inode *inode, 929static noinline int cow_file_range(struct inode *inode,
925 struct page *locked_page, 930 struct page *locked_page,
926 u64 start, u64 end, int *page_started, 931 u64 start, u64 end, u64 delalloc_end,
927 unsigned long *nr_written, 932 int *page_started, unsigned long *nr_written,
928 int unlock) 933 int unlock, struct btrfs_dedupe_hash *hash)
929{ 934{
930 struct btrfs_root *root = BTRFS_I(inode)->root; 935 struct btrfs_root *root = BTRFS_I(inode)->root;
931 u64 alloc_hint = 0; 936 u64 alloc_hint = 0;
@@ -1416,7 +1421,8 @@ out_check:
1416 if (cow_start != (u64)-1) { 1421 if (cow_start != (u64)-1) {
1417 ret = cow_file_range(inode, locked_page, 1422 ret = cow_file_range(inode, locked_page,
1418 cow_start, found_key.offset - 1, 1423 cow_start, found_key.offset - 1,
1419 page_started, nr_written, 1); 1424 end, page_started, nr_written, 1,
1425 NULL);
1420 if (ret) { 1426 if (ret) {
1421 if (!nolock && nocow) 1427 if (!nolock && nocow)
1422 btrfs_end_write_no_snapshoting(root); 1428 btrfs_end_write_no_snapshoting(root);
@@ -1499,8 +1505,8 @@ out_check:
1499 } 1505 }
1500 1506
1501 if (cow_start != (u64)-1) { 1507 if (cow_start != (u64)-1) {
1502 ret = cow_file_range(inode, locked_page, cow_start, end, 1508 ret = cow_file_range(inode, locked_page, cow_start, end, end,
1503 page_started, nr_written, 1); 1509 page_started, nr_written, 1, NULL);
1504 if (ret) 1510 if (ret)
1505 goto error; 1511 goto error;
1506 } 1512 }
@@ -1559,8 +1565,8 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
1559 ret = run_delalloc_nocow(inode, locked_page, start, end, 1565 ret = run_delalloc_nocow(inode, locked_page, start, end,
1560 page_started, 0, nr_written); 1566 page_started, 0, nr_written);
1561 } else if (!inode_need_compress(inode)) { 1567 } else if (!inode_need_compress(inode)) {
1562 ret = cow_file_range(inode, locked_page, start, end, 1568 ret = cow_file_range(inode, locked_page, start, end, end,
1563 page_started, nr_written, 1); 1569 page_started, nr_written, 1, NULL);
1564 } else { 1570 } else {
1565 set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT, 1571 set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
1566 &BTRFS_I(inode)->runtime_flags); 1572 &BTRFS_I(inode)->runtime_flags);