All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH V12 05/14] btrfs: delayed-ref: Add support for increasing data ref under spinlock
Date: Thu, 30 Jun 2016 17:18:24 +0800	[thread overview]
Message-ID: <20160630091833.26975-7-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <20160630091833.26975-1-quwenruo@cn.fujitsu.com>

For in-band dedupe, btrfs needs to increase data ref with delayed_ref
locked, so add a new function btrfs_add_delayed_data_ref_lock() to
increase extent ref with delayed_refs already locked.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
---
 fs/btrfs/delayed-ref.c | 30 +++++++++++++++++++++++-------
 fs/btrfs/delayed-ref.h |  8 ++++++++
 2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 430b368..07474e8 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -805,6 +805,26 @@ free_ref:
 }
 
 /*
+ * Do real delayed data ref insert.
+ * Caller must hold delayed_refs->lock and allocation memory
+ * for dref,head_ref and record.
+ */
+void btrfs_add_delayed_data_ref_locked(struct btrfs_fs_info *fs_info,
+			struct btrfs_trans_handle *trans,
+			struct btrfs_delayed_data_ref *dref,
+			struct btrfs_delayed_ref_head *head_ref,
+			struct btrfs_qgroup_extent_record *qrecord,
+			u64 bytenr, u64 num_bytes, u64 parent, u64 ref_root,
+			u64 owner, u64 offset, u64 reserved, int action)
+{
+	head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node,
+			qrecord, bytenr, num_bytes, ref_root, reserved,
+			action, 1);
+	add_delayed_data_ref(fs_info, trans, head_ref, &dref->node, bytenr,
+			num_bytes, parent, ref_root, owner, offset, action);
+}
+
+/*
  * add a delayed data ref. it's similar to btrfs_add_delayed_tree_ref.
  */
 int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
@@ -849,13 +869,9 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
 	 * insert both the head node and the new ref without dropping
 	 * the spin lock
 	 */
-	head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
-					bytenr, num_bytes, ref_root, reserved,
-					action, 1);
-
-	add_delayed_data_ref(fs_info, trans, head_ref, &ref->node, bytenr,
-				   num_bytes, parent, ref_root, owner, offset,
-				   action);
+	btrfs_add_delayed_data_ref_locked(fs_info, trans, ref, head_ref, record,
+			bytenr, num_bytes, parent, ref_root, owner, offset,
+			reserved, action);
 	spin_unlock(&delayed_refs->lock);
 
 	return 0;
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index 5fca953..5830341 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -239,11 +239,19 @@ static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref)
 	}
 }
 
+struct btrfs_qgroup_extent_record;
 int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
 			       struct btrfs_trans_handle *trans,
 			       u64 bytenr, u64 num_bytes, u64 parent,
 			       u64 ref_root, int level, int action,
 			       struct btrfs_delayed_extent_op *extent_op);
+void btrfs_add_delayed_data_ref_locked(struct btrfs_fs_info *fs_info,
+			struct btrfs_trans_handle *trans,
+			struct btrfs_delayed_data_ref *dref,
+			struct btrfs_delayed_ref_head *head_ref,
+			struct btrfs_qgroup_extent_record *qrecord,
+			u64 bytenr, u64 num_bytes, u64 parent, u64 ref_root,
+			u64 owner, u64 offset, u64 reserved, int action);
 int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
 			       struct btrfs_trans_handle *trans,
 			       u64 bytenr, u64 num_bytes,
-- 
2.9.0




  parent reply	other threads:[~2016-06-30  9:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-30  9:18 [PATCH V12 00/14] Btrfs in-band de-duplication Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 01/14] btrfs: dedupe: Introduce dedupe framework and its header Qu Wenruo
2016-06-30  9:18 ` [PATCH] btrfs: dedupe: Introduce new reconfigure ioctl Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 02/14] btrfs: dedupe: Introduce function to initialize dedupe info Qu Wenruo
2016-06-30 12:13   ` kbuild test robot
2016-06-30  9:18 ` [PATCH V12 03/14] btrfs: dedupe: Introduce function to add hash into in-memory tree Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 04/14] btrfs: dedupe: Introduce function to remove hash from " Qu Wenruo
2016-06-30  9:18 ` Qu Wenruo [this message]
2016-06-30  9:18 ` [PATCH V12 06/14] btrfs: dedupe: Introduce function to search for an existing hash Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 07/14] btrfs: dedupe: Implement btrfs_dedupe_calc_hash interface Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 08/14] btrfs: ordered-extent: Add support for dedupe Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 09/14] btrfs: dedupe: Inband in-memory only de-duplication implement Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 10/14] btrfs: dedupe: Add ioctl for inband dedupelication Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 11/14] btrfs: relocation: Enhance error handling to avoid BUG_ON Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 12/14] btrfs: improve inode's outstanding_extents computation Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 13/14] btrfs: dedupe: fix false ENOSPC Qu Wenruo
2016-06-30  9:18 ` [PATCH V12 14/14] btrfs: dedupe: Introduce new reconfigure ioctl 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=20160630091833.26975-7-quwenruo@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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.