Lines Matching refs:node

109 tmpfs_init_vnode(struct vnode *vp, tmpfs_node_t *node)  in tmpfs_init_vnode()  argument
113 KASSERT(node->tn_vnode == NULL); in tmpfs_init_vnode()
116 if (node->tn_type == VREG) { in tmpfs_init_vnode()
117 slock = node->tn_spec.tn_reg.tn_aobj->vmobjlock; in tmpfs_init_vnode()
123 vp->v_type = node->tn_type; in tmpfs_init_vnode()
130 spec_node_init(vp, node->tn_spec.tn_dev.tn_rdev); in tmpfs_init_vnode()
136 if (node->tn_spec.tn_dir.tn_parent == node) in tmpfs_init_vnode()
149 vp->v_data = node; in tmpfs_init_vnode()
150 node->tn_vnode = vp; in tmpfs_init_vnode()
151 uvm_vnp_setsize(vp, node->tn_size); in tmpfs_init_vnode()
152 KASSERT(node->tn_mode != VNOVAL); in tmpfs_init_vnode()
153 cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true); in tmpfs_init_vnode()
163 tmpfs_node_t *node; in tmpfs_loadvnode() local
165 KASSERT(key_len == sizeof(node)); in tmpfs_loadvnode()
166 memcpy(&node, key, key_len); in tmpfs_loadvnode()
168 if (node->tn_links == 0) in tmpfs_loadvnode()
171 tmpfs_init_vnode(vp, node); in tmpfs_loadvnode()
188 tmpfs_node_t *node, *dnode; in tmpfs_newvnode() local
204 node = tmpfs_node_get(tmp); in tmpfs_newvnode()
205 if (node == NULL) in tmpfs_newvnode()
209 node->tn_links = 0; in tmpfs_newvnode()
210 node->tn_vnode = NULL; in tmpfs_newvnode()
211 node->tn_holdcount = 0; in tmpfs_newvnode()
212 node->tn_dirent_hint = NULL; in tmpfs_newvnode()
219 node->tn_id = (ino_t)((uintptr_t)node / sizeof(*node)); in tmpfs_newvnode()
225 node->tn_gen = TMPFS_NODE_GEN_MASK & cprng_fast32(); in tmpfs_newvnode()
226 } while (node->tn_gen == 0); in tmpfs_newvnode()
230 node->tn_type = vap->va_type; in tmpfs_newvnode()
231 node->tn_size = 0; in tmpfs_newvnode()
232 node->tn_flags = 0; in tmpfs_newvnode()
233 node->tn_lockf = NULL; in tmpfs_newvnode()
235 node->tn_tflags = 0; in tmpfs_newvnode()
236 vfs_timestamp(&node->tn_atime); in tmpfs_newvnode()
237 node->tn_birthtime = node->tn_atime; in tmpfs_newvnode()
238 node->tn_ctime = node->tn_atime; in tmpfs_newvnode()
239 node->tn_mtime = node->tn_atime; in tmpfs_newvnode()
240 mutex_init(&node->tn_timelock, MUTEX_DEFAULT, IPL_NONE); in tmpfs_newvnode()
244 node->tn_uid = vap->va_uid; in tmpfs_newvnode()
245 node->tn_gid = vap->va_gid; in tmpfs_newvnode()
249 node->tn_uid = kauth_cred_geteuid(cred); in tmpfs_newvnode()
250 node->tn_gid = dnode->tn_gid; in tmpfs_newvnode()
253 node->tn_mode = vap->va_mode; in tmpfs_newvnode()
256 switch (node->tn_type) { in tmpfs_newvnode()
261 node->tn_spec.tn_dev.tn_rdev = vap->va_rdev; in tmpfs_newvnode()
265 TAILQ_INIT(&node->tn_spec.tn_dir.tn_dir); in tmpfs_newvnode()
266 node->tn_spec.tn_dir.tn_parent = NULL; in tmpfs_newvnode()
267 node->tn_spec.tn_dir.tn_seq_arena = NULL; in tmpfs_newvnode()
268 node->tn_spec.tn_dir.tn_next_seq = TMPFS_DIRSEQ_START; in tmpfs_newvnode()
269 node->tn_spec.tn_dir.tn_readdir_lastp = NULL; in tmpfs_newvnode()
272 node->tn_links++; in tmpfs_newvnode()
278 node->tn_size = 0; in tmpfs_newvnode()
279 node->tn_spec.tn_lnk.tn_link = NULL; in tmpfs_newvnode()
283 node->tn_spec.tn_reg.tn_aobj = in tmpfs_newvnode()
285 node->tn_spec.tn_reg.tn_aobj_pages = 0; in tmpfs_newvnode()
292 tmpfs_init_vnode(vp, node); in tmpfs_newvnode()
295 LIST_INSERT_HEAD(&tmp->tm_nodes, node, tn_entries); in tmpfs_newvnode()
309 tmpfs_free_node(tmpfs_mount_t *tmp, tmpfs_node_t *node) in tmpfs_free_node() argument
315 hold = atomic_or_32_nv(&node->tn_holdcount, TMPFS_NODE_RECLAIMED); in tmpfs_free_node()
321 LIST_REMOVE(node, tn_entries); in tmpfs_free_node()
324 switch (node->tn_type) { in tmpfs_free_node()
326 if (node->tn_size > 0) { in tmpfs_free_node()
327 tmpfs_strname_free(tmp, node->tn_spec.tn_lnk.tn_link, in tmpfs_free_node()
328 node->tn_size); in tmpfs_free_node()
336 objsz = PAGE_SIZE * node->tn_spec.tn_reg.tn_aobj_pages; in tmpfs_free_node()
340 if (node->tn_spec.tn_reg.tn_aobj != NULL) { in tmpfs_free_node()
341 uao_detach(node->tn_spec.tn_reg.tn_aobj); in tmpfs_free_node()
345 KASSERT(node->tn_size == 0); in tmpfs_free_node()
346 KASSERT(node->tn_spec.tn_dir.tn_seq_arena == NULL); in tmpfs_free_node()
347 KASSERT(TAILQ_EMPTY(&node->tn_spec.tn_dir.tn_dir)); in tmpfs_free_node()
348 KASSERT(node->tn_spec.tn_dir.tn_parent == NULL || in tmpfs_free_node()
349 node == tmp->tm_root); in tmpfs_free_node()
354 KASSERT(node->tn_vnode == NULL); in tmpfs_free_node()
355 KASSERT(node->tn_links == 0); in tmpfs_free_node()
357 mutex_destroy(&node->tn_timelock); in tmpfs_free_node()
358 tmpfs_node_put(tmp, node); in tmpfs_free_node()
372 tmpfs_node_t *dnode = VP_TO_TMPFS_DIR(dvp), *node; in tmpfs_construct_node() local
417 node = VP_TO_TMPFS_NODE(*vpp); in tmpfs_construct_node()
420 node->tn_spec.tn_lnk.tn_link = slink; in tmpfs_construct_node()
421 node->tn_size = ssize; in tmpfs_construct_node()
433 tmpfs_dir_attach(dnode, de, node); in tmpfs_construct_node()
437 node->tn_flags |= UF_OPAQUE; in tmpfs_construct_node()
498 tmpfs_dir_attach(tmpfs_node_t *dnode, tmpfs_dirent_t *de, tmpfs_node_t *node) in tmpfs_dir_attach() argument
511 de->td_node = node; in tmpfs_dir_attach()
512 if (node != TMPFS_NODE_WHITEOUT) { in tmpfs_dir_attach()
513 KASSERT(node->tn_links < LINK_MAX); in tmpfs_dir_attach()
514 node->tn_links++; in tmpfs_dir_attach()
517 node->tn_dirent_hint = de; in tmpfs_dir_attach()
529 if (node != TMPFS_NODE_WHITEOUT && node->tn_type == VDIR) { in tmpfs_dir_attach()
531 KASSERT(node->tn_spec.tn_dir.tn_parent == NULL); in tmpfs_dir_attach()
532 node->tn_spec.tn_dir.tn_parent = dnode; in tmpfs_dir_attach()
539 TMPFS_VALIDATE_DIR(node); in tmpfs_dir_attach()
556 tmpfs_node_t *node = de->td_node; in tmpfs_dir_detach() local
561 if (__predict_true(node != TMPFS_NODE_WHITEOUT)) { in tmpfs_dir_detach()
563 node->tn_dirent_hint = NULL; in tmpfs_dir_detach()
565 KASSERT(node->tn_links > 0); in tmpfs_dir_detach()
566 node->tn_links--; in tmpfs_dir_detach()
569 if (node->tn_type == VDIR) { in tmpfs_dir_detach()
570 KASSERT(node->tn_spec.tn_dir.tn_parent == dnode); in tmpfs_dir_detach()
571 node->tn_spec.tn_dir.tn_parent = NULL; in tmpfs_dir_detach()
600 tmpfs_dir_lookup(tmpfs_node_t *node, struct componentname *cnp) in tmpfs_dir_lookup() argument
606 KASSERT(VOP_ISLOCKED(node->tn_vnode)); in tmpfs_dir_lookup()
609 TMPFS_VALIDATE_DIR(node); in tmpfs_dir_lookup()
611 TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) { in tmpfs_dir_lookup()
628 tmpfs_dir_cached(tmpfs_node_t *node) in tmpfs_dir_cached() argument
630 tmpfs_dirent_t *de = node->tn_dirent_hint; in tmpfs_dir_cached()
632 KASSERT(VOP_ISLOCKED(node->tn_vnode)); in tmpfs_dir_cached()
637 KASSERT(de->td_node == node); in tmpfs_dir_cached()
643 return (node->tn_type != VDIR && node->tn_links > 1) ? NULL : de; in tmpfs_dir_cached()
737 tmpfs_dir_lookupbyseq(tmpfs_node_t *node, off_t seq) in tmpfs_dir_lookupbyseq() argument
739 tmpfs_dirent_t *de = node->tn_spec.tn_dir.tn_readdir_lastp; in tmpfs_dir_lookupbyseq()
741 TMPFS_VALIDATE_DIR(node); in tmpfs_dir_lookupbyseq()
751 TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) { in tmpfs_dir_lookupbyseq()
765 tmpfs_dir_getdotents(tmpfs_node_t *node, struct dirent *dp, struct uio *uio) in tmpfs_dir_getdotents() argument
773 dp->d_fileno = node->tn_id; in tmpfs_dir_getdotents()
778 dp->d_fileno = node->tn_spec.tn_dir.tn_parent->tn_id; in tmpfs_dir_getdotents()
780 de = TAILQ_FIRST(&node->tn_spec.tn_dir.tn_dir); in tmpfs_dir_getdotents()
781 next = de ? tmpfs_dir_getseq(node, de) : TMPFS_DIRSEQ_EOF; in tmpfs_dir_getdotents()
808 tmpfs_dir_getdents(tmpfs_node_t *node, struct uio *uio, off_t *cntp) in tmpfs_dir_getdents() argument
814 KASSERT(VOP_ISLOCKED(node->tn_vnode)); in tmpfs_dir_getdents()
815 TMPFS_VALIDATE_DIR(node); in tmpfs_dir_getdents()
824 if ((error = tmpfs_dir_getdotents(node, &dent, uio)) != 0) { in tmpfs_dir_getdents()
830 if ((error = tmpfs_dir_getdotents(node, &dent, uio)) != 0) { in tmpfs_dir_getdents()
842 de = tmpfs_dir_lookupbyseq(node, uio->uio_offset); in tmpfs_dir_getdents()
883 uio->uio_offset = de ? tmpfs_dir_getseq(node, de) : TMPFS_DIRSEQ_EOF; in tmpfs_dir_getdents()
884 node->tn_spec.tn_dir.tn_readdir_lastp = de; in tmpfs_dir_getdents()
886 tmpfs_update(node->tn_vnode, TMPFS_UPDATE_ATIME); in tmpfs_dir_getdents()
904 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_reg_resize() local
905 struct uvm_object *uobj = node->tn_spec.tn_reg.tn_aobj; in tmpfs_reg_resize()
915 oldsize = node->tn_size; in tmpfs_reg_resize()
918 KASSERT(oldpages == node->tn_spec.tn_reg.tn_aobj_pages); in tmpfs_reg_resize()
932 zerolen = MIN(round_page(newsize), node->tn_size) - newsize; in tmpfs_reg_resize()
936 node->tn_spec.tn_reg.tn_aobj_pages = newpages; in tmpfs_reg_resize()
937 node->tn_size = newsize; in tmpfs_reg_resize()
960 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chflags() local
975 if ((flags & SF_SETTABLE) != (node->tn_flags & SF_SETTABLE)) { in tmpfs_chflags()
984 if (node->tn_flags & (SF_IMMUTABLE | SF_APPEND)) { in tmpfs_chflags()
989 genfs_can_chflags(vp, cred, node->tn_uid, changing_sysflags)); in tmpfs_chflags()
1004 node->tn_flags &= SF_SETTABLE; in tmpfs_chflags()
1005 node->tn_flags |= (flags & UF_SETTABLE); in tmpfs_chflags()
1007 node->tn_flags = flags; in tmpfs_chflags()
1019 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chmod() local
1029 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chmod()
1033 NULL, genfs_can_chmod(vp, cred, node->tn_uid, node->tn_gid, mode)); in tmpfs_chmod()
1037 node->tn_mode = (mode & ALLPERMS); in tmpfs_chmod()
1039 cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true); in tmpfs_chmod()
1052 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chown() local
1060 uid = node->tn_uid; in tmpfs_chown()
1063 gid = node->tn_gid; in tmpfs_chown()
1071 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chown()
1075 NULL, genfs_can_chown(vp, cred, node->tn_uid, node->tn_gid, uid, in tmpfs_chown()
1080 node->tn_uid = uid; in tmpfs_chown()
1081 node->tn_gid = gid; in tmpfs_chown()
1083 cache_enter_id(vp, node->tn_mode, node->tn_uid, node->tn_gid, true); in tmpfs_chown()
1093 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chsize() local
1122 if (node->tn_flags & (IMMUTABLE | APPEND)) { in tmpfs_chsize()
1131 if (node->tn_size != length && in tmpfs_chsize()
1147 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chtimes() local
1157 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chtimes()
1161 genfs_can_chtimes(vp, cred, node->tn_uid, vaflags)); in tmpfs_chtimes()
1165 mutex_enter(&node->tn_timelock); in tmpfs_chtimes()
1167 atomic_and_uint(&node->tn_tflags, ~TMPFS_UPDATE_ATIME); in tmpfs_chtimes()
1168 node->tn_atime = *atime; in tmpfs_chtimes()
1171 atomic_and_uint(&node->tn_tflags, ~TMPFS_UPDATE_MTIME); in tmpfs_chtimes()
1172 node->tn_mtime = *mtime; in tmpfs_chtimes()
1175 node->tn_birthtime = *btime; in tmpfs_chtimes()
1177 mutex_exit(&node->tn_timelock); in tmpfs_chtimes()
1187 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_update_locked() local
1190 KASSERT(mutex_owned(&node->tn_timelock)); in tmpfs_update_locked()
1192 if ((tflags |= atomic_swap_uint(&node->tn_tflags, 0)) == 0) { in tmpfs_update_locked()
1198 node->tn_atime = nowtm; in tmpfs_update_locked()
1201 node->tn_mtime = nowtm; in tmpfs_update_locked()
1204 node->tn_ctime = nowtm; in tmpfs_update_locked()
1214 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_update() local
1216 if ((tflags | atomic_load_relaxed(&node->tn_tflags)) == 0) { in tmpfs_update()
1220 mutex_enter(&node->tn_timelock); in tmpfs_update()
1222 mutex_exit(&node->tn_timelock); in tmpfs_update()
1231 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_update_lazily() local
1234 cur = atomic_load_relaxed(&node->tn_tflags); in tmpfs_update_lazily()
1236 atomic_or_uint(&node->tn_tflags, tflags); in tmpfs_update_lazily()