On Wed, Jun 01, 2016 at 02:15:22PM -0700, Mark Fasheh wrote: > > +static int ref_tree_add(struct ref_root *ref_tree, u64 root_id, u64 > > object_id, > > + u64 offset, u64 parent, int count) > > +{ > > + struct ref_node *node = NULL; > > + struct rb_node **pos = NULL; > > + struct rb_node *pos_parent = NULL; > > + int origin_count; > > + int ret; > > + > > + if (!count) > > + return 0; > > + > > + node = __ref_tree_search(ref_tree, &pos, &pos_parent, root_id, > > + object_id, offset, parent); > > + if (node == NULL) { > > + node = kmalloc(sizeof(*node), GFP_KERNEL); > > + if (!node) > > + return -ENOMEM; > > + > > + node->root_id = root_id; > > + node->object_id = object_id; > > + node->offset = offset; > > + node->parent = parent; > > + node->ref_mod = count; > > + > > + ret = ref_tree_insert(ref_tree, pos, pos_parent, node); > > + ASSERT(!ret); > > + if (ret) { > > + kfree(node); > > + return ret; > > + } > > If you put the open coded comparisons into their own function, then it > should be trivial to call that here and we can have a 'standard' looking > rbtree insert instead of this custom version. See the rbtree.h header for an > example.
oops, I meant Documentation/rbtree.txt instead of include/linux/rbtree.h. --Mark -- Mark Fasheh -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html