Lines Matching refs:node
105 mode_t mode, char *target, dev_t rdev, tmpfs_node_t **node) in tmpfs_alloc_node() argument
208 *node = nnode; in tmpfs_alloc_node()
217 tmpfs_free_node(tmpfs_mount_t *tmp, tmpfs_node_t *node) in tmpfs_free_node() argument
222 LIST_REMOVE(node, tn_entries); in tmpfs_free_node()
225 switch (node->tn_type) { in tmpfs_free_node()
227 if (node->tn_size > 0) { in tmpfs_free_node()
228 KASSERT(node->tn_size <= SIZE_MAX); in tmpfs_free_node()
229 tmpfs_strname_free(tmp, node->tn_spec.tn_lnk.tn_link, in tmpfs_free_node()
230 node->tn_size); in tmpfs_free_node()
238 objsz = PAGE_SIZE * node->tn_spec.tn_reg.tn_aobj_pages; in tmpfs_free_node()
242 if (node->tn_spec.tn_reg.tn_aobj != NULL) { in tmpfs_free_node()
243 uao_detach(node->tn_spec.tn_reg.tn_aobj); in tmpfs_free_node()
244 node->tn_spec.tn_reg.tn_aobj = NULL; in tmpfs_free_node()
248 KASSERT(TAILQ_EMPTY(&node->tn_spec.tn_dir.tn_dir)); in tmpfs_free_node()
249 KASSERT(node->tn_spec.tn_dir.tn_parent == NULL || in tmpfs_free_node()
250 node == tmp->tm_root); in tmpfs_free_node()
257 if (node->tn_id == tmp->tm_highest_inode) in tmpfs_free_node()
262 tmpfs_node_put(tmp, node); in tmpfs_free_node()
272 tmpfs_vnode_get(struct mount *mp, tmpfs_node_t *node, struct vnode **vpp) in tmpfs_vnode_get() argument
279 if ((vp = node->tn_vnode) != NULL) { in tmpfs_vnode_get()
281 node->tn_gen |= TMPFS_RECLAIMING_BIT; in tmpfs_vnode_get()
282 rw_exit_write(&node->tn_nlock); in tmpfs_vnode_get()
285 rw_enter_write(&node->tn_nlock); in tmpfs_vnode_get()
289 node->tn_gen &= ~TMPFS_RECLAIMING_BIT; in tmpfs_vnode_get()
293 if (TMPFS_NODE_RECLAIMING(node)) { in tmpfs_vnode_get()
295 node->tn_gen &= ~TMPFS_RECLAIMING_BIT; in tmpfs_vnode_get()
303 if (node->tn_type == VREG) { in tmpfs_vnode_get()
304 struct uvm_object *uobj = node->tn_spec.tn_reg.tn_aobj; in tmpfs_vnode_get()
312 rw_exit_write(&node->tn_nlock); in tmpfs_vnode_get()
316 rrw_init_flags(&node->tn_vlock, "tnode", RWL_DUPOK | RWL_IS_VNODE); in tmpfs_vnode_get()
317 vp->v_type = node->tn_type; in tmpfs_vnode_get()
320 switch (node->tn_type) { in tmpfs_vnode_get()
324 if ((nvp = checkalias(vp, node->tn_spec.tn_dev.tn_rdev, mp))) { in tmpfs_vnode_get()
331 node->tn_vnode = vp; in tmpfs_vnode_get()
335 vp->v_flag |= node->tn_spec.tn_dir.tn_parent == node ? in tmpfs_vnode_get()
351 uvm_vnp_setsize(vp, node->tn_size); in tmpfs_vnode_get()
352 vp->v_data = node; in tmpfs_vnode_get()
353 node->tn_vnode = vp; in tmpfs_vnode_get()
355 rw_exit_write(&node->tn_nlock); in tmpfs_vnode_get()
373 tmpfs_node_t *dnode = VP_TO_TMPFS_DIR(dvp), *node; in tmpfs_alloc_file() local
402 dnode->tn_gid, vap->va_mode, target, vap->va_rdev, &node); in tmpfs_alloc_file()
409 tmpfs_free_node(tmp, node); in tmpfs_alloc_file()
414 rw_enter_write(&node->tn_nlock); in tmpfs_alloc_file()
415 error = tmpfs_vnode_get(dvp->v_mount, node, vpp); in tmpfs_alloc_file()
418 tmpfs_free_node(tmp, node); in tmpfs_alloc_file()
423 tmpfs_dir_attach(dnode, de, node); in tmpfs_alloc_file()
480 tmpfs_dir_attach(tmpfs_node_t *dnode, tmpfs_dirent_t *de, tmpfs_node_t *node) in tmpfs_dir_attach() argument
493 de->td_node = node; in tmpfs_dir_attach()
494 KASSERT(node->tn_links < LINK_MAX); in tmpfs_dir_attach()
495 node->tn_links++; in tmpfs_dir_attach()
498 node->tn_dirent_hint = de; in tmpfs_dir_attach()
506 if (node->tn_type == VDIR) { in tmpfs_dir_attach()
508 KASSERT(node->tn_spec.tn_dir.tn_parent == NULL); in tmpfs_dir_attach()
509 node->tn_spec.tn_dir.tn_parent = dnode; in tmpfs_dir_attach()
516 TMPFS_VALIDATE_DIR(node); in tmpfs_dir_attach()
532 tmpfs_node_t *node = de->td_node; in tmpfs_dir_detach() local
540 node->tn_dirent_hint = NULL; in tmpfs_dir_detach()
542 KASSERT(node->tn_links > 0); in tmpfs_dir_detach()
543 node->tn_links--; in tmpfs_dir_detach()
544 if ((vp = node->tn_vnode) != NULL) { in tmpfs_dir_detach()
546 VN_KNOTE(vp, node->tn_links ? NOTE_LINK : NOTE_DELETE); in tmpfs_dir_detach()
550 if (node->tn_type == VDIR) { in tmpfs_dir_detach()
551 KASSERT(node->tn_spec.tn_dir.tn_parent == dnode); in tmpfs_dir_detach()
552 node->tn_spec.tn_dir.tn_parent = NULL; in tmpfs_dir_detach()
582 tmpfs_dir_lookup(tmpfs_node_t *node, struct componentname *cnp) in tmpfs_dir_lookup() argument
588 KASSERT(VOP_ISLOCKED(node->tn_vnode)); in tmpfs_dir_lookup()
591 TMPFS_VALIDATE_DIR(node); in tmpfs_dir_lookup()
593 TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) { in tmpfs_dir_lookup()
600 tmpfs_update(node, TMPFS_NODE_ACCESSED); in tmpfs_dir_lookup()
611 tmpfs_dir_cached(tmpfs_node_t *node) in tmpfs_dir_cached() argument
613 tmpfs_dirent_t *de = node->tn_dirent_hint; in tmpfs_dir_cached()
615 KASSERT(VOP_ISLOCKED(node->tn_vnode)); in tmpfs_dir_cached()
620 KASSERT(de->td_node == node); in tmpfs_dir_cached()
626 return (node->tn_type != VDIR && node->tn_links > 1) ? NULL : de; in tmpfs_dir_cached()
681 tmpfs_dir_lookupbyseq(tmpfs_node_t *node, off_t seq) in tmpfs_dir_lookupbyseq() argument
683 tmpfs_dirent_t *de = node->tn_spec.tn_dir.tn_readdir_lastp; in tmpfs_dir_lookupbyseq()
685 TMPFS_VALIDATE_DIR(node); in tmpfs_dir_lookupbyseq()
695 TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) { in tmpfs_dir_lookupbyseq()
709 tmpfs_dir_getdotents(tmpfs_node_t *node, struct dirent *dp, struct uio *uio) in tmpfs_dir_getdotents() argument
717 dp->d_fileno = node->tn_id; in tmpfs_dir_getdotents()
722 dp->d_fileno = node->tn_spec.tn_dir.tn_parent->tn_id; in tmpfs_dir_getdotents()
724 de = TAILQ_FIRST(&node->tn_spec.tn_dir.tn_dir); in tmpfs_dir_getdotents()
725 next = de ? tmpfs_dir_getseq(node, de) : TMPFS_DIRSEQ_EOF; in tmpfs_dir_getdotents()
754 tmpfs_dir_getdents(tmpfs_node_t *node, struct uio *uio) in tmpfs_dir_getdents() argument
760 KASSERT(VOP_ISLOCKED(node->tn_vnode)); in tmpfs_dir_getdents()
761 TMPFS_VALIDATE_DIR(node); in tmpfs_dir_getdents()
765 if ((error = tmpfs_dir_getdotents(node, &dent, uio)) != 0) { in tmpfs_dir_getdents()
770 if ((error = tmpfs_dir_getdotents(node, &dent, uio)) != 0) { in tmpfs_dir_getdents()
780 de = tmpfs_dir_lookupbyseq(node, uio->uio_offset); in tmpfs_dir_getdents()
832 dent.d_off = tmpfs_dir_getseq(node, next_de); in tmpfs_dir_getdents()
850 uio->uio_offset = de ? tmpfs_dir_getseq(node, de) : TMPFS_DIRSEQ_EOF; in tmpfs_dir_getdents()
851 node->tn_spec.tn_dir.tn_readdir_lastp = de; in tmpfs_dir_getdents()
853 tmpfs_update(node, TMPFS_NODE_ACCESSED); in tmpfs_dir_getdents()
872 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_reg_resize() local
873 struct uvm_object *uobj = node->tn_spec.tn_reg.tn_aobj; in tmpfs_reg_resize()
882 oldsize = node->tn_size; in tmpfs_reg_resize()
885 KASSERT(oldpages == node->tn_spec.tn_reg.tn_aobj_pages); in tmpfs_reg_resize()
901 node->tn_spec.tn_reg.tn_aobj_pages = newpages; in tmpfs_reg_resize()
902 node->tn_size = newsize; in tmpfs_reg_resize()
910 if (tmpfs_uio_cached(node)) in tmpfs_reg_resize()
911 tmpfs_uio_uncache(node); in tmpfs_reg_resize()
920 if (tmpfs_uio_cached(node)) in tmpfs_reg_resize()
921 tmpfs_uio_uncache(node); in tmpfs_reg_resize()
928 error = tmpfs_zeropg(node, trunc_page(oldsize), pgoff); in tmpfs_reg_resize()
944 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chflags() local
953 if (cred->cr_uid != node->tn_uid && (error = suser_ucred(cred))) in tmpfs_chflags()
957 if (node->tn_flags & (SF_IMMUTABLE | SF_APPEND) && in tmpfs_chflags()
960 node->tn_flags = flags; in tmpfs_chflags()
962 if (node->tn_flags & (SF_IMMUTABLE | SF_APPEND) || in tmpfs_chflags()
965 node->tn_flags &= SF_SETTABLE; in tmpfs_chflags()
966 node->tn_flags |= (flags & UF_SETTABLE); in tmpfs_chflags()
969 tmpfs_update(node, TMPFS_NODE_CHANGED); in tmpfs_chflags()
981 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chmod() local
991 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chmod()
994 if (cred->cr_uid != node->tn_uid && (error = suser_ucred(cred))) in tmpfs_chmod()
999 if (!groupmember(node->tn_gid, cred) && (mode & S_ISGID)) in tmpfs_chmod()
1003 node->tn_mode = (mode & ALLPERMS); in tmpfs_chmod()
1004 tmpfs_update(node, TMPFS_NODE_CHANGED); in tmpfs_chmod()
1005 if ((vp->v_flag & VTEXT) && (node->tn_mode & S_ISTXT) == 0) in tmpfs_chmod()
1020 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chown() local
1028 uid = node->tn_uid; in tmpfs_chown()
1031 gid = node->tn_gid; in tmpfs_chown()
1039 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chown()
1042 if ((cred->cr_uid != node->tn_uid || uid != node->tn_uid || in tmpfs_chown()
1043 (gid != node->tn_gid && !groupmember(gid, cred))) && in tmpfs_chown()
1047 node->tn_uid = uid; in tmpfs_chown()
1048 node->tn_gid = gid; in tmpfs_chown()
1049 tmpfs_update(node, TMPFS_NODE_CHANGED); in tmpfs_chown()
1060 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chsize() local
1087 if (node->tn_flags & (IMMUTABLE | APPEND)) { in tmpfs_chsize()
1103 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_chtimes() local
1113 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chtimes()
1116 if (cred->cr_uid != node->tn_uid && (error = suser_ucred(cred)) && in tmpfs_chtimes()
1122 node->tn_atime = *atime; in tmpfs_chtimes()
1125 node->tn_mtime = *mtime; in tmpfs_chtimes()
1139 tmpfs_update(tmpfs_node_t *node, int flags) in tmpfs_update() argument
1146 node->tn_atime = nowtm; in tmpfs_update()
1149 node->tn_mtime = nowtm; in tmpfs_update()
1152 node->tn_ctime = nowtm; in tmpfs_update()
1159 tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); in tmpfs_truncate() local
1166 if (node->tn_size == length) { in tmpfs_truncate()
1172 tmpfs_update(node, TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED); in tmpfs_truncate()
1179 tmpfs_uio_cached(tmpfs_node_t *node) in tmpfs_uio_cached() argument
1181 int pgnum_valid = (node->tn_pgnum != (voff_t)-1); in tmpfs_uio_cached()
1182 int pgptr_valid = (node->tn_pgptr != (vaddr_t)NULL); in tmpfs_uio_cached()
1188 tmpfs_uio_lookup(tmpfs_node_t *node, voff_t pgnum) in tmpfs_uio_lookup() argument
1190 if (tmpfs_uio_cached(node) == 1 && node->tn_pgnum == pgnum) in tmpfs_uio_lookup()
1191 return node->tn_pgptr; in tmpfs_uio_lookup()
1197 tmpfs_uio_uncache(tmpfs_node_t *node) in tmpfs_uio_uncache() argument
1199 KASSERT(node->tn_pgnum != (voff_t)-1); in tmpfs_uio_uncache()
1200 KASSERT(node->tn_pgptr != (vaddr_t)NULL); in tmpfs_uio_uncache()
1201 uvm_unmap(kernel_map, node->tn_pgptr, node->tn_pgptr + PAGE_SIZE); in tmpfs_uio_uncache()
1202 node->tn_pgnum = (voff_t)-1; in tmpfs_uio_uncache()
1203 node->tn_pgptr = (vaddr_t)NULL; in tmpfs_uio_uncache()
1207 tmpfs_uio_cache(tmpfs_node_t *node, voff_t pgnum, vaddr_t pgptr) in tmpfs_uio_cache() argument
1209 KASSERT(node->tn_pgnum == (voff_t)-1); in tmpfs_uio_cache()
1210 KASSERT(node->tn_pgptr == (vaddr_t)NULL); in tmpfs_uio_cache()
1211 node->tn_pgnum = pgnum; in tmpfs_uio_cache()
1212 node->tn_pgptr = pgptr; in tmpfs_uio_cache()
1221 tmpfs_uiomove(tmpfs_node_t *node, struct uio *uio, vsize_t len) in tmpfs_uiomove() argument
1232 va = tmpfs_uio_lookup(node, pgnum); in tmpfs_uiomove()
1245 if (tmpfs_uio_cached(node)) in tmpfs_uiomove()
1246 tmpfs_uio_uncache(node); in tmpfs_uiomove()
1248 uao_reference(node->tn_uobj); in tmpfs_uiomove()
1250 error = uvm_map(kernel_map, &va, round_page(pgoff + sz), node->tn_uobj, in tmpfs_uiomove()
1254 uao_detach(node->tn_uobj); /* Drop reference. */ in tmpfs_uiomove()
1260 tmpfs_uio_cache(node, pgnum, va); in tmpfs_uiomove()
1268 tmpfs_zeropg(tmpfs_node_t *node, voff_t pgnum, vaddr_t pgoff) in tmpfs_zeropg() argument
1273 KASSERT(tmpfs_uio_cached(node) == 0); in tmpfs_zeropg()
1275 uao_reference(node->tn_uobj); in tmpfs_zeropg()
1277 error = uvm_map(kernel_map, &va, PAGE_SIZE, node->tn_uobj, pgnum, 0, in tmpfs_zeropg()
1281 uao_detach(node->tn_uobj); /* Drop reference. */ in tmpfs_zeropg()