diff options
author | Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com> | 2016-07-10 23:05:29 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-07-26 07:52:25 -0400 |
commit | dda3245eca18c73413a854a834c41fc770feb0dd (patch) | |
tree | 9004d9180ec0c8542257ae5859b6b1f51ff15fac /fs/btrfs | |
parent | f5daf2c780f2ddfddbf98f2eb668f026c4dd2e5d (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')
-rw-r--r-- | fs/btrfs/dedupe.h | 24 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 28 |
2 files changed, 41 insertions, 11 deletions
diff --git a/fs/btrfs/dedupe.h b/fs/btrfs/dedupe.h new file mode 100644 index 000000000000..83ebfe28da9e --- /dev/null +++ b/fs/btrfs/dedupe.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 Fujitsu. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public | ||
6 | * License v2 as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | * General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public | ||
14 | * License along with this program; if not, write to the | ||
15 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
16 | * Boston, MA 021110-1307, USA. | ||
17 | */ | ||
18 | |||
19 | #ifndef __BTRFS_DEDUPE__ | ||
20 | #define __BTRFS_DEDUPE__ | ||
21 | |||
22 | /* later in-band dedupe will expand this struct */ | ||
23 | struct btrfs_dedupe_hash; | ||
24 | #endif | ||
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 | ||
64 | struct btrfs_iget_args { | 65 | struct btrfs_iget_args { |
65 | struct btrfs_key *location; | 66 | struct btrfs_key *location; |
@@ -105,8 +106,9 @@ static int btrfs_truncate(struct inode *inode); | |||
105 | static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent); | 106 | static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent); |
106 | static noinline int cow_file_range(struct inode *inode, | 107 | static 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); | ||
110 | static struct extent_map *create_pinned_em(struct inode *inode, u64 start, | 112 | static 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 | */ |
924 | static noinline int cow_file_range(struct inode *inode, | 929 | static 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); |