Lines Matching defs:watch

91  * Post a notification to a watch queue.
184 * @wlist: The watch list to post the event to.
187 * @id: The ID to match on the watch.
189 * Post a notification of an event into a set of watch queues and let the users
202 struct watch *watch;
211 hlist_for_each_entry_rcu(watch, &wlist->watchers, list_node) {
212 if (watch->id != id)
215 n->info |= watch->info_id;
217 wqueue = rcu_dereference(watch->queue);
222 if (security_post_notification(watch->cred, cred, n) < 0)
316 * Set the filter on a watch queue.
417 * @wqueue: The watch queue to unref.
427 struct watch *watch = container_of(rcu, struct watch, rcu);
429 put_watch_queue(rcu_access_pointer(watch->queue));
430 atomic_dec(&watch->cred->user->nr_watches);
431 put_cred(watch->cred);
432 kfree(watch);
437 struct watch *watch = container_of(kref, struct watch, usage);
439 call_rcu(&watch->rcu, free_watch);
443 * Discard a watch.
445 static void put_watch(struct watch *watch)
447 kref_put(&watch->usage, __put_watch);
451 * init_watch - Initialise a watch
452 * @watch: The watch to initialise.
455 * Initialise a watch and set the watch queue.
457 void init_watch(struct watch *watch, struct watch_queue *wqueue)
459 kref_init(&watch->usage);
460 INIT_HLIST_NODE(&watch->list_node);
461 INIT_HLIST_NODE(&watch->queue_node);
462 rcu_assign_pointer(watch->queue, wqueue);
465 static int add_one_watch(struct watch *watch, struct watch_list *wlist, struct watch_queue *wqueue)
468 struct watch *w;
472 if (wqueue == wq && watch->id == w->id)
482 watch->cred = get_cred(cred);
483 rcu_assign_pointer(watch->watch_list, wlist);
486 kref_get(&watch->usage);
487 hlist_add_head(&watch->queue_node, &wqueue->watches);
488 hlist_add_head_rcu(&watch->list_node, &wlist->watchers);
493 * add_watch_to_object - Add a watch on an object to a watch list
494 * @watch: The watch to add
495 * @wlist: The watch list to add to
497 * @watch->queue must have been set to point to the queue to post notifications
498 * to and the watch list of the object to be watched. @watch->cred must also
502 * locked against racing watch additions/removals.
504 int add_watch_to_object(struct watch *watch, struct watch_list *wlist)
511 wqueue = rcu_access_pointer(watch->queue);
514 ret = add_one_watch(watch, wlist, wqueue);
525 * remove_watch_from_object - Remove a watch or all watches from an object.
526 * @wlist: The watch list to remove from
527 * @wq: The watch queue of interest (ignored if @all is true)
528 * @id: The ID of the watch to remove (ignored if @all is true)
531 * Remove a specific watch or all watches from an object. A notification is
539 struct watch *watch;
546 hlist_for_each_entry(watch, &wlist->watchers, list_node) {
548 (watch->id == id && rcu_access_pointer(watch->queue) == wq))
556 hlist_del_init_rcu(&watch->list_node);
557 rcu_assign_pointer(watch->watch_list, NULL);
560 /* We now own the reference on watch that used to belong to wlist. */
562 n.watch.type = WATCH_TYPE_META;
563 n.watch.subtype = WATCH_META_REMOVAL_NOTIFICATION;
564 n.watch.info = watch->info_id | watch_sizeof(n.watch);
567 n.watch.info = watch->info_id | watch_sizeof(n);
569 wqueue = rcu_dereference(watch->queue);
572 post_one_notification(wqueue, &n.watch);
574 if (!hlist_unhashed(&watch->queue_node)) {
575 hlist_del_init_rcu(&watch->queue_node);
576 put_watch(watch);
583 void (*release_watch)(struct watch *);
587 (*release_watch)(watch);
590 put_watch(watch);
608 struct watch *watch;
621 watch = hlist_entry(wqueue->watches.first, struct watch, queue_node);
622 hlist_del_init_rcu(&watch->queue_node);
623 /* We now own a ref on the watch. */
631 wlist = rcu_dereference(watch->watch_list);
633 void (*release_watch)(struct watch *);
637 release = !hlist_unhashed(&watch->list_node);
639 hlist_del_init_rcu(&watch->list_node);
640 rcu_assign_pointer(watch->watch_list, NULL);
642 /* We now own a second ref on the watch. */
654 (*release_watch)(watch);
657 put_watch(watch);
661 put_watch(watch);
670 * get_watch_queue - Get a watch queue from its file descriptor.
692 * Initialise a watch queue