Lines Matching refs:wqueue
42 static inline bool lock_wqueue(struct watch_queue *wqueue) in lock_wqueue() argument
44 spin_lock_bh(&wqueue->lock); in lock_wqueue()
45 if (unlikely(!wqueue->pipe)) { in lock_wqueue()
46 spin_unlock_bh(&wqueue->lock); in lock_wqueue()
52 static inline void unlock_wqueue(struct watch_queue *wqueue) in unlock_wqueue() argument
54 spin_unlock_bh(&wqueue->lock); in unlock_wqueue()
60 struct watch_queue *wqueue = (struct watch_queue *)buf->private; in watch_queue_pipe_buf_release() local
76 set_bit(bit, wqueue->notes_bitmap); in watch_queue_pipe_buf_release()
97 static bool post_one_notification(struct watch_queue *wqueue, in post_one_notification() argument
101 struct pipe_inode_info *pipe = wqueue->pipe; in post_one_notification()
115 note = find_first_bit(wqueue->notes_bitmap, wqueue->nr_notes); in post_one_notification()
116 if (note >= wqueue->nr_notes) in post_one_notification()
119 page = wqueue->notes[note / WATCH_QUEUE_NOTES_PER_PAGE]; in post_one_notification()
129 buf->private = (unsigned long)wqueue; in post_one_notification()
136 if (!test_and_clear_bit(note, wqueue->notes_bitmap)) { in post_one_notification()
200 struct watch_queue *wqueue; in __post_watch_notification() local
216 wqueue = rcu_dereference(watch->queue); in __post_watch_notification()
217 wf = rcu_dereference(wqueue->filter); in __post_watch_notification()
224 if (lock_wqueue(wqueue)) { in __post_watch_notification()
225 post_one_notification(wqueue, n); in __post_watch_notification()
226 unlock_wqueue(wqueue); in __post_watch_notification()
240 struct watch_queue *wqueue = pipe->watch_queue; in watch_queue_set_size() local
246 if (!wqueue) in watch_queue_set_size()
248 if (wqueue->notes) in watch_queue_set_size()
289 wqueue->notes = pages; in watch_queue_set_size()
290 wqueue->notes_bitmap = bitmap; in watch_queue_set_size()
291 wqueue->nr_pages = nr_pages; in watch_queue_set_size()
292 wqueue->nr_notes = nr_notes; in watch_queue_set_size()
314 struct watch_queue *wqueue = pipe->watch_queue; in watch_queue_set_filter() local
317 if (!wqueue) in watch_queue_set_filter()
374 wfilter = rcu_replace_pointer(wqueue->filter, wfilter, in watch_queue_set_filter()
388 struct watch_queue *wqueue = in __put_watch_queue() local
393 for (i = 0; i < wqueue->nr_pages; i++) in __put_watch_queue()
394 __free_page(wqueue->notes[i]); in __put_watch_queue()
395 kfree(wqueue->notes); in __put_watch_queue()
396 bitmap_free(wqueue->notes_bitmap); in __put_watch_queue()
398 wfilter = rcu_access_pointer(wqueue->filter); in __put_watch_queue()
401 kfree_rcu(wqueue, rcu); in __put_watch_queue()
408 void put_watch_queue(struct watch_queue *wqueue) in put_watch_queue() argument
410 kref_put(&wqueue->usage, __put_watch_queue); in put_watch_queue()
446 void init_watch(struct watch *watch, struct watch_queue *wqueue) in init_watch() argument
451 rcu_assign_pointer(watch->queue, wqueue); in init_watch()
454 static int add_one_watch(struct watch *watch, struct watch_list *wlist, struct watch_queue *wqueue) in add_one_watch() argument
461 if (wqueue == wq && watch->id == w->id) in add_one_watch()
474 kref_get(&wqueue->usage); in add_one_watch()
476 hlist_add_head(&watch->queue_node, &wqueue->watches); in add_one_watch()
495 struct watch_queue *wqueue; in add_watch_to_object() local
500 wqueue = rcu_access_pointer(watch->queue); in add_watch_to_object()
501 if (lock_wqueue(wqueue)) { in add_watch_to_object()
503 ret = add_one_watch(watch, wlist, wqueue); in add_watch_to_object()
505 unlock_wqueue(wqueue); in add_watch_to_object()
527 struct watch_queue *wqueue; in remove_watch_from_object() local
558 wqueue = rcu_dereference(watch->queue); in remove_watch_from_object()
560 if (lock_wqueue(wqueue)) { in remove_watch_from_object()
561 post_one_notification(wqueue, &n.watch); in remove_watch_from_object()
568 unlock_wqueue(wqueue); in remove_watch_from_object()
594 void watch_queue_clear(struct watch_queue *wqueue) in watch_queue_clear() argument
601 spin_lock_bh(&wqueue->lock); in watch_queue_clear()
607 wqueue->pipe = NULL; in watch_queue_clear()
609 while (!hlist_empty(&wqueue->watches)) { in watch_queue_clear()
610 watch = hlist_entry(wqueue->watches.first, struct watch, queue_node); in watch_queue_clear()
613 spin_unlock_bh(&wqueue->lock); in watch_queue_clear()
651 spin_lock_bh(&wqueue->lock); in watch_queue_clear()
654 spin_unlock_bh(&wqueue->lock); in watch_queue_clear()
665 struct watch_queue *wqueue = ERR_PTR(-EINVAL); in get_watch_queue() local
672 wqueue = pipe->watch_queue; in get_watch_queue()
673 kref_get(&wqueue->usage); in get_watch_queue()
678 return wqueue; in get_watch_queue()
687 struct watch_queue *wqueue; in watch_queue_init() local
689 wqueue = kzalloc(sizeof(*wqueue), GFP_KERNEL); in watch_queue_init()
690 if (!wqueue) in watch_queue_init()
693 wqueue->pipe = pipe; in watch_queue_init()
694 kref_init(&wqueue->usage); in watch_queue_init()
695 spin_lock_init(&wqueue->lock); in watch_queue_init()
696 INIT_HLIST_HEAD(&wqueue->watches); in watch_queue_init()
698 pipe->watch_queue = wqueue; in watch_queue_init()