Lines Matching refs:conn

100 static __u32 *fsnotify_conn_mask_p(struct fsnotify_mark_connector *conn)  in fsnotify_conn_mask_p()  argument
102 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) in fsnotify_conn_mask_p()
103 return &fsnotify_conn_inode(conn)->i_fsnotify_mask; in fsnotify_conn_mask_p()
104 else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT) in fsnotify_conn_mask_p()
105 return &fsnotify_conn_mount(conn)->mnt_fsnotify_mask; in fsnotify_conn_mask_p()
106 else if (conn->type == FSNOTIFY_OBJ_TYPE_SB) in fsnotify_conn_mask_p()
107 return &fsnotify_conn_sb(conn)->s_fsnotify_mask; in fsnotify_conn_mask_p()
111 __u32 fsnotify_conn_mask(struct fsnotify_mark_connector *conn) in fsnotify_conn_mask() argument
113 if (WARN_ON(!fsnotify_valid_obj_type(conn->type))) in fsnotify_conn_mask()
116 return *fsnotify_conn_mask_p(conn); in fsnotify_conn_mask()
119 static void __fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) in __fsnotify_recalc_mask() argument
124 assert_spin_locked(&conn->lock); in __fsnotify_recalc_mask()
126 if (!fsnotify_valid_obj_type(conn->type)) in __fsnotify_recalc_mask()
128 hlist_for_each_entry(mark, &conn->list, obj_list) { in __fsnotify_recalc_mask()
132 *fsnotify_conn_mask_p(conn) = new_mask; in __fsnotify_recalc_mask()
141 void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) in fsnotify_recalc_mask() argument
143 if (!conn) in fsnotify_recalc_mask()
146 spin_lock(&conn->lock); in fsnotify_recalc_mask()
147 __fsnotify_recalc_mask(conn); in fsnotify_recalc_mask()
148 spin_unlock(&conn->lock); in fsnotify_recalc_mask()
149 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) in fsnotify_recalc_mask()
151 fsnotify_conn_inode(conn)); in fsnotify_recalc_mask()
157 struct fsnotify_mark_connector *conn, *free; in fsnotify_connector_destroy_workfn() local
160 conn = connector_destroy_list; in fsnotify_connector_destroy_workfn()
165 while (conn) { in fsnotify_connector_destroy_workfn()
166 free = conn; in fsnotify_connector_destroy_workfn()
167 conn = conn->destroy_next; in fsnotify_connector_destroy_workfn()
187 static void fsnotify_get_sb_connectors(struct fsnotify_mark_connector *conn) in fsnotify_get_sb_connectors() argument
189 struct super_block *sb = fsnotify_connector_sb(conn); in fsnotify_get_sb_connectors()
195 static void fsnotify_put_sb_connectors(struct fsnotify_mark_connector *conn) in fsnotify_put_sb_connectors() argument
197 struct super_block *sb = fsnotify_connector_sb(conn); in fsnotify_put_sb_connectors()
204 struct fsnotify_mark_connector *conn, in fsnotify_detach_connector_from_object() argument
209 *type = conn->type; in fsnotify_detach_connector_from_object()
210 if (conn->type == FSNOTIFY_OBJ_TYPE_DETACHED) in fsnotify_detach_connector_from_object()
213 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) { in fsnotify_detach_connector_from_object()
214 inode = fsnotify_conn_inode(conn); in fsnotify_detach_connector_from_object()
216 } else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT) { in fsnotify_detach_connector_from_object()
217 fsnotify_conn_mount(conn)->mnt_fsnotify_mask = 0; in fsnotify_detach_connector_from_object()
218 } else if (conn->type == FSNOTIFY_OBJ_TYPE_SB) { in fsnotify_detach_connector_from_object()
219 fsnotify_conn_sb(conn)->s_fsnotify_mask = 0; in fsnotify_detach_connector_from_object()
222 fsnotify_put_sb_connectors(conn); in fsnotify_detach_connector_from_object()
223 rcu_assign_pointer(*(conn->obj), NULL); in fsnotify_detach_connector_from_object()
224 conn->obj = NULL; in fsnotify_detach_connector_from_object()
225 conn->type = FSNOTIFY_OBJ_TYPE_DETACHED; in fsnotify_detach_connector_from_object()
253 struct fsnotify_mark_connector *conn = READ_ONCE(mark->connector); in fsnotify_put_mark() local
259 if (!conn) { in fsnotify_put_mark()
269 if (!refcount_dec_and_lock(&mark->refcnt, &conn->lock)) in fsnotify_put_mark()
273 if (hlist_empty(&conn->list)) { in fsnotify_put_mark()
274 objp = fsnotify_detach_connector_from_object(conn, &type); in fsnotify_put_mark()
277 __fsnotify_recalc_mask(conn); in fsnotify_put_mark()
280 spin_unlock(&conn->lock); in fsnotify_put_mark()
286 conn->destroy_next = connector_destroy_list; in fsnotify_put_mark()
287 connector_destroy_list = conn; in fsnotify_put_mark()
503 struct fsnotify_mark_connector *conn; in fsnotify_attach_connector_to_object() local
505 conn = kmem_cache_alloc(fsnotify_mark_connector_cachep, GFP_KERNEL); in fsnotify_attach_connector_to_object()
506 if (!conn) in fsnotify_attach_connector_to_object()
508 spin_lock_init(&conn->lock); in fsnotify_attach_connector_to_object()
509 INIT_HLIST_HEAD(&conn->list); in fsnotify_attach_connector_to_object()
510 conn->type = type; in fsnotify_attach_connector_to_object()
511 conn->obj = connp; in fsnotify_attach_connector_to_object()
514 conn->fsid = *fsid; in fsnotify_attach_connector_to_object()
515 conn->flags = FSNOTIFY_CONN_FLAG_HAS_FSID; in fsnotify_attach_connector_to_object()
517 conn->fsid.val[0] = conn->fsid.val[1] = 0; in fsnotify_attach_connector_to_object()
518 conn->flags = 0; in fsnotify_attach_connector_to_object()
520 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) { in fsnotify_attach_connector_to_object()
521 inode = fsnotify_conn_inode(conn); in fsnotify_attach_connector_to_object()
524 fsnotify_get_sb_connectors(conn); in fsnotify_attach_connector_to_object()
530 if (cmpxchg(connp, NULL, conn)) { in fsnotify_attach_connector_to_object()
534 fsnotify_put_sb_connectors(conn); in fsnotify_attach_connector_to_object()
535 kmem_cache_free(fsnotify_mark_connector_cachep, conn); in fsnotify_attach_connector_to_object()
550 struct fsnotify_mark_connector *conn; in fsnotify_grab_connector() local
554 conn = srcu_dereference(*connp, &fsnotify_mark_srcu); in fsnotify_grab_connector()
555 if (!conn) in fsnotify_grab_connector()
557 spin_lock(&conn->lock); in fsnotify_grab_connector()
558 if (conn->type == FSNOTIFY_OBJ_TYPE_DETACHED) { in fsnotify_grab_connector()
559 spin_unlock(&conn->lock); in fsnotify_grab_connector()
565 return conn; in fsnotify_grab_connector()
579 struct fsnotify_mark_connector *conn; in fsnotify_add_mark_list() local
592 conn = fsnotify_grab_connector(connp); in fsnotify_add_mark_list()
593 if (!conn) { in fsnotify_add_mark_list()
599 } else if (fsid && !(conn->flags & FSNOTIFY_CONN_FLAG_HAS_FSID)) { in fsnotify_add_mark_list()
600 conn->fsid = *fsid; in fsnotify_add_mark_list()
603 conn->flags |= FSNOTIFY_CONN_FLAG_HAS_FSID; in fsnotify_add_mark_list()
604 } else if (fsid && (conn->flags & FSNOTIFY_CONN_FLAG_HAS_FSID) && in fsnotify_add_mark_list()
605 (fsid->val[0] != conn->fsid.val[0] || in fsnotify_add_mark_list()
606 fsid->val[1] != conn->fsid.val[1])) { in fsnotify_add_mark_list()
615 "%x.%x != %x.%x\n", __func__, conn->type, in fsnotify_add_mark_list()
617 conn->fsid.val[0], conn->fsid.val[1]); in fsnotify_add_mark_list()
623 if (hlist_empty(&conn->list)) { in fsnotify_add_mark_list()
624 hlist_add_head_rcu(&mark->obj_list, &conn->list); in fsnotify_add_mark_list()
629 hlist_for_each_entry(lmark, &conn->list, obj_list) { in fsnotify_add_mark_list()
655 WRITE_ONCE(mark->connector, conn); in fsnotify_add_mark_list()
657 spin_unlock(&conn->lock); in fsnotify_add_mark_list()
728 struct fsnotify_mark_connector *conn; in fsnotify_find_mark() local
731 conn = fsnotify_grab_connector(connp); in fsnotify_find_mark()
732 if (!conn) in fsnotify_find_mark()
735 hlist_for_each_entry(mark, &conn->list, obj_list) { in fsnotify_find_mark()
739 spin_unlock(&conn->lock); in fsnotify_find_mark()
743 spin_unlock(&conn->lock); in fsnotify_find_mark()
796 struct fsnotify_mark_connector *conn; in fsnotify_destroy_marks() local
801 conn = fsnotify_grab_connector(connp); in fsnotify_destroy_marks()
802 if (!conn) in fsnotify_destroy_marks()
811 hlist_for_each_entry(mark, &conn->list, obj_list) { in fsnotify_destroy_marks()
813 spin_unlock(&conn->lock); in fsnotify_destroy_marks()
818 spin_lock(&conn->lock); in fsnotify_destroy_marks()
825 objp = fsnotify_detach_connector_from_object(conn, &type); in fsnotify_destroy_marks()
826 spin_unlock(&conn->lock); in fsnotify_destroy_marks()