All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robbie Ko <robbieko@synology.com>
To: linux-btrfs@vger.kernel.org
Cc: Robbie Ko <robbieko@synology.com>
Subject: [PATCH v2 7/7] Btrfs: incremental send, avoid the overhead of allocating an orphan_dir_info object unnecessarily
Date: Mon, 22 Jun 2015 17:08:48 +0800	[thread overview]
Message-ID: <1434964128-31757-8-git-send-email-robbieko@synology.com> (raw)
In-Reply-To: <1434964128-31757-1-git-send-email-robbieko@synology.com>

Avoid the overhead of allocating an orphan_dir_info object unnecessarily.

Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 fs/btrfs/send.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 579a4c8..9c60421 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -2785,12 +2785,6 @@ add_orphan_dir_info(struct send_ctx *sctx, u64 dir_ino)
 	struct rb_node *parent = NULL;
 	struct orphan_dir_info *entry, *odi;
 
-	odi = kmalloc(sizeof(*odi), GFP_NOFS);
-	if (!odi)
-		return ERR_PTR(-ENOMEM);
-	odi->ino = dir_ino;
-	odi->gen = 0;
-
 	while (*p) {
 		parent = *p;
 		entry = rb_entry(parent, struct orphan_dir_info, node);
@@ -2799,11 +2793,16 @@ add_orphan_dir_info(struct send_ctx *sctx, u64 dir_ino)
 		} else if (dir_ino > entry->ino) {
 			p = &(*p)->rb_right;
 		} else {
-			kfree(odi);
 			return entry;
 		}
 	}
 
+	odi = kmalloc(sizeof(*odi), GFP_NOFS);
+	if (!odi)
+		return ERR_PTR(-ENOMEM);
+	odi->ino = dir_ino;
+	odi->gen = 0;
+
 	rb_link_node(&odi->node, parent, p);
 	rb_insert_color(&odi->node, &sctx->orphan_dirs);
 	return odi;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in

      parent reply	other threads:[~2015-06-22  9:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-22  9:08 [PATCH v2 0/7] Btrfs incremental send fix serval case for rename and rm directory Robbie Ko
2015-06-22  9:08 ` [PATCH v2 1/7] Revert "Btrfs: incremental send, remove dead code" Robbie Ko
2015-06-22 11:32   ` Filipe David Manana
2015-06-22  9:08 ` [PATCH v2 2/7] Btrfs: incremental send, avoid circular waiting and descendant overwrite ancestor need to update path Robbie Ko
2015-06-22 11:35   ` Filipe David Manana
2015-06-22  9:08 ` [PATCH v2 3/7] Btrfs: incremental send, avoid ancestor rename to descendant Robbie Ko
2015-06-22 11:36   ` Filipe David Manana
2015-06-22  9:08 ` [PATCH v2 4/7] Btrfs: incremental send, fix orphan_dir_info leak Robbie Ko
2015-06-22  9:08 ` [PATCH v2 5/7] Btrfs: incremental send, fix rmdir but dir have a unprocess item Robbie Ko
2015-06-22  9:08 ` [PATCH v2 6/7] Btrfs: incremental send, don't send utimes for non-existing directory Robbie Ko
2015-06-22 11:37   ` Filipe David Manana
2015-06-22  9:08 ` Robbie Ko [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=1434964128-31757-8-git-send-email-robbieko@synology.com \
    --to=robbieko@synology.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.