aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ulist.c
diff options
context:
space:
mode:
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>2014-01-10 08:25:46 -0500
committerChris Mason <clm@fb.com>2014-01-28 16:20:30 -0500
commitf499e40fd97698a1c48d188279647009b21905fe (patch)
tree416f03ad6bad10af662d009688180d5312f6c00d /fs/btrfs/ulist.c
parentde6e8200669f9b60694ca87eadf0a0a99cbdb6aa (diff)
Btrfs: optimize to remove unnecessary removal with ulist reallocation
Here we are not going to free memory, no need to remove every node one by one, just init root node here is ok. Cc: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ulist.c')
-rw-r--r--fs/btrfs/ulist.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/fs/btrfs/ulist.c b/fs/btrfs/ulist.c
index b0a523b2c60e..35f5de9dd498 100644
--- a/fs/btrfs/ulist.c
+++ b/fs/btrfs/ulist.c
@@ -207,9 +207,6 @@ int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
207 void *old = NULL; 207 void *old = NULL;
208 int i; 208 int i;
209 209
210 for (i = 0; i < ulist->nnodes; i++)
211 rb_erase(&ulist->nodes[i].rb_node, &ulist->root);
212
213 /* 210 /*
214 * if nodes_alloced == ULIST_SIZE no memory has been allocated 211 * if nodes_alloced == ULIST_SIZE no memory has been allocated
215 * yet, so pass NULL to krealloc 212 * yet, so pass NULL to krealloc
@@ -234,6 +231,7 @@ int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
234 * pointers, so we have to do it ourselves. Otherwise we may 231 * pointers, so we have to do it ourselves. Otherwise we may
235 * be bitten by crashes. 232 * be bitten by crashes.
236 */ 233 */
234 ulist->root = RB_ROOT;
237 for (i = 0; i < ulist->nnodes; i++) { 235 for (i = 0; i < ulist->nnodes; i++) {
238 ret = ulist_rbtree_insert(ulist, &ulist->nodes[i]); 236 ret = ulist_rbtree_insert(ulist, &ulist->nodes[i]);
239 if (ret < 0) 237 if (ret < 0)