提交 35c8eda1 编写于 作者: R Robbie Ko 提交者: David Sterba

btrfs: incremental send, move allocation until it's needed in orphan_dir_info

Move the allocation after the search when it's clear that the new entry
will be added.
Signed-off-by: NRobbie Ko <robbieko@synology.com>
Reviewed-by: NFilipe Manana <fdmanana@suse.com>
[ update changelog ]
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 2335efaf
......@@ -2844,12 +2844,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_KERNEL);
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);
......@@ -2858,11 +2852,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_KERNEL);
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册