mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-02 04:14:14 +00:00
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>
This commit is contained in:
parent
f5daf2c780
commit
dda3245eca
2 changed files with 41 additions and 11 deletions
24
fs/btrfs/dedupe.h
Normal file
24
fs/btrfs/dedupe.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Fujitsu. All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public
|
||||||
|
* License v2 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public
|
||||||
|
* License along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 021110-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __BTRFS_DEDUPE__
|
||||||
|
#define __BTRFS_DEDUPE__
|
||||||
|
|
||||||
|
/* later in-band dedupe will expand this struct */
|
||||||
|
struct btrfs_dedupe_hash;
|
||||||
|
#endif
|
|
@ -60,6 +60,7 @@
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "props.h"
|
#include "props.h"
|
||||||
#include "qgroup.h"
|
#include "qgroup.h"
|
||||||
|
#include "dedupe.h"
|
||||||
|
|
||||||
struct btrfs_iget_args {
|
struct btrfs_iget_args {
|
||||||
struct btrfs_key *location;
|
struct btrfs_key *location;
|
||||||
|
@ -105,8 +106,9 @@ static int btrfs_truncate(struct inode *inode);
|
||||||
static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);
|
static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);
|
||||||
static noinline int cow_file_range(struct inode *inode,
|
static noinline int cow_file_range(struct inode *inode,
|
||||||
struct page *locked_page,
|
struct page *locked_page,
|
||||||
u64 start, u64 end, int *page_started,
|
u64 start, u64 end, u64 delalloc_end,
|
||||||
unsigned long *nr_written, int unlock);
|
int *page_started, unsigned long *nr_written,
|
||||||
|
int unlock, struct btrfs_dedupe_hash *hash);
|
||||||
static struct extent_map *create_pinned_em(struct inode *inode, u64 start,
|
static struct extent_map *create_pinned_em(struct inode *inode, u64 start,
|
||||||
u64 len, u64 orig_start,
|
u64 len, u64 orig_start,
|
||||||
u64 block_start, u64 block_len,
|
u64 block_start, u64 block_len,
|
||||||
|
@ -710,7 +712,10 @@ retry:
|
||||||
async_extent->start,
|
async_extent->start,
|
||||||
async_extent->start +
|
async_extent->start +
|
||||||
async_extent->ram_size - 1,
|
async_extent->ram_size - 1,
|
||||||
&page_started, &nr_written, 0);
|
async_extent->start +
|
||||||
|
async_extent->ram_size - 1,
|
||||||
|
&page_started, &nr_written, 0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
/* JDM XXX */
|
/* JDM XXX */
|
||||||
|
|
||||||
|
@ -923,9 +928,9 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start,
|
||||||
*/
|
*/
|
||||||
static noinline int cow_file_range(struct inode *inode,
|
static noinline int cow_file_range(struct inode *inode,
|
||||||
struct page *locked_page,
|
struct page *locked_page,
|
||||||
u64 start, u64 end, int *page_started,
|
u64 start, u64 end, u64 delalloc_end,
|
||||||
unsigned long *nr_written,
|
int *page_started, unsigned long *nr_written,
|
||||||
int unlock)
|
int unlock, struct btrfs_dedupe_hash *hash)
|
||||||
{
|
{
|
||||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
struct btrfs_root *root = BTRFS_I(inode)->root;
|
||||||
u64 alloc_hint = 0;
|
u64 alloc_hint = 0;
|
||||||
|
@ -1416,7 +1421,8 @@ out_check:
|
||||||
if (cow_start != (u64)-1) {
|
if (cow_start != (u64)-1) {
|
||||||
ret = cow_file_range(inode, locked_page,
|
ret = cow_file_range(inode, locked_page,
|
||||||
cow_start, found_key.offset - 1,
|
cow_start, found_key.offset - 1,
|
||||||
page_started, nr_written, 1);
|
end, page_started, nr_written, 1,
|
||||||
|
NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (!nolock && nocow)
|
if (!nolock && nocow)
|
||||||
btrfs_end_write_no_snapshoting(root);
|
btrfs_end_write_no_snapshoting(root);
|
||||||
|
@ -1499,8 +1505,8 @@ out_check:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cow_start != (u64)-1) {
|
if (cow_start != (u64)-1) {
|
||||||
ret = cow_file_range(inode, locked_page, cow_start, end,
|
ret = cow_file_range(inode, locked_page, cow_start, end, end,
|
||||||
page_started, nr_written, 1);
|
page_started, nr_written, 1, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -1559,8 +1565,8 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
|
||||||
ret = run_delalloc_nocow(inode, locked_page, start, end,
|
ret = run_delalloc_nocow(inode, locked_page, start, end,
|
||||||
page_started, 0, nr_written);
|
page_started, 0, nr_written);
|
||||||
} else if (!inode_need_compress(inode)) {
|
} else if (!inode_need_compress(inode)) {
|
||||||
ret = cow_file_range(inode, locked_page, start, end,
|
ret = cow_file_range(inode, locked_page, start, end, end,
|
||||||
page_started, nr_written, 1);
|
page_started, nr_written, 1, NULL);
|
||||||
} else {
|
} else {
|
||||||
set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
|
set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
|
||||||
&BTRFS_I(inode)->runtime_flags);
|
&BTRFS_I(inode)->runtime_flags);
|
||||||
|
|
Loading…
Add table
Reference in a new issue