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 04/13] btrfs: backref, add unode_aux_to_inode_list helper
Date: Wed, 28 Jun 2017 21:56:56 -0600	[thread overview]
Message-ID: <20170629035705.1589-5-enadolski@suse.com> (raw)
In-Reply-To: <20170629035705.1589-1-enadolski@suse.com>

From: Jeff Mahoney <jeffm@suse.com>

Replacing the double cast and ternary conditional with a helper makes
the code easier on the eyes.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 fs/btrfs/backref.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 9d6474d..4a7a4b0 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -682,6 +682,14 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
 	return ret;
 }
 
+static struct extent_inode_elem *
+unode_aux_to_inode_list(struct ulist_node *node)
+{
+	if (!node)
+		return NULL;
+	return (struct extent_inode_elem *)(uintptr_t)node->aux;
+}
+
 /*
  * resolve all indirect backrefs from the list
  */
@@ -736,8 +744,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
 		ULIST_ITER_INIT(&uiter);
 		node = ulist_next(parents, &uiter);
 		ref->parent = node ? node->val : 0;
-		ref->inode_list = node ?
-			(struct extent_inode_elem *)(uintptr_t)node->aux : NULL;
+		ref->inode_list = unode_aux_to_inode_list(node);
 
 		/* additional parents require new refs being added here */
 		while ((node = ulist_next(parents, &uiter))) {
@@ -749,8 +756,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
 			}
 			memcpy(new_ref, ref, sizeof(*ref));
 			new_ref->parent = node->val;
-			new_ref->inode_list = (struct extent_inode_elem *)
-							(uintptr_t)node->aux;
+			new_ref->inode_list = unode_aux_to_inode_list(node);
 			list_add(&new_ref->list, &ref->list);
 		}
 		ulist_reinit(parents);
@@ -1476,7 +1482,7 @@ static void free_leaf_list(struct ulist *blocks)
 	while ((node = ulist_next(blocks, &uiter))) {
 		if (!node->aux)
 			continue;
-		eie = (struct extent_inode_elem *)(uintptr_t)node->aux;
+		eie = unode_aux_to_inode_list(node);
 		free_inode_elem_list(eie);
 		node->aux = 0;
 	}
-- 
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 ` Edmund Nadolski [this message]
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 ` [PATCH v2 13/13] btrfs: clean up extraneous computations in add_delayed_refs Edmund Nadolski
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-5-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.