Lines Matching full:chunk

42 	struct audit_chunk *chunk;  member
50 * One struct chunk is attached to each inode of interest through
51 * audit_tree_mark (fsnotify mark). We replace struct chunk on tagging /
52 * untagging, the mark is stable as long as there is chunk attached. The
53 * association between mark and chunk is protected by hash_lock and
57 * the current chunk.
62 * References to struct chunk are collected at audit_inode{,_child}()
68 * tree.chunks anchors chunk.owners[].list hash_lock
70 * chunk.trees anchors tree.same_root hash_lock
71 * chunk.hash is a hash with middle bits of watch.inode as
75 * it", one for each chunk with pointer to it.
77 * chunk is refcounted by embedded .refs. Mark associated with the chunk holds
78 * one chunk reference. This reference is dropped either when a mark is going
79 * to be freed (corresponding inode goes away) or when chunk attached to the
84 * node.index allows to get from node.list to containing chunk.
130 static void free_chunk(struct audit_chunk *chunk) in free_chunk() argument
134 for (i = 0; i < chunk->count; i++) { in free_chunk()
135 if (chunk->owners[i].owner) in free_chunk()
136 put_tree(chunk->owners[i].owner); in free_chunk()
138 kfree(chunk); in free_chunk()
141 void audit_put_chunk(struct audit_chunk *chunk) in audit_put_chunk() argument
143 if (atomic_long_dec_and_test(&chunk->refs)) in audit_put_chunk()
144 free_chunk(chunk); in audit_put_chunk()
149 struct audit_chunk *chunk = container_of(rcu, struct audit_chunk, head); in __put_chunk() local
150 audit_put_chunk(chunk); in __put_chunk()
154 * Drop reference to the chunk that was held by the mark. This is the reference
155 * that gets dropped after we've removed the chunk from the hash table and we
156 * use it to make sure chunk cannot be freed before RCU grace period expires.
158 static void audit_mark_put_chunk(struct audit_chunk *chunk) in audit_mark_put_chunk() argument
160 call_rcu(&chunk->head, __put_chunk); in audit_mark_put_chunk()
170 return audit_mark(mark)->chunk; in mark_chunk()
192 struct audit_chunk *chunk; in alloc_chunk() local
195 chunk = kzalloc(struct_size(chunk, owners, count), GFP_KERNEL); in alloc_chunk()
196 if (!chunk) in alloc_chunk()
199 INIT_LIST_HEAD(&chunk->hash); in alloc_chunk()
200 INIT_LIST_HEAD(&chunk->trees); in alloc_chunk()
201 chunk->count = count; in alloc_chunk()
202 atomic_long_set(&chunk->refs, 1); in alloc_chunk()
204 INIT_LIST_HEAD(&chunk->owners[i].list); in alloc_chunk()
205 chunk->owners[i].index = i; in alloc_chunk()
207 return chunk; in alloc_chunk()
228 static void insert_hash(struct audit_chunk *chunk) in insert_hash() argument
233 * Make sure chunk is fully initialized before making it visible in the in insert_hash()
238 WARN_ON_ONCE(!chunk->key); in insert_hash()
239 list = chunk_hash(chunk->key); in insert_hash()
240 list_add_rcu(&chunk->hash, list); in insert_hash()
253 * the chunk we see is fully initialized. in audit_tree_lookup()
263 bool audit_tree_match(struct audit_chunk *chunk, struct audit_tree *tree) in audit_tree_match() argument
266 for (n = 0; n < chunk->count; n++) in audit_tree_match()
267 if (chunk->owners[n].owner == tree) in audit_tree_match()
282 struct audit_chunk *chunk) in replace_mark_chunk() argument
288 audit_mark(mark)->chunk = chunk; in replace_mark_chunk()
289 if (chunk) in replace_mark_chunk()
290 chunk->mark = mark; in replace_mark_chunk()
319 * Make sure chunk is fully initialized before making it visible in the in replace_chunk()
327 static void remove_chunk_node(struct audit_chunk *chunk, struct audit_node *p) in remove_chunk_node() argument
331 if (owner->root == chunk) { in remove_chunk_node()
340 static int chunk_count_trees(struct audit_chunk *chunk) in chunk_count_trees() argument
345 for (i = 0; i < chunk->count; i++) in chunk_count_trees()
346 if (chunk->owners[i].owner) in chunk_count_trees()
351 static void untag_chunk(struct audit_chunk *chunk, struct fsnotify_mark *mark) in untag_chunk() argument
358 * mark_mutex stabilizes chunk attached to the mark so we can check in untag_chunk()
362 mark_chunk(mark) != chunk) in untag_chunk()
365 size = chunk_count_trees(chunk); in untag_chunk()
368 list_del_init(&chunk->trees); in untag_chunk()
369 list_del_rcu(&chunk->hash); in untag_chunk()
374 audit_mark_put_chunk(chunk); in untag_chunk()
385 * This has to go last when updating chunk as once replace_chunk() is in untag_chunk()
386 * called, new RCU readers can see the new chunk. in untag_chunk()
388 replace_chunk(new, chunk); in untag_chunk()
391 audit_mark_put_chunk(chunk); in untag_chunk()
402 struct audit_chunk *chunk = alloc_chunk(1); in create_chunk() local
404 if (!chunk) { in create_chunk()
412 kfree(chunk); in create_chunk()
419 kfree(chunk); in create_chunk()
430 kfree(chunk); in create_chunk()
433 replace_mark_chunk(mark, chunk); in create_chunk()
434 chunk->owners[0].index = (1U << 31); in create_chunk()
435 chunk->owners[0].owner = tree; in create_chunk()
437 list_add(&chunk->owners[0].list, &tree->chunks); in create_chunk()
439 tree->root = chunk; in create_chunk()
440 list_add(&tree->same_root, &chunk->trees); in create_chunk()
442 chunk->key = inode_to_key(inode); in create_chunk()
445 * readers can see the chunk. in create_chunk()
447 insert_hash(chunk); in create_chunk()
453 * chunk pointing to this mark. in create_chunk()
463 struct audit_chunk *chunk, *old; in tag_chunk() local
474 * from getting detached and thus it makes sure there is chunk attached in tag_chunk()
490 chunk = alloc_chunk(old->count + 1); in tag_chunk()
491 if (!chunk) { in tag_chunk()
502 kfree(chunk); in tag_chunk()
505 p = &chunk->owners[chunk->count - 1]; in tag_chunk()
506 p->index = (chunk->count - 1) | (1U<<31); in tag_chunk()
511 tree->root = chunk; in tag_chunk()
512 list_add(&tree->same_root, &chunk->trees); in tag_chunk()
515 * This has to go last when updating chunk as once replace_chunk() is in tag_chunk()
516 * called, new RCU readers can see the new chunk. in tag_chunk()
518 replace_chunk(chunk, old); in tag_chunk()
576 struct audit_chunk *chunk; in prune_tree_chunks() local
583 chunk = find_chunk(p); in prune_tree_chunks()
584 mark = chunk->mark; in prune_tree_chunks()
585 remove_chunk_node(chunk, p); in prune_tree_chunks()
592 untag_chunk(chunk, mark); in prune_tree_chunks()
703 struct audit_chunk *chunk = find_chunk(node); in audit_trim_trees() local
708 if (inode_to_key(inode) == chunk->key) { in audit_trim_trees()
1008 static void evict_chunk(struct audit_chunk *chunk) in evict_chunk() argument
1017 while (!list_empty(&chunk->trees)) { in evict_chunk()
1018 owner = list_entry(chunk->trees.next, in evict_chunk()
1033 list_del_rcu(&chunk->hash); in evict_chunk()
1034 for (n = 0; n < chunk->count; n++) in evict_chunk()
1035 list_del_init(&chunk->owners[n].list); in evict_chunk()
1052 struct audit_chunk *chunk; in audit_tree_freeing_mark() local
1056 chunk = mark_chunk(mark); in audit_tree_freeing_mark()
1060 if (chunk) { in audit_tree_freeing_mark()
1061 evict_chunk(chunk); in audit_tree_freeing_mark()
1062 audit_mark_put_chunk(chunk); in audit_tree_freeing_mark()