Lines Matching refs:conn
100 static __u32 *fsnotify_conn_mask_p(struct fsnotify_mark_connector *conn)
102 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)
103 return &fsnotify_conn_inode(conn)->i_fsnotify_mask;
104 else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT)
105 return &fsnotify_conn_mount(conn)->mnt_fsnotify_mask;
106 else if (conn->type == FSNOTIFY_OBJ_TYPE_SB)
107 return &fsnotify_conn_sb(conn)->s_fsnotify_mask;
111 __u32 fsnotify_conn_mask(struct fsnotify_mark_connector *conn)
113 if (WARN_ON(!fsnotify_valid_obj_type(conn->type)))
116 return *fsnotify_conn_mask_p(conn);
133 static struct inode *fsnotify_update_iref(struct fsnotify_mark_connector *conn,
136 bool has_iref = conn->flags & FSNOTIFY_CONN_FLAG_HAS_IREF;
139 if (conn->type != FSNOTIFY_OBJ_TYPE_INODE ||
145 fsnotify_get_inode_ref(fsnotify_conn_inode(conn));
146 conn->flags |= FSNOTIFY_CONN_FLAG_HAS_IREF;
149 inode = fsnotify_conn_inode(conn);
150 conn->flags &= ~FSNOTIFY_CONN_FLAG_HAS_IREF;
156 static void *__fsnotify_recalc_mask(struct fsnotify_mark_connector *conn)
162 assert_spin_locked(&conn->lock);
164 if (!fsnotify_valid_obj_type(conn->type))
166 hlist_for_each_entry(mark, &conn->list, obj_list) {
170 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE &&
174 *fsnotify_conn_mask_p(conn) = new_mask;
176 return fsnotify_update_iref(conn, want_iref);
185 void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn)
187 if (!conn)
190 spin_lock(&conn->lock);
191 __fsnotify_recalc_mask(conn);
192 spin_unlock(&conn->lock);
193 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)
195 fsnotify_conn_inode(conn));
201 struct fsnotify_mark_connector *conn, *free;
204 conn = connector_destroy_list;
209 while (conn) {
210 free = conn;
211 conn = conn->destroy_next;
225 static void fsnotify_get_sb_connectors(struct fsnotify_mark_connector *conn)
227 struct super_block *sb = fsnotify_connector_sb(conn);
233 static void fsnotify_put_sb_connectors(struct fsnotify_mark_connector *conn)
235 struct super_block *sb = fsnotify_connector_sb(conn);
242 struct fsnotify_mark_connector *conn,
247 *type = conn->type;
248 if (conn->type == FSNOTIFY_OBJ_TYPE_DETACHED)
251 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) {
252 inode = fsnotify_conn_inode(conn);
256 if (!(conn->flags & FSNOTIFY_CONN_FLAG_HAS_IREF))
258 } else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT) {
259 fsnotify_conn_mount(conn)->mnt_fsnotify_mask = 0;
260 } else if (conn->type == FSNOTIFY_OBJ_TYPE_SB) {
261 fsnotify_conn_sb(conn)->s_fsnotify_mask = 0;
264 fsnotify_put_sb_connectors(conn);
265 rcu_assign_pointer(*(conn->obj), NULL);
266 conn->obj = NULL;
267 conn->type = FSNOTIFY_OBJ_TYPE_DETACHED;
295 struct fsnotify_mark_connector *conn = READ_ONCE(mark->connector);
301 if (!conn) {
311 if (!refcount_dec_and_lock(&mark->refcnt, &conn->lock))
315 if (hlist_empty(&conn->list)) {
316 objp = fsnotify_detach_connector_from_object(conn, &type);
319 objp = __fsnotify_recalc_mask(conn);
320 type = conn->type;
323 spin_unlock(&conn->lock);
329 conn->destroy_next = connector_destroy_list;
330 connector_destroy_list = conn;
543 struct fsnotify_mark_connector *conn;
545 conn = kmem_cache_alloc(fsnotify_mark_connector_cachep, GFP_KERNEL);
546 if (!conn)
548 spin_lock_init(&conn->lock);
549 INIT_HLIST_HEAD(&conn->list);
550 conn->flags = 0;
551 conn->type = obj_type;
552 conn->obj = connp;
555 conn->fsid = *fsid;
556 conn->flags = FSNOTIFY_CONN_FLAG_HAS_FSID;
558 conn->fsid.val[0] = conn->fsid.val[1] = 0;
559 conn->flags = 0;
561 fsnotify_get_sb_connectors(conn);
567 if (cmpxchg(connp, NULL, conn)) {
569 fsnotify_put_sb_connectors(conn);
570 kmem_cache_free(fsnotify_mark_connector_cachep, conn);
585 struct fsnotify_mark_connector *conn;
589 conn = srcu_dereference(*connp, &fsnotify_mark_srcu);
590 if (!conn)
592 spin_lock(&conn->lock);
593 if (conn->type == FSNOTIFY_OBJ_TYPE_DETACHED) {
594 spin_unlock(&conn->lock);
600 return conn;
615 struct fsnotify_mark_connector *conn;
628 conn = fsnotify_grab_connector(connp);
629 if (!conn) {
636 } else if (fsid && !(conn->flags & FSNOTIFY_CONN_FLAG_HAS_FSID)) {
637 conn->fsid = *fsid;
640 conn->flags |= FSNOTIFY_CONN_FLAG_HAS_FSID;
641 } else if (fsid && (conn->flags & FSNOTIFY_CONN_FLAG_HAS_FSID) &&
642 (fsid->val[0] != conn->fsid.val[0] ||
643 fsid->val[1] != conn->fsid.val[1])) {
647 * Only allow setting conn->fsid once to non zero fsid.
649 * conn->fsid.
652 "%x.%x != %x.%x\n", __func__, conn->type,
654 conn->fsid.val[0], conn->fsid.val[1]);
660 if (hlist_empty(&conn->list)) {
661 hlist_add_head_rcu(&mark->obj_list, &conn->list);
666 hlist_for_each_entry(lmark, &conn->list, obj_list) {
692 WRITE_ONCE(mark->connector, conn);
694 spin_unlock(&conn->lock);
765 struct fsnotify_mark_connector *conn;
768 conn = fsnotify_grab_connector(connp);
769 if (!conn)
772 hlist_for_each_entry(mark, &conn->list, obj_list) {
776 spin_unlock(&conn->lock);
780 spin_unlock(&conn->lock);
833 struct fsnotify_mark_connector *conn;
838 conn = fsnotify_grab_connector(connp);
839 if (!conn)
843 * fsnotify_clear_marks_by_group() and once we drop the conn->lock, the
846 * iteration after regaining conn->lock.
848 hlist_for_each_entry(mark, &conn->list, obj_list) {
850 spin_unlock(&conn->lock);
855 spin_lock(&conn->lock);
862 objp = fsnotify_detach_connector_from_object(conn, &type);
863 spin_unlock(&conn->lock);