Lines Matching refs:wqueue
43 static inline bool lock_wqueue(struct watch_queue *wqueue) in lock_wqueue() argument
45 spin_lock_bh(&wqueue->lock); in lock_wqueue()
46 if (unlikely(wqueue->defunct)) { in lock_wqueue()
47 spin_unlock_bh(&wqueue->lock); in lock_wqueue()
53 static inline void unlock_wqueue(struct watch_queue *wqueue) in unlock_wqueue() argument
55 spin_unlock_bh(&wqueue->lock); in unlock_wqueue()
61 struct watch_queue *wqueue = (struct watch_queue *)buf->private; in watch_queue_pipe_buf_release() local
77 set_bit(bit, wqueue->notes_bitmap); in watch_queue_pipe_buf_release()
98 static bool post_one_notification(struct watch_queue *wqueue, in post_one_notification() argument
102 struct pipe_inode_info *pipe = wqueue->pipe; in post_one_notification()
119 note = find_first_bit(wqueue->notes_bitmap, wqueue->nr_notes); in post_one_notification()
120 if (note >= wqueue->nr_notes) in post_one_notification()
123 page = wqueue->notes[note / WATCH_QUEUE_NOTES_PER_PAGE]; in post_one_notification()
133 buf->private = (unsigned long)wqueue; in post_one_notification()
140 if (!test_and_clear_bit(note, wqueue->notes_bitmap)) { in post_one_notification()
204 struct watch_queue *wqueue; in __post_watch_notification() local
220 wqueue = rcu_dereference(watch->queue); in __post_watch_notification()
221 wf = rcu_dereference(wqueue->filter); in __post_watch_notification()
228 if (lock_wqueue(wqueue)) { in __post_watch_notification()
229 post_one_notification(wqueue, n); in __post_watch_notification()
230 unlock_wqueue(wqueue); in __post_watch_notification()
244 struct watch_queue *wqueue = pipe->watch_queue; in watch_queue_set_size() local
250 if (!wqueue) in watch_queue_set_size()
252 if (wqueue->notes) in watch_queue_set_size()
293 wqueue->notes = pages; in watch_queue_set_size()
294 wqueue->notes_bitmap = bitmap; in watch_queue_set_size()
295 wqueue->nr_pages = nr_pages; in watch_queue_set_size()
296 wqueue->nr_notes = nr_notes; in watch_queue_set_size()
318 struct watch_queue *wqueue = pipe->watch_queue; in watch_queue_set_filter() local
321 if (!wqueue) in watch_queue_set_filter()
378 wfilter = rcu_replace_pointer(wqueue->filter, wfilter, in watch_queue_set_filter()
392 struct watch_queue *wqueue = in __put_watch_queue() local
397 for (i = 0; i < wqueue->nr_pages; i++) in __put_watch_queue()
398 __free_page(wqueue->notes[i]); in __put_watch_queue()
399 kfree(wqueue->notes); in __put_watch_queue()
400 bitmap_free(wqueue->notes_bitmap); in __put_watch_queue()
402 wfilter = rcu_access_pointer(wqueue->filter); in __put_watch_queue()
405 kfree_rcu(wqueue, rcu); in __put_watch_queue()
412 void put_watch_queue(struct watch_queue *wqueue) in put_watch_queue() argument
414 kref_put(&wqueue->usage, __put_watch_queue); in put_watch_queue()
450 void init_watch(struct watch *watch, struct watch_queue *wqueue) in init_watch() argument
455 rcu_assign_pointer(watch->queue, wqueue); in init_watch()
458 static int add_one_watch(struct watch *watch, struct watch_list *wlist, struct watch_queue *wqueue) in add_one_watch() argument
465 if (wqueue == wq && watch->id == w->id) in add_one_watch()
478 kref_get(&wqueue->usage); in add_one_watch()
480 hlist_add_head(&watch->queue_node, &wqueue->watches); in add_one_watch()
499 struct watch_queue *wqueue; in add_watch_to_object() local
504 wqueue = rcu_access_pointer(watch->queue); in add_watch_to_object()
505 if (lock_wqueue(wqueue)) { in add_watch_to_object()
507 ret = add_one_watch(watch, wlist, wqueue); in add_watch_to_object()
509 unlock_wqueue(wqueue); in add_watch_to_object()
531 struct watch_queue *wqueue; in remove_watch_from_object() local
562 wqueue = rcu_dereference(watch->queue); in remove_watch_from_object()
564 if (lock_wqueue(wqueue)) { in remove_watch_from_object()
565 post_one_notification(wqueue, &n.watch); in remove_watch_from_object()
572 unlock_wqueue(wqueue); in remove_watch_from_object()
598 void watch_queue_clear(struct watch_queue *wqueue) in watch_queue_clear() argument
605 spin_lock_bh(&wqueue->lock); in watch_queue_clear()
608 wqueue->defunct = true; in watch_queue_clear()
610 while (!hlist_empty(&wqueue->watches)) { in watch_queue_clear()
611 watch = hlist_entry(wqueue->watches.first, struct watch, queue_node); in watch_queue_clear()
614 spin_unlock_bh(&wqueue->lock); in watch_queue_clear()
652 spin_lock_bh(&wqueue->lock); in watch_queue_clear()
655 spin_unlock_bh(&wqueue->lock); in watch_queue_clear()
666 struct watch_queue *wqueue = ERR_PTR(-EINVAL); in get_watch_queue() local
673 wqueue = pipe->watch_queue; in get_watch_queue()
674 kref_get(&wqueue->usage); in get_watch_queue()
679 return wqueue; in get_watch_queue()
688 struct watch_queue *wqueue; in watch_queue_init() local
690 wqueue = kzalloc(sizeof(*wqueue), GFP_KERNEL); in watch_queue_init()
691 if (!wqueue) in watch_queue_init()
694 wqueue->pipe = pipe; in watch_queue_init()
695 kref_init(&wqueue->usage); in watch_queue_init()
696 spin_lock_init(&wqueue->lock); in watch_queue_init()
697 INIT_HLIST_HEAD(&wqueue->watches); in watch_queue_init()
699 pipe->watch_queue = wqueue; in watch_queue_init()