Lines Matching refs:mark
94 void fsnotify_get_mark(struct fsnotify_mark *mark) in fsnotify_get_mark() argument
96 WARN_ON_ONCE(!refcount_read(&mark->refcnt)); in fsnotify_get_mark()
97 refcount_inc(&mark->refcnt); in fsnotify_get_mark()
122 struct fsnotify_mark *mark; in __fsnotify_recalc_mask() local
128 hlist_for_each_entry(mark, &conn->list, obj_list) { in __fsnotify_recalc_mask()
129 if (mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED) in __fsnotify_recalc_mask()
130 new_mask |= mark->mask; in __fsnotify_recalc_mask()
230 static void fsnotify_final_mark_destroy(struct fsnotify_mark *mark) in fsnotify_final_mark_destroy() argument
232 struct fsnotify_group *group = mark->group; in fsnotify_final_mark_destroy()
236 group->ops->free_mark(mark); in fsnotify_final_mark_destroy()
251 void fsnotify_put_mark(struct fsnotify_mark *mark) in fsnotify_put_mark() argument
253 struct fsnotify_mark_connector *conn = READ_ONCE(mark->connector); in fsnotify_put_mark()
260 if (refcount_dec_and_test(&mark->refcnt)) in fsnotify_put_mark()
261 fsnotify_final_mark_destroy(mark); in fsnotify_put_mark()
269 if (!refcount_dec_and_lock(&mark->refcnt, &conn->lock)) in fsnotify_put_mark()
272 hlist_del_init_rcu(&mark->obj_list); in fsnotify_put_mark()
279 WRITE_ONCE(mark->connector, NULL); in fsnotify_put_mark()
298 list_add(&mark->g_list, &destroy_list); in fsnotify_put_mark()
312 static bool fsnotify_get_mark_safe(struct fsnotify_mark *mark) in fsnotify_get_mark_safe() argument
314 if (!mark) in fsnotify_get_mark_safe()
317 if (refcount_inc_not_zero(&mark->refcnt)) { in fsnotify_get_mark_safe()
318 spin_lock(&mark->lock); in fsnotify_get_mark_safe()
319 if (mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED) { in fsnotify_get_mark_safe()
321 atomic_inc(&mark->group->user_waits); in fsnotify_get_mark_safe()
322 spin_unlock(&mark->lock); in fsnotify_get_mark_safe()
325 spin_unlock(&mark->lock); in fsnotify_get_mark_safe()
326 fsnotify_put_mark(mark); in fsnotify_get_mark_safe()
336 static void fsnotify_put_mark_wake(struct fsnotify_mark *mark) in fsnotify_put_mark_wake() argument
338 if (mark) { in fsnotify_put_mark_wake()
339 struct fsnotify_group *group = mark->group; in fsnotify_put_mark_wake()
341 fsnotify_put_mark(mark); in fsnotify_put_mark_wake()
399 void fsnotify_detach_mark(struct fsnotify_mark *mark) in fsnotify_detach_mark() argument
401 struct fsnotify_group *group = mark->group; in fsnotify_detach_mark()
405 refcount_read(&mark->refcnt) < 1 + in fsnotify_detach_mark()
406 !!(mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED)); in fsnotify_detach_mark()
408 spin_lock(&mark->lock); in fsnotify_detach_mark()
410 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED)) { in fsnotify_detach_mark()
411 spin_unlock(&mark->lock); in fsnotify_detach_mark()
414 mark->flags &= ~FSNOTIFY_MARK_FLAG_ATTACHED; in fsnotify_detach_mark()
415 list_del_init(&mark->g_list); in fsnotify_detach_mark()
416 spin_unlock(&mark->lock); in fsnotify_detach_mark()
419 fsnotify_put_mark(mark); in fsnotify_detach_mark()
430 void fsnotify_free_mark(struct fsnotify_mark *mark) in fsnotify_free_mark() argument
432 struct fsnotify_group *group = mark->group; in fsnotify_free_mark()
434 spin_lock(&mark->lock); in fsnotify_free_mark()
436 if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) { in fsnotify_free_mark()
437 spin_unlock(&mark->lock); in fsnotify_free_mark()
440 mark->flags &= ~FSNOTIFY_MARK_FLAG_ALIVE; in fsnotify_free_mark()
441 spin_unlock(&mark->lock); in fsnotify_free_mark()
449 group->ops->freeing_mark(mark, group); in fsnotify_free_mark()
452 void fsnotify_destroy_mark(struct fsnotify_mark *mark, in fsnotify_destroy_mark() argument
456 fsnotify_detach_mark(mark); in fsnotify_destroy_mark()
458 fsnotify_free_mark(mark); in fsnotify_destroy_mark()
574 static int fsnotify_add_mark_list(struct fsnotify_mark *mark, in fsnotify_add_mark_list() argument
591 spin_lock(&mark->lock); in fsnotify_add_mark_list()
594 spin_unlock(&mark->lock); in fsnotify_add_mark_list()
624 hlist_add_head_rcu(&mark->obj_list, &conn->list); in fsnotify_add_mark_list()
632 if ((lmark->group == mark->group) && in fsnotify_add_mark_list()
639 cmp = fsnotify_compare_groups(lmark->group, mark->group); in fsnotify_add_mark_list()
641 hlist_add_before_rcu(&mark->obj_list, &lmark->obj_list); in fsnotify_add_mark_list()
648 hlist_add_behind_rcu(&mark->obj_list, &last->obj_list); in fsnotify_add_mark_list()
655 WRITE_ONCE(mark->connector, conn); in fsnotify_add_mark_list()
658 spin_unlock(&mark->lock); in fsnotify_add_mark_list()
667 int fsnotify_add_mark_locked(struct fsnotify_mark *mark, in fsnotify_add_mark_locked() argument
671 struct fsnotify_group *group = mark->group; in fsnotify_add_mark_locked()
682 spin_lock(&mark->lock); in fsnotify_add_mark_locked()
683 mark->flags |= FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_ATTACHED; in fsnotify_add_mark_locked()
685 list_add(&mark->g_list, &group->marks_list); in fsnotify_add_mark_locked()
686 fsnotify_get_mark(mark); /* for g_list */ in fsnotify_add_mark_locked()
687 spin_unlock(&mark->lock); in fsnotify_add_mark_locked()
689 ret = fsnotify_add_mark_list(mark, connp, type, allow_dups, fsid); in fsnotify_add_mark_locked()
693 if (mark->mask) in fsnotify_add_mark_locked()
694 fsnotify_recalc_mask(mark->connector); in fsnotify_add_mark_locked()
698 spin_lock(&mark->lock); in fsnotify_add_mark_locked()
699 mark->flags &= ~(FSNOTIFY_MARK_FLAG_ALIVE | in fsnotify_add_mark_locked()
701 list_del_init(&mark->g_list); in fsnotify_add_mark_locked()
702 spin_unlock(&mark->lock); in fsnotify_add_mark_locked()
704 fsnotify_put_mark(mark); in fsnotify_add_mark_locked()
708 int fsnotify_add_mark(struct fsnotify_mark *mark, fsnotify_connp_t *connp, in fsnotify_add_mark() argument
712 struct fsnotify_group *group = mark->group; in fsnotify_add_mark()
715 ret = fsnotify_add_mark_locked(mark, connp, type, allow_dups, fsid); in fsnotify_add_mark()
729 struct fsnotify_mark *mark; in fsnotify_find_mark() local
735 hlist_for_each_entry(mark, &conn->list, obj_list) { in fsnotify_find_mark()
736 if (mark->group == group && in fsnotify_find_mark()
737 (mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED)) { in fsnotify_find_mark()
738 fsnotify_get_mark(mark); in fsnotify_find_mark()
740 return mark; in fsnotify_find_mark()
752 struct fsnotify_mark *lmark, *mark; in fsnotify_clear_marks_by_group() local
771 list_for_each_entry_safe(mark, lmark, &group->marks_list, g_list) { in fsnotify_clear_marks_by_group()
772 if ((1U << mark->connector->type) & type_mask) in fsnotify_clear_marks_by_group()
773 list_move(&mark->g_list, &to_free); in fsnotify_clear_marks_by_group()
784 mark = list_first_entry(head, struct fsnotify_mark, g_list); in fsnotify_clear_marks_by_group()
785 fsnotify_get_mark(mark); in fsnotify_clear_marks_by_group()
786 fsnotify_detach_mark(mark); in fsnotify_clear_marks_by_group()
788 fsnotify_free_mark(mark); in fsnotify_clear_marks_by_group()
789 fsnotify_put_mark(mark); in fsnotify_clear_marks_by_group()
797 struct fsnotify_mark *mark, *old_mark = NULL; in fsnotify_destroy_marks() local
811 hlist_for_each_entry(mark, &conn->list, obj_list) { in fsnotify_destroy_marks()
812 fsnotify_get_mark(mark); in fsnotify_destroy_marks()
816 old_mark = mark; in fsnotify_destroy_marks()
817 fsnotify_destroy_mark(mark, mark->group); in fsnotify_destroy_marks()
835 void fsnotify_init_mark(struct fsnotify_mark *mark, in fsnotify_init_mark() argument
838 memset(mark, 0, sizeof(*mark)); in fsnotify_init_mark()
839 spin_lock_init(&mark->lock); in fsnotify_init_mark()
840 refcount_set(&mark->refcnt, 1); in fsnotify_init_mark()
842 mark->group = group; in fsnotify_init_mark()
843 WRITE_ONCE(mark->connector, NULL); in fsnotify_init_mark()
853 struct fsnotify_mark *mark, *next; in fsnotify_mark_destroy_workfn() local
863 list_for_each_entry_safe(mark, next, &private_destroy_list, g_list) { in fsnotify_mark_destroy_workfn()
864 list_del_init(&mark->g_list); in fsnotify_mark_destroy_workfn()
865 fsnotify_final_mark_destroy(mark); in fsnotify_mark_destroy_workfn()