Lines Matching full:conn
115 static __u32 *fsnotify_conn_mask_p(struct fsnotify_mark_connector *conn) in fsnotify_conn_mask_p() argument
117 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) in fsnotify_conn_mask_p()
118 return &fsnotify_conn_inode(conn)->i_fsnotify_mask; in fsnotify_conn_mask_p()
119 else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT) in fsnotify_conn_mask_p()
120 return &fsnotify_conn_mount(conn)->mnt_fsnotify_mask; in fsnotify_conn_mask_p()
121 else if (conn->type == FSNOTIFY_OBJ_TYPE_SB) in fsnotify_conn_mask_p()
122 return &fsnotify_conn_sb(conn)->s_fsnotify_mask; in fsnotify_conn_mask_p()
126 __u32 fsnotify_conn_mask(struct fsnotify_mark_connector *conn) in fsnotify_conn_mask() argument
128 if (WARN_ON(!fsnotify_valid_obj_type(conn->type))) in fsnotify_conn_mask()
131 return READ_ONCE(*fsnotify_conn_mask_p(conn)); in fsnotify_conn_mask()
168 struct fsnotify_mark_connector *conn) in fsnotify_update_sb_watchers() argument
171 bool is_watched = conn->flags & FSNOTIFY_CONN_FLAG_IS_WATCHED; in fsnotify_update_sb_watchers()
175 if (conn->obj) in fsnotify_update_sb_watchers()
176 first_mark = hlist_entry_safe(conn->list.first, in fsnotify_update_sb_watchers()
188 for (unsigned int p = conn->prio + 1; p <= highest_prio; p++) in fsnotify_update_sb_watchers()
190 for (unsigned int p = conn->prio; p > highest_prio; p--) in fsnotify_update_sb_watchers()
192 conn->prio = highest_prio; in fsnotify_update_sb_watchers()
197 conn->flags |= FSNOTIFY_CONN_FLAG_IS_WATCHED; in fsnotify_update_sb_watchers()
200 conn->flags &= ~FSNOTIFY_CONN_FLAG_IS_WATCHED; in fsnotify_update_sb_watchers()
213 static struct inode *fsnotify_update_iref(struct fsnotify_mark_connector *conn, in fsnotify_update_iref() argument
216 bool has_iref = conn->flags & FSNOTIFY_CONN_FLAG_HAS_IREF; in fsnotify_update_iref()
219 if (conn->type != FSNOTIFY_OBJ_TYPE_INODE || in fsnotify_update_iref()
225 fsnotify_get_inode_ref(fsnotify_conn_inode(conn)); in fsnotify_update_iref()
226 conn->flags |= FSNOTIFY_CONN_FLAG_HAS_IREF; in fsnotify_update_iref()
229 inode = fsnotify_conn_inode(conn); in fsnotify_update_iref()
230 conn->flags &= ~FSNOTIFY_CONN_FLAG_HAS_IREF; in fsnotify_update_iref()
236 static void *__fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) in __fsnotify_recalc_mask() argument
242 assert_spin_locked(&conn->lock); in __fsnotify_recalc_mask()
244 if (!fsnotify_valid_obj_type(conn->type)) in __fsnotify_recalc_mask()
246 hlist_for_each_entry(mark, &conn->list, obj_list) { in __fsnotify_recalc_mask()
250 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE && in __fsnotify_recalc_mask()
256 * confusing readers not holding conn->lock with partial updates. in __fsnotify_recalc_mask()
258 WRITE_ONCE(*fsnotify_conn_mask_p(conn), new_mask); in __fsnotify_recalc_mask()
260 return fsnotify_update_iref(conn, want_iref); in __fsnotify_recalc_mask()
264 struct fsnotify_mark_connector *conn) in fsnotify_conn_watches_children() argument
266 if (conn->type != FSNOTIFY_OBJ_TYPE_INODE) in fsnotify_conn_watches_children()
269 return fsnotify_inode_watches_children(fsnotify_conn_inode(conn)); in fsnotify_conn_watches_children()
273 struct fsnotify_mark_connector *conn) in fsnotify_conn_set_children_dentry_flags() argument
275 if (conn->type != FSNOTIFY_OBJ_TYPE_INODE) in fsnotify_conn_set_children_dentry_flags()
278 fsnotify_set_children_dentry_flags(fsnotify_conn_inode(conn)); in fsnotify_conn_set_children_dentry_flags()
287 void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) in fsnotify_recalc_mask() argument
291 if (!conn) in fsnotify_recalc_mask()
294 spin_lock(&conn->lock); in fsnotify_recalc_mask()
295 update_children = !fsnotify_conn_watches_children(conn); in fsnotify_recalc_mask()
296 __fsnotify_recalc_mask(conn); in fsnotify_recalc_mask()
297 update_children &= fsnotify_conn_watches_children(conn); in fsnotify_recalc_mask()
298 spin_unlock(&conn->lock); in fsnotify_recalc_mask()
305 fsnotify_conn_set_children_dentry_flags(conn); in fsnotify_recalc_mask()
311 struct fsnotify_mark_connector *conn, *free; in fsnotify_connector_destroy_workfn() local
314 conn = connector_destroy_list; in fsnotify_connector_destroy_workfn()
319 while (conn) { in fsnotify_connector_destroy_workfn()
320 free = conn; in fsnotify_connector_destroy_workfn()
321 conn = conn->destroy_next; in fsnotify_connector_destroy_workfn()
327 struct fsnotify_mark_connector *conn, in fsnotify_detach_connector_from_object() argument
330 fsnotify_connp_t *connp = fsnotify_object_connp(conn->obj, conn->type); in fsnotify_detach_connector_from_object()
331 struct super_block *sb = fsnotify_connector_sb(conn); in fsnotify_detach_connector_from_object()
334 *type = conn->type; in fsnotify_detach_connector_from_object()
335 if (conn->type == FSNOTIFY_OBJ_TYPE_DETACHED) in fsnotify_detach_connector_from_object()
338 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) { in fsnotify_detach_connector_from_object()
339 inode = fsnotify_conn_inode(conn); in fsnotify_detach_connector_from_object()
343 if (!(conn->flags & FSNOTIFY_CONN_FLAG_HAS_IREF)) in fsnotify_detach_connector_from_object()
345 } else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT) { in fsnotify_detach_connector_from_object()
346 fsnotify_conn_mount(conn)->mnt_fsnotify_mask = 0; in fsnotify_detach_connector_from_object()
347 } else if (conn->type == FSNOTIFY_OBJ_TYPE_SB) { in fsnotify_detach_connector_from_object()
348 fsnotify_conn_sb(conn)->s_fsnotify_mask = 0; in fsnotify_detach_connector_from_object()
352 conn->obj = NULL; in fsnotify_detach_connector_from_object()
353 conn->type = FSNOTIFY_OBJ_TYPE_DETACHED; in fsnotify_detach_connector_from_object()
354 fsnotify_update_sb_watchers(sb, conn); in fsnotify_detach_connector_from_object()
382 struct fsnotify_mark_connector *conn = READ_ONCE(mark->connector); in fsnotify_put_mark() local
388 if (!conn) { in fsnotify_put_mark()
398 if (!refcount_dec_and_lock(&mark->refcnt, &conn->lock)) in fsnotify_put_mark()
402 if (hlist_empty(&conn->list)) { in fsnotify_put_mark()
403 objp = fsnotify_detach_connector_from_object(conn, &type); in fsnotify_put_mark()
406 struct super_block *sb = fsnotify_connector_sb(conn); in fsnotify_put_mark()
410 fsnotify_update_sb_watchers(sb, conn); in fsnotify_put_mark()
411 objp = __fsnotify_recalc_mask(conn); in fsnotify_put_mark()
412 type = conn->type; in fsnotify_put_mark()
415 spin_unlock(&conn->lock); in fsnotify_put_mark()
421 conn->destroy_next = connector_destroy_list; in fsnotify_put_mark()
422 connector_destroy_list = conn; in fsnotify_put_mark()
654 struct fsnotify_mark_connector *conn; in fsnotify_attach_connector_to_object() local
656 conn = kmem_cache_alloc(fsnotify_mark_connector_cachep, GFP_KERNEL); in fsnotify_attach_connector_to_object()
657 if (!conn) in fsnotify_attach_connector_to_object()
659 spin_lock_init(&conn->lock); in fsnotify_attach_connector_to_object()
660 INIT_HLIST_HEAD(&conn->list); in fsnotify_attach_connector_to_object()
661 conn->flags = 0; in fsnotify_attach_connector_to_object()
662 conn->prio = 0; in fsnotify_attach_connector_to_object()
663 conn->type = obj_type; in fsnotify_attach_connector_to_object()
664 conn->obj = obj; in fsnotify_attach_connector_to_object()
670 if (cmpxchg(connp, NULL, conn)) { in fsnotify_attach_connector_to_object()
672 kmem_cache_free(fsnotify_mark_connector_cachep, conn); in fsnotify_attach_connector_to_object()
686 struct fsnotify_mark_connector *conn; in fsnotify_grab_connector() local
690 conn = srcu_dereference(*connp, &fsnotify_mark_srcu); in fsnotify_grab_connector()
691 if (!conn) in fsnotify_grab_connector()
693 spin_lock(&conn->lock); in fsnotify_grab_connector()
694 if (conn->type == FSNOTIFY_OBJ_TYPE_DETACHED) { in fsnotify_grab_connector()
695 spin_unlock(&conn->lock); in fsnotify_grab_connector()
701 return conn; in fsnotify_grab_connector()
715 struct fsnotify_mark_connector *conn; in fsnotify_add_mark_list() local
736 conn = fsnotify_grab_connector(connp); in fsnotify_add_mark_list()
737 if (!conn) { in fsnotify_add_mark_list()
746 if (hlist_empty(&conn->list)) { in fsnotify_add_mark_list()
747 hlist_add_head_rcu(&mark->obj_list, &conn->list); in fsnotify_add_mark_list()
752 hlist_for_each_entry(lmark, &conn->list, obj_list) { in fsnotify_add_mark_list()
773 fsnotify_update_sb_watchers(sb, conn); in fsnotify_add_mark_list()
779 WRITE_ONCE(mark->connector, conn); in fsnotify_add_mark_list()
781 spin_unlock(&conn->lock); in fsnotify_add_mark_list()
852 struct fsnotify_mark_connector *conn; in fsnotify_find_mark() local
858 conn = fsnotify_grab_connector(connp); in fsnotify_find_mark()
859 if (!conn) in fsnotify_find_mark()
862 hlist_for_each_entry(mark, &conn->list, obj_list) { in fsnotify_find_mark()
866 spin_unlock(&conn->lock); in fsnotify_find_mark()
870 spin_unlock(&conn->lock); in fsnotify_find_mark()
923 struct fsnotify_mark_connector *conn; in fsnotify_destroy_marks() local
928 conn = fsnotify_grab_connector(connp); in fsnotify_destroy_marks()
929 if (!conn) in fsnotify_destroy_marks()
933 * fsnotify_clear_marks_by_group() and once we drop the conn->lock, the in fsnotify_destroy_marks()
936 * iteration after regaining conn->lock. in fsnotify_destroy_marks()
938 hlist_for_each_entry(mark, &conn->list, obj_list) { in fsnotify_destroy_marks()
940 spin_unlock(&conn->lock); in fsnotify_destroy_marks()
945 spin_lock(&conn->lock); in fsnotify_destroy_marks()
952 objp = fsnotify_detach_connector_from_object(conn, &type); in fsnotify_destroy_marks()
953 spin_unlock(&conn->lock); in fsnotify_destroy_marks()