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>
Subject: [PATCH v4 18/18] btrfs: dedup: add per-file online dedup control
Date: Thu, 14 Jan 2016 13:57:34 +0800	[thread overview]
Message-ID: <1452751054-2365-19-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1452751054-2365-1-git-send-email-quwenruo@cn.fujitsu.com>

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

Introduce inode_need_dedup() to implement per-file online dedup control.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
---
 fs/btrfs/inode.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5a49afa..6d2f068 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -672,6 +672,21 @@ static void free_async_extent_pages(struct async_extent *async_extent)
 	async_extent->pages = NULL;
 }
 
+static inline int inode_need_dedup(struct inode *inode)
+{
+	struct btrfs_root *root = BTRFS_I(inode)->root;
+	struct btrfs_dedup_info *dedup_info = root->fs_info->dedup_info;
+
+	if (!dedup_info)
+		return 0;
+
+	if (BTRFS_I(inode)->flags & BTRFS_INODE_NODEDUP)
+		return 0;
+
+	return 1;
+}
+
+
 static int submit_dedup_extent(struct inode *inode, u64 start,
 			       unsigned long len, u64 disk_start, int dedup)
 {
@@ -1794,8 +1809,6 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
 {
 	int ret;
 	int force_cow = need_force_cow(inode, start, end);
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	struct btrfs_dedup_info *dedup_info = root->fs_info->dedup_info;
 
 	if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW && !force_cow) {
 		ret = run_delalloc_nocow(inode, locked_page, start, end,
@@ -1803,7 +1816,7 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
 	} else if (BTRFS_I(inode)->flags & BTRFS_INODE_PREALLOC && !force_cow) {
 		ret = run_delalloc_nocow(inode, locked_page, start, end,
 					 page_started, 0, nr_written);
-	} else if (!inode_need_compress(inode) && !dedup_info) {
+	} else if (!inode_need_compress(inode) && !inode_need_dedup(inode)) {
 		ret = cow_file_range(inode, locked_page, start, end,
 				      page_started, nr_written, 1);
 	} else {
-- 
2.7.0




      parent reply	other threads:[~2016-01-14  6:00 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-14  5:57 [PATCH v4 00/14][For 4.6] Btrfs: Add inband (write time) de-duplication framework Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 01/18] btrfs: dedup: Introduce dedup framework and its header Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 02/18] btrfs: dedup: Introduce function to initialize dedup info Qu Wenruo
2016-01-14 21:33   ` kbuild test robot
2016-01-14  5:57 ` [PATCH v4 03/18] btrfs: dedup: Introduce function to add hash into in-memory tree Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 04/18] btrfs: dedup: Introduce function to remove hash from " Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 05/18] btrfs: delayed-ref: Add support for atomic increasing extent ref Qu Wenruo
2016-01-14  9:56   ` Filipe Manana
2016-01-15  1:16     ` Qu Wenruo
2016-01-20  3:25       ` Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 06/18] btrfs: dedup: Introduce function to search for an existing hash Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 07/18] btrfs: dedup: Implement btrfs_dedup_calc_hash interface Qu Wenruo
2016-01-14 10:08   ` Filipe Manana
2016-01-15  1:41     ` Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 08/18] btrfs: ordered-extent: Add support for dedup Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 09/18] btrfs: dedup: Inband in-memory only de-duplication implement Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 10/18] btrfs: dedup: Add basic tree structure for on-disk dedup method Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 11/18] btrfs: dedup: Introduce interfaces to resume and cleanup dedup info Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 12/18] btrfs: dedup: Add support for on-disk hash search Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 13/18] btrfs: dedup: Add support to delete hash for on-disk backend Qu Wenruo
2016-01-14 10:19   ` Filipe Manana
2016-01-15  1:43     ` Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 14/18] btrfs: dedup: Add support for adding " Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 15/18] btrfs: dedup: Add ioctl for inband deduplication Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 16/18] btrfs: dedup: add an inode nodedup flag Qu Wenruo
2016-01-14  5:57 ` [PATCH v4 17/18] btrfs: dedup: add a property handler for online dedup Qu Wenruo
2016-01-14  9:56   ` Filipe Manana
2016-01-14 19:04     ` Darrick J. Wong
2016-01-15  1:37     ` Qu Wenruo
2016-01-15  9:19       ` Filipe Manana
2016-01-15  9:33         ` Qu Wenruo
2016-01-15 12:36         ` Duncan
2016-01-15 15:22           ` Filipe Manana
2016-01-16  2:53             ` Duncan
2016-01-14  5:57 ` Qu Wenruo [this message]

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=1452751054-2365-19-git-send-email-quwenruo@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --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.