Lines Matching refs:watch
182 struct watch *watch; in __post_watch_notification() local
191 hlist_for_each_entry_rcu(watch, &wlist->watchers, list_node) { in __post_watch_notification()
192 if (watch->id != id) in __post_watch_notification()
195 n->info |= watch->info_id; in __post_watch_notification()
197 wqueue = rcu_dereference(watch->queue); in __post_watch_notification()
202 if (security_post_notification(watch->cred, cred, n) < 0) in __post_watch_notification()
393 struct watch *watch = container_of(rcu, struct watch, rcu); in free_watch() local
395 put_watch_queue(rcu_access_pointer(watch->queue)); in free_watch()
396 atomic_dec(&watch->cred->user->nr_watches); in free_watch()
397 put_cred(watch->cred); in free_watch()
402 struct watch *watch = container_of(kref, struct watch, usage); in __put_watch() local
404 call_rcu(&watch->rcu, free_watch); in __put_watch()
410 static void put_watch(struct watch *watch) in put_watch() argument
412 kref_put(&watch->usage, __put_watch); in put_watch()
422 void init_watch(struct watch *watch, struct watch_queue *wqueue) in init_watch() argument
424 kref_init(&watch->usage); in init_watch()
425 INIT_HLIST_NODE(&watch->list_node); in init_watch()
426 INIT_HLIST_NODE(&watch->queue_node); in init_watch()
427 rcu_assign_pointer(watch->queue, wqueue); in init_watch()
442 int add_watch_to_object(struct watch *watch, struct watch_list *wlist) in add_watch_to_object() argument
444 struct watch_queue *wqueue = rcu_access_pointer(watch->queue); in add_watch_to_object()
445 struct watch *w; in add_watch_to_object()
449 if (wqueue == wq && watch->id == w->id) in add_watch_to_object()
453 watch->cred = get_current_cred(); in add_watch_to_object()
454 rcu_assign_pointer(watch->watch_list, wlist); in add_watch_to_object()
456 if (atomic_inc_return(&watch->cred->user->nr_watches) > in add_watch_to_object()
458 atomic_dec(&watch->cred->user->nr_watches); in add_watch_to_object()
459 put_cred(watch->cred); in add_watch_to_object()
465 kref_get(&watch->usage); in add_watch_to_object()
466 hlist_add_head(&watch->queue_node, &wqueue->watches); in add_watch_to_object()
469 hlist_add_head(&watch->list_node, &wlist->watchers); in add_watch_to_object()
489 struct watch *watch; in remove_watch_from_object() local
496 hlist_for_each_entry(watch, &wlist->watchers, list_node) { in remove_watch_from_object()
498 (watch->id == id && rcu_access_pointer(watch->queue) == wq)) in remove_watch_from_object()
506 hlist_del_init_rcu(&watch->list_node); in remove_watch_from_object()
507 rcu_assign_pointer(watch->watch_list, NULL); in remove_watch_from_object()
512 n.watch.type = WATCH_TYPE_META; in remove_watch_from_object()
513 n.watch.subtype = WATCH_META_REMOVAL_NOTIFICATION; in remove_watch_from_object()
514 n.watch.info = watch->info_id | watch_sizeof(n.watch); in remove_watch_from_object()
517 n.watch.info = watch->info_id | watch_sizeof(n); in remove_watch_from_object()
519 wqueue = rcu_dereference(watch->queue); in remove_watch_from_object()
525 post_one_notification(wqueue, &n.watch); in remove_watch_from_object()
529 if (!hlist_unhashed(&watch->queue_node)) { in remove_watch_from_object()
530 hlist_del_init_rcu(&watch->queue_node); in remove_watch_from_object()
531 put_watch(watch); in remove_watch_from_object()
538 void (*release_watch)(struct watch *); in remove_watch_from_object()
542 (*release_watch)(watch); in remove_watch_from_object()
545 put_watch(watch); in remove_watch_from_object()
563 struct watch *watch; in watch_queue_clear() local
573 watch = hlist_entry(wqueue->watches.first, struct watch, queue_node); in watch_queue_clear()
574 hlist_del_init_rcu(&watch->queue_node); in watch_queue_clear()
583 wlist = rcu_dereference(watch->watch_list); in watch_queue_clear()
585 void (*release_watch)(struct watch *); in watch_queue_clear()
589 release = !hlist_unhashed(&watch->list_node); in watch_queue_clear()
591 hlist_del_init_rcu(&watch->list_node); in watch_queue_clear()
592 rcu_assign_pointer(watch->watch_list, NULL); in watch_queue_clear()
606 (*release_watch)(watch); in watch_queue_clear()
609 put_watch(watch); in watch_queue_clear()
613 put_watch(watch); in watch_queue_clear()