All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Cc: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>,
	Chandan Rajendra <chandan@linux.vnet.ibm.com>,
	David Sterba <dsterba@suse.cz>
Subject: [PATCH v12.1 01/15] btrfs: expand cow_file_range() to support in-band dedup and subpage-blocksize
Date: Mon, 11 Jul 2016 11:05:29 +0800	[thread overview]
Message-ID: <20160711030543.30115-2-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <20160711030543.30115-1-quwenruo@cn.fujitsu.com>

From: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>

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>
---
 fs/btrfs/dedupe.h | 24 ++++++++++++++++++++++++
 fs/btrfs/inode.c  | 28 +++++++++++++++++-----------
 2 files changed, 41 insertions(+), 11 deletions(-)
 create mode 100644 fs/btrfs/dedupe.h

diff --git a/fs/btrfs/dedupe.h b/fs/btrfs/dedupe.h
new file mode 100644
index 0000000..83ebfe2
--- /dev/null
+++ b/fs/btrfs/dedupe.h
@@ -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
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index bf4319d..ef2b27e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -60,6 +60,7 @@
 #include "hash.h"
 #include "props.h"
 #include "qgroup.h"
+#include "dedupe.h"
 
 struct btrfs_iget_args {
 	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 noinline int cow_file_range(struct inode *inode,
 				   struct page *locked_page,
-				   u64 start, u64 end, int *page_started,
-				   unsigned long *nr_written, int unlock);
+				   u64 start, u64 end, u64 delalloc_end,
+				   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,
 					   u64 len, u64 orig_start,
 					   u64 block_start, u64 block_len,
@@ -710,7 +712,10 @@ retry:
 					     async_extent->start,
 					     async_extent->start +
 					     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 */
 
@@ -923,9 +928,9 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start,
  */
 static noinline int cow_file_range(struct inode *inode,
 				   struct page *locked_page,
-				   u64 start, u64 end, int *page_started,
-				   unsigned long *nr_written,
-				   int unlock)
+				   u64 start, u64 end, u64 delalloc_end,
+				   int *page_started, unsigned long *nr_written,
+				   int unlock, struct btrfs_dedupe_hash *hash)
 {
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	u64 alloc_hint = 0;
@@ -1416,7 +1421,8 @@ out_check:
 		if (cow_start != (u64)-1) {
 			ret = cow_file_range(inode, locked_page,
 					     cow_start, found_key.offset - 1,
-					     page_started, nr_written, 1);
+					     end, page_started, nr_written, 1,
+					     NULL);
 			if (ret) {
 				if (!nolock && nocow)
 					btrfs_end_write_no_snapshoting(root);
@@ -1499,8 +1505,8 @@ out_check:
 	}
 
 	if (cow_start != (u64)-1) {
-		ret = cow_file_range(inode, locked_page, cow_start, end,
-				     page_started, nr_written, 1);
+		ret = cow_file_range(inode, locked_page, cow_start, end, end,
+				     page_started, nr_written, 1, NULL);
 		if (ret)
 			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,
 					 page_started, 0, nr_written);
 	} else if (!inode_need_compress(inode)) {
-		ret = cow_file_range(inode, locked_page, start, end,
-				      page_started, nr_written, 1);
+		ret = cow_file_range(inode, locked_page, start, end, end,
+				      page_started, nr_written, 1, NULL);
 	} else {
 		set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
 			&BTRFS_I(inode)->runtime_flags);
-- 
2.9.0




  reply	other threads:[~2016-07-11  3:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-11  3:05 [PATCH v12.1 00/15] Btrfs in-band de-duplication Qu Wenruo
2016-07-11  3:05 ` Qu Wenruo [this message]
2016-07-11 16:41   ` [PATCH v12.1 01/15] btrfs: expand cow_file_range() to support in-band dedup and subpage-blocksize David Sterba
2016-07-12  4:50     ` Satoru Takeuchi
2016-07-19  6:40     ` Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 02/15] btrfs: dedupe: Introduce dedupe framework and its header Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 03/15] btrfs: dedupe: Introduce function to initialize dedupe info Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 04/15] btrfs: dedupe: Introduce function to add hash into in-memory tree Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 05/15] btrfs: dedupe: Introduce function to remove hash from " Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 06/15] btrfs: delayed-ref: Add support for increasing data ref under spinlock Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 07/15] btrfs: dedupe: Introduce function to search for an existing hash Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 08/15] btrfs: dedupe: Implement btrfs_dedupe_calc_hash interface Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 09/15] btrfs: ordered-extent: Add support for dedupe Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 10/15] btrfs: dedupe: Inband in-memory only de-duplication implement Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 11/15] btrfs: dedupe: Add ioctl for inband dedupelication Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 12/15] btrfs: relocation: Enhance error handling to avoid BUG_ON Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 13/15] btrfs: improve inode's outstanding_extents computation Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 14/15] btrfs: dedupe: fix false ENOSPC Qu Wenruo
2016-07-11  3:05 ` [PATCH v12.1 15/15] btrfs: dedupe: Introduce new reconfigure ioctl Qu Wenruo
2016-07-11  3:08 ` [PATCH v12.1 00/15] Btrfs in-band de-duplication Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160711030543.30115-2-quwenruo@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=chandan@linux.vnet.ibm.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wangxg.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.