diff mbox

[1/2] btrfs: provide enumeration for __merge_refs mode argument

Message ID 20170313203204.11857-2-enadolski@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

ednadolski@gmail.com March 13, 2017, 8:32 p.m. UTC
From: Edmund Nadolski <enadolski@suse.com>

Replace hardcoded numeric values for __merge_refs 'mode' argument
with descriptive constants.

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

Comments

David Sterba March 15, 2017, 2:47 p.m. UTC | #1
On Mon, Mar 13, 2017 at 02:32:03PM -0600, ednadolski@gmail.com wrote:
> @@ -809,14 +814,12 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
>  /*
>   * merge backrefs and adjust counts accordingly
>   *
> - * mode = 1: merge identical keys, if key is set
>   *    FIXME: if we add more keys in __add_prelim_ref, we can merge more here.
>   *           additionally, we could even add a key range for the blocks we
>   *           looked into to merge even more (-> replace unresolved refs by those
>   *           having a parent).

The 'FIXME' seems to refer to mode = 1, but now that you remove it, it's
not clear what it's referring to. Mentioning MERGE_IDENTICAL_KEYS would
be good.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 7699e16..e794b6e 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -26,6 +26,11 @@ 
 #include "delayed-ref.h"
 #include "locking.h"
 
+enum merge_mode {
+	MERGE_IDENTICAL_KEYS = 1,
+	MERGE_IDENTICAL_PARENTS,
+};
+
 /* Just an arbitrary number so we can be sure this happened */
 #define BACKREF_FOUND_SHARED 6
 
@@ -809,14 +814,12 @@  static int __add_missing_keys(struct btrfs_fs_info *fs_info,
 /*
  * merge backrefs and adjust counts accordingly
  *
- * mode = 1: merge identical keys, if key is set
  *    FIXME: if we add more keys in __add_prelim_ref, we can merge more here.
  *           additionally, we could even add a key range for the blocks we
  *           looked into to merge even more (-> replace unresolved refs by those
  *           having a parent).
- * mode = 2: merge identical parents
  */
-static void __merge_refs(struct list_head *head, int mode)
+static void __merge_refs(struct list_head *head, enum merge_mode mode)
 {
 	struct __prelim_ref *pos1;
 
@@ -829,7 +832,7 @@  static void __merge_refs(struct list_head *head, int mode)
 
 			if (!ref_for_same_block(ref1, ref2))
 				continue;
-			if (mode == 1) {
+			if (mode == MERGE_IDENTICAL_KEYS) {
 				if (!ref1->parent && ref2->parent)
 					swap(ref1, ref2);
 			} else {
@@ -1374,7 +1377,7 @@  static int find_parent_nodes(struct btrfs_trans_handle *trans,
 	if (ret)
 		goto out;
 
-	__merge_refs(&prefs, 1);
+	__merge_refs(&prefs, MERGE_IDENTICAL_KEYS);
 
 	ret = __resolve_indirect_refs(fs_info, path, time_seq, &prefs,
 				      extent_item_pos, total_refs,
@@ -1382,7 +1385,7 @@  static int find_parent_nodes(struct btrfs_trans_handle *trans,
 	if (ret)
 		goto out;
 
-	__merge_refs(&prefs, 2);
+	__merge_refs(&prefs, MERGE_IDENTICAL_PARENTS);
 
 	while (!list_empty(&prefs)) {
 		ref = list_first_entry(&prefs, struct __prelim_ref, list);