289 if (!s)
290 continue;
291 get_tree(s);
292 list_replace_init(&chunk->owners[i].list, &new->owners[j].list);
293 }
294
295 list_replace_rcu(&chunk->hash, &new->hash);
296 list_for_each_entry(owner, &new->trees, same_root)
297 owner->root = new;
298 spin_unlock(&hash_lock);
299 inotify_evict_watch(&chunk->watch);
300 mutex_unlock(&chunk->watch.inode->inotify_mutex);
301 put_inotify_watch(&chunk->watch);
302 goto out;
303
304Fallback:
305
306 spin_lock(&hash_lock);
307 if (owner->root == chunk) {
308 list_del_init(&owner->same_root);
309 owner->root = NULL;
310 }
311 list_del_init(&p->list);
312 p->owner = NULL;
313 put_tree(owner);
314 spin_unlock(&hash_lock);
315 mutex_unlock(&chunk->watch.inode->inotify_mutex);
316out:
317 unpin_inotify_watch(&chunk->watch);
318 spin_lock(&hash_lock);
319}
320
321static int create_chunk(struct inode *inode, struct audit_tree *tree)
322{
323 struct audit_chunk *chunk = alloc_chunk(1);
324 if (!chunk)
325 return -ENOMEM;
326
327 if (inotify_add_watch(rtree_ih, &chunk->watch, inode, IN_IGNORED | IN_DELETE_SELF) < 0) {
328 free_chunk(chunk);
329 return -ENOSPC;