Lines Matching full:watch
2 /* Watch queue and general notification mechanism, built on pipes
30 MODULE_DESCRIPTION("Watch queue");
91 * Post a notification to a watch queue.
183 * @wlist: The watch list to post the event to.
186 * @id: The ID to match on the watch.
188 * Post a notification of an event into a set of watch queues and let the users
201 struct watch *watch; in __post_watch_notification() local
210 hlist_for_each_entry_rcu(watch, &wlist->watchers, list_node) { in __post_watch_notification()
211 if (watch->id != id) in __post_watch_notification()
214 n->info |= watch->info_id; in __post_watch_notification()
216 wqueue = rcu_dereference(watch->queue); in __post_watch_notification()
221 if (security_post_notification(watch->cred, cred, n) < 0) in __post_watch_notification()
314 * Set the filter on a watch queue.
415 * @wqueue: The watch queue to unref.
425 struct watch *watch = container_of(rcu, struct watch, rcu); in free_watch() local
427 put_watch_queue(rcu_access_pointer(watch->queue)); in free_watch()
428 atomic_dec(&watch->cred->user->nr_watches); in free_watch()
429 put_cred(watch->cred); in free_watch()
430 kfree(watch); in free_watch()
435 struct watch *watch = container_of(kref, struct watch, usage); in __put_watch() local
437 call_rcu(&watch->rcu, free_watch); in __put_watch()
441 * Discard a watch.
443 static void put_watch(struct watch *watch) in put_watch() argument
445 kref_put(&watch->usage, __put_watch); in put_watch()
449 * init_watch - Initialise a watch
450 * @watch: The watch to initialise.
453 * Initialise a watch and set the watch queue.
455 void init_watch(struct watch *watch, struct watch_queue *wqueue) in init_watch() argument
457 kref_init(&watch->usage); in init_watch()
458 INIT_HLIST_NODE(&watch->list_node); in init_watch()
459 INIT_HLIST_NODE(&watch->queue_node); in init_watch()
460 rcu_assign_pointer(watch->queue, wqueue); in init_watch()
463 static int add_one_watch(struct watch *watch, struct watch_list *wlist, struct watch_queue *wqueue) in add_one_watch() argument
466 struct watch *w; in add_one_watch()
470 if (wqueue == wq && watch->id == w->id) in add_one_watch()
480 watch->cred = get_cred(cred); in add_one_watch()
481 rcu_assign_pointer(watch->watch_list, wlist); in add_one_watch()
484 kref_get(&watch->usage); in add_one_watch()
485 hlist_add_head(&watch->queue_node, &wqueue->watches); in add_one_watch()
486 hlist_add_head_rcu(&watch->list_node, &wlist->watchers); in add_one_watch()
491 * add_watch_to_object - Add a watch on an object to a watch list
492 * @watch: The watch to add
493 * @wlist: The watch list to add to
495 * @watch->queue must have been set to point to the queue to post notifications
496 * to and the watch list of the object to be watched. @watch->cred must also
500 * locked against racing watch additions/removals.
502 int add_watch_to_object(struct watch *watch, struct watch_list *wlist) in add_watch_to_object() argument
509 wqueue = rcu_access_pointer(watch->queue); in add_watch_to_object()
512 ret = add_one_watch(watch, wlist, wqueue); in add_watch_to_object()
523 * remove_watch_from_object - Remove a watch or all watches from an object.
524 * @wlist: The watch list to remove from
525 * @wq: The watch queue of interest (ignored if @all is true)
526 * @id: The ID of the watch to remove (ignored if @all is true)
529 * Remove a specific watch or all watches from an object. A notification is
537 struct watch *watch; in remove_watch_from_object() local
544 hlist_for_each_entry(watch, &wlist->watchers, list_node) { in remove_watch_from_object()
546 (watch->id == id && rcu_access_pointer(watch->queue) == wq)) in remove_watch_from_object()
554 hlist_del_init_rcu(&watch->list_node); in remove_watch_from_object()
555 rcu_assign_pointer(watch->watch_list, NULL); in remove_watch_from_object()
558 /* We now own the reference on watch that used to belong to wlist. */ in remove_watch_from_object()
560 n.watch.type = WATCH_TYPE_META; in remove_watch_from_object()
561 n.watch.subtype = WATCH_META_REMOVAL_NOTIFICATION; in remove_watch_from_object()
562 n.watch.info = watch->info_id | watch_sizeof(n.watch); in remove_watch_from_object()
565 n.watch.info = watch->info_id | watch_sizeof(n); in remove_watch_from_object()
567 wqueue = rcu_dereference(watch->queue); in remove_watch_from_object()
570 post_one_notification(wqueue, &n.watch); in remove_watch_from_object()
572 if (!hlist_unhashed(&watch->queue_node)) { in remove_watch_from_object()
573 hlist_del_init_rcu(&watch->queue_node); in remove_watch_from_object()
574 put_watch(watch); in remove_watch_from_object()
581 void (*release_watch)(struct watch *); in remove_watch_from_object()
585 (*release_watch)(watch); in remove_watch_from_object()
588 put_watch(watch); in remove_watch_from_object()
606 struct watch *watch; in watch_queue_clear() local
619 watch = hlist_entry(wqueue->watches.first, struct watch, queue_node); in watch_queue_clear()
620 hlist_del_init_rcu(&watch->queue_node); in watch_queue_clear()
621 /* We now own a ref on the watch. */ in watch_queue_clear()
629 wlist = rcu_dereference(watch->watch_list); in watch_queue_clear()
631 void (*release_watch)(struct watch *); in watch_queue_clear()
635 release = !hlist_unhashed(&watch->list_node); in watch_queue_clear()
637 hlist_del_init_rcu(&watch->list_node); in watch_queue_clear()
638 rcu_assign_pointer(watch->watch_list, NULL); in watch_queue_clear()
640 /* We now own a second ref on the watch. */ in watch_queue_clear()
652 (*release_watch)(watch); in watch_queue_clear()
655 put_watch(watch); in watch_queue_clear()
659 put_watch(watch); in watch_queue_clear()
668 * get_watch_queue - Get a watch queue from its file descriptor.
690 * Initialise a watch queue