All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edmund Nadolski <enadolski@suse.com>
To: enadolski@suse.com, jeffm@suse.com, linux-btrfs@vger.kernel.org,
	lufq.fnst@cn.fujitsu.com
Subject: [PATCH v2 13/13] btrfs: clean up extraneous computations in add_delayed_refs
Date: Wed, 28 Jun 2017 21:57:05 -0600	[thread overview]
Message-ID: <20170629035705.1589-14-enadolski@suse.com> (raw)
In-Reply-To: <20170629035705.1589-1-enadolski@suse.com>

Repeating the same computation in multiple places is not
necessary.

Signed-off-by: Edmund Nadolski <enadolski@suse.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 fs/btrfs/backref.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 5011b2f..7393a6f 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -764,7 +764,7 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
 	struct btrfs_key key;
 	struct btrfs_key tmp_op_key;
 	struct btrfs_key *op_key = NULL;
-	int sgn;
+	int count;
 	int ret = 0;
 
 	if (extent_op && extent_op->update_key) {
@@ -783,15 +783,15 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
 			WARN_ON(1);
 			continue;
 		case BTRFS_ADD_DELAYED_REF:
-			sgn = 1;
+			count = node->ref_mod;
 			break;
 		case BTRFS_DROP_DELAYED_REF:
-			sgn = -1;
+			count = node->ref_mod * -1;
 			break;
 		default:
 			BUG_ON(1);
 		}
-		*total_refs += (node->ref_mod * sgn);
+		*total_refs += count;
 		switch (node->type) {
 		case BTRFS_TREE_BLOCK_REF_KEY: {
 			/* NORMAL INDIRECT METADATA backref */
@@ -800,9 +800,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
 			ref = btrfs_delayed_node_to_tree_ref(node);
 			ret = add_indirect_ref(fs_info, preftrees, ref->root,
 					       &tmp_op_key, ref->level + 1,
-					       node->bytenr,
-					       node->ref_mod * sgn,
-					       sc, GFP_ATOMIC);
+					       node->bytenr, count, sc,
+					       GFP_ATOMIC);
 			break;
 		}
 		case BTRFS_SHARED_BLOCK_REF_KEY: {
@@ -811,9 +810,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
 
 			ref = btrfs_delayed_node_to_tree_ref(node);
 
-			ret = add_direct_ref(fs_info, preftrees,
-					     ref->level + 1, ref->parent,
-					     node->bytenr, node->ref_mod * sgn,
+			ret = add_direct_ref(fs_info, preftrees, ref->level + 1,
+					     ref->parent, node->bytenr, count,
 					     sc, GFP_ATOMIC);
 			break;
 		}
@@ -836,9 +834,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
 			}
 
 			ret = add_indirect_ref(fs_info, preftrees, ref->root,
-					       &key, 0, node->bytenr,
-					       node->ref_mod * sgn,
-					       sc, GFP_ATOMIC);
+					       &key, 0, node->bytenr, count, sc,
+					       GFP_ATOMIC);
 			break;
 		}
 		case BTRFS_SHARED_DATA_REF_KEY: {
@@ -847,10 +844,9 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
 
 			ref = btrfs_delayed_node_to_data_ref(node);
 
-			ret = add_direct_ref(fs_info, preftrees, 0,
-					     ref->parent, node->bytenr,
-					     node->ref_mod * sgn,
-					     sc, GFP_ATOMIC);
+			ret = add_direct_ref(fs_info, preftrees, 0, ref->parent,
+					     node->bytenr, count, sc,
+					     GFP_ATOMIC);
 			break;
 		}
 		default:
-- 
2.10.2


  parent reply	other threads:[~2017-06-29  3:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29  3:56 [PATCH v2 00/13] use rbtrees for preliminary backrefs Edmund Nadolski
2017-06-29  3:56 ` [PATCH v2 01/13] btrfs: struct-funcs, constify readers Edmund Nadolski
2017-06-29  3:56 ` [PATCH v2 02/13] btrfs: constify tracepoint arguments Edmund Nadolski
2017-06-29  3:56 ` [PATCH v2 03/13] btrfs: backref, constify some arguments Edmund Nadolski
2017-06-29  3:56 ` [PATCH v2 04/13] btrfs: backref, add unode_aux_to_inode_list helper Edmund Nadolski
2017-06-29  3:56 ` [PATCH v2 05/13] btrfs: backref, cleanup __ namespace abuse Edmund Nadolski
2017-06-29  3:56 ` [PATCH v2 06/13] btrfs: btrfs_check_shared should manage its own transaction Edmund Nadolski
2017-07-10 16:51   ` David Sterba
2017-06-29  3:56 ` [PATCH v2 07/13] btrfs: remove ref_tree implementation from backref.c Edmund Nadolski
2017-07-10 16:53   ` David Sterba
2017-06-29  3:57 ` [PATCH v2 08/13] btrfs: convert prelimary reference tracking to use rbtrees Edmund Nadolski
2017-07-10 16:59   ` David Sterba
2017-07-11 15:15   ` David Sterba
2017-07-11 23:12     ` Edmund Nadolski
2017-07-12 15:15       ` David Sterba
2017-06-29  3:57 ` [PATCH v2 09/13] btrfs: add a node counter to each of the rbtrees Edmund Nadolski
2017-06-29  3:57 ` [PATCH v2 10/13] btrfs: backref, add tracepoints for prelim_ref insertion and merging Edmund Nadolski
2017-07-11 17:29   ` David Sterba
2017-06-29  3:57 ` [PATCH v2 11/13] btrfs: add cond_resched() calls when resolving backrefs Edmund Nadolski
2017-06-29  3:57 ` [PATCH v2 12/13] btrfs: allow backref search checks for shared extents Edmund Nadolski
2017-06-29  3:57 ` Edmund Nadolski [this message]
2017-07-10 17:05 ` [PATCH v2 00/13] use rbtrees for preliminary backrefs David Sterba

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=20170629035705.1589-14-enadolski@suse.com \
    --to=enadolski@suse.com \
    --cc=jeffm@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lufq.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.