Lines Matching full:new
62 struct aa_proxy *new; in aa_alloc_proxy() local
64 new = kzalloc(sizeof(struct aa_proxy), gfp); in aa_alloc_proxy()
65 if (new) { in aa_alloc_proxy()
66 kref_init(&new->count); in aa_alloc_proxy()
67 rcu_assign_pointer(new->label, aa_get_label(label)); in aa_alloc_proxy()
69 return new; in aa_alloc_proxy()
73 void __aa_proxy_redirect(struct aa_label *orig, struct aa_label *new) in __aa_proxy_redirect() argument
78 AA_BUG(!new); in __aa_proxy_redirect()
83 rcu_assign_pointer(orig->proxy->label, aa_get_label(new)); in __aa_proxy_redirect()
88 static void __proxy_share(struct aa_label *old, struct aa_label *new) in __proxy_share() argument
90 struct aa_proxy *proxy = new->proxy; in __proxy_share()
92 new->proxy = aa_get_proxy(old->proxy); in __proxy_share()
93 __aa_proxy_redirect(old, new); in __proxy_share()
387 static void label_free_or_put_new(struct aa_label *label, struct aa_label *new) in label_free_or_put_new() argument
389 if (label != new) in label_free_or_put_new()
391 aa_label_free(new); in label_free_or_put_new()
393 aa_put_label(new); in label_free_or_put_new()
415 * @proxy: proxy to use OR null if to allocate a new one
418 * Returns: new label
423 struct aa_label *new; in aa_label_alloc() local
428 new = kzalloc(struct_size(new, vec, size + 1), gfp); in aa_label_alloc()
429 AA_DEBUG("%s (%p)\n", __func__, new); in aa_label_alloc()
430 if (!new) in aa_label_alloc()
433 if (!aa_label_init(new, size, gfp)) in aa_label_alloc()
437 proxy = aa_alloc_proxy(new, gfp); in aa_label_alloc()
442 /* just set new's proxy, don't redirect proxy here if it was passed in*/ in aa_label_alloc()
443 new->proxy = proxy; in aa_label_alloc()
445 return new; in aa_label_alloc()
448 kfree(new); in aa_label_alloc()
585 * @new: label to redirect to
590 static bool __label_remove(struct aa_label *label, struct aa_label *new) in __label_remove() argument
598 if (new) in __label_remove()
599 __aa_proxy_redirect(label, new); in __label_remove()
614 * __label_replace - replace @old with @new in label set
616 * @new: label to replace @old with
619 * valid ref count be held on @new
620 * Returns: true if @old was in set and replaced by @new
623 * that @new directly replaces @old position in the set (ie.
626 static bool __label_replace(struct aa_label *old, struct aa_label *new) in __label_replace() argument
632 AA_BUG(!new); in __label_replace()
634 AA_BUG(new->flags & FLAG_IN_TREE); in __label_replace()
640 rb_replace_node(&old->node, &new->node, &ls->root); in __label_replace()
642 new->flags |= FLAG_IN_TREE; in __label_replace()
652 * @label: new label to insert (NOT NULL)
665 struct rb_node **new, *parent = NULL; in __label_insert() local
673 /* Figure out where to put new node */ in __label_insert()
674 new = &ls->root.rb_node; in __label_insert()
675 while (*new) { in __label_insert()
676 struct aa_label *this = rb_entry(*new, struct aa_label, node); in __label_insert()
679 parent = *new; in __label_insert()
694 new = &((*new)->rb_left); in __label_insert()
696 new = &((*new)->rb_right); in __label_insert()
699 /* Add new node and rebalance tree. */ in __label_insert()
700 rb_link_node(&label->node, parent, new); in __label_insert()
785 * aa_label_replace - replace a label @old with a new version @new
787 * @new: label replacing @old
790 * else @old was not in tree, and @new was not inserted
792 bool aa_label_replace(struct aa_label *old, struct aa_label *new) in aa_label_replace() argument
797 if (name_is_shared(old, new) && labels_ns(old) == labels_ns(new)) { in aa_label_replace()
799 if (old->proxy != new->proxy) in aa_label_replace()
800 __proxy_share(old, new); in aa_label_replace()
802 __aa_proxy_redirect(old, new); in aa_label_replace()
803 res = __label_replace(old, new); in aa_label_replace()
810 res = __label_remove(old, new); in aa_label_replace()
811 if (labels_ns(old) != labels_ns(new)) { in aa_label_replace()
813 ls = labels_set(new); in aa_label_replace()
816 l = __label_insert(ls, new, true); in aa_label_replace()
817 res = (l == new); in aa_label_replace()
858 struct aa_label *new; in vec_create_and_insert_label() local
871 new = aa_label_alloc(len, NULL, gfp); in vec_create_and_insert_label()
872 if (!new) in vec_create_and_insert_label()
876 new->vec[i] = aa_get_profile(vec[i]); in vec_create_and_insert_label()
879 label = __label_insert(ls, new, false); in vec_create_and_insert_label()
881 label_free_or_put_new(label, new); in vec_create_and_insert_label()
1030 * label_merge_insert - create a new label by merging @a and @b
1031 * @new: preallocated label to merge into (NOT NULL)
1037 * Returns: ref counted label either @new if merge is unique
1041 * NOTE: will not use @new if the merge results in @new == @a or @b
1046 static struct aa_label *label_merge_insert(struct aa_label *new, in label_merge_insert() argument
1062 AA_BUG(!new); in label_merge_insert()
1063 AA_BUG(new->size < a->size + b->size); in label_merge_insert()
1068 new->vec[k] = aa_get_newest_profile(next); in label_merge_insert()
1069 AA_BUG(!new->vec[k]->label.proxy); in label_merge_insert()
1070 AA_BUG(!new->vec[k]->label.proxy->label); in label_merge_insert()
1071 if (next->label.proxy != new->vec[k]->label.proxy) in label_merge_insert()
1076 new->vec[k++] = aa_get_profile(next); in label_merge_insert()
1079 new->size = k; in label_merge_insert()
1080 new->vec[k] = NULL; in label_merge_insert()
1083 new->size -= aa_vec_unique(&new->vec[0], new->size, in label_merge_insert()
1086 if (new->size == 1) { in label_merge_insert()
1087 label = aa_get_label(&new->vec[0]->label); in label_merge_insert()
1093 * for new->size == a->size == b->size unless a == b in label_merge_insert()
1100 new->flags |= union_vec_flags(new->vec, new->size, FLAG_UNCONFINED | in label_merge_insert()
1102 ls = labels_set(new); in label_merge_insert()
1104 label = __label_insert(labels_set(new), new, false); in label_merge_insert()
1204 * aa_label_merge - attempt to insert new merged label of @a and @b
1213 * Returns: ref counted new label if successful in inserting merge of a & b
1235 struct aa_label *new; in aa_label_merge() local
1243 new = aa_label_alloc(a->size + b->size, NULL, gfp); in aa_label_merge()
1244 if (!new) in aa_label_merge()
1247 label = label_merge_insert(new, a, b); in aa_label_merge()
1248 label_free_or_put_new(label, new); in aa_label_merge()
1924 * if component specified a new ns it becomes the new base in aa_label_strn_parse()
2041 * Returns: new label that is up to date
2051 struct aa_label *new, *tmp; in __label_update() local
2059 new = aa_label_alloc(label->size, label->proxy, GFP_KERNEL); in __label_update()
2060 if (!new) in __label_update()
2071 new->vec[i] = aa_get_newest_profile(label->vec[i]); in __label_update()
2072 AA_BUG(!new->vec[i]); in __label_update()
2073 AA_BUG(!new->vec[i]->label.proxy); in __label_update()
2074 AA_BUG(!new->vec[i]->label.proxy->label); in __label_update()
2075 if (new->vec[i]->label.proxy != label->vec[i]->label.proxy) in __label_update()
2081 new->size -= aa_vec_unique(&new->vec[0], new->size, in __label_update()
2084 if (new->size == 1) { in __label_update()
2085 tmp = aa_get_label(&new->vec[0]->label); in __label_update()
2089 if (labels_set(label) != labels_set(new)) { in __label_update()
2091 tmp = aa_label_insert(labels_set(new), new); in __label_update()
2096 AA_BUG(labels_ns(label) != labels_ns(new)); in __label_update()
2098 tmp = __label_insert(labels_set(label), new, true); in __label_update()
2103 label_free_or_put_new(tmp, new); in __label_update()