Lines Matching +full:de +full:- +full:be
3 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
85 int tmpfs_pager_type = -1;
105 * Make sure tmpfs vnodes with writable mappings can be found on the lazy list.
123 if (vp == NULL || vp->v_object == NULL) { in tmpfs_pager_writecount_recalc()
124 KASSERT((object->flags & OBJ_TMPFS_VREF) == 0, in tmpfs_pager_writecount_recalc()
132 VNASSERT((object->flags & OBJ_TMPFS_VREF) == 0, vp, in tmpfs_pager_writecount_recalc()
134 VNPASS(vp->v_usecount > 0, vp); in tmpfs_pager_writecount_recalc()
136 VNASSERT((object->flags & OBJ_TMPFS_VREF) != 0, vp, in tmpfs_pager_writecount_recalc()
151 if ((object->flags & OBJ_TMPFS_VREF) == 0) { in tmpfs_pager_writecount_recalc()
167 KASSERT((object->flags & OBJ_ANON) == 0, in tmpfs_pager_update_writecount()
169 old = object->un_pager.swp.writemappings; in tmpfs_pager_update_writecount()
170 object->un_pager.swp.writemappings += (vm_ooffset_t)end - start; in tmpfs_pager_update_writecount()
171 new = object->un_pager.swp.writemappings; in tmpfs_pager_update_writecount()
183 KASSERT((object->flags & OBJ_ANON) == 0, in tmpfs_pager_release_writecount()
185 old = object->un_pager.swp.writemappings; in tmpfs_pager_release_writecount()
186 KASSERT(old >= (vm_ooffset_t)end - start, in tmpfs_pager_release_writecount()
188 (uintmax_t)((vm_ooffset_t)end - start))); in tmpfs_pager_release_writecount()
189 object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start; in tmpfs_pager_release_writecount()
190 new = object->un_pager.swp.writemappings; in tmpfs_pager_release_writecount()
208 if ((object->flags & OBJ_TMPFS) != 0) { in tmpfs_pager_getvp()
230 if ((obj->flags & OBJ_TMPFS) == 0 || c == 0) in tmpfs_pager_freespace()
233 node = obj->un_pager.swp.swp_priv; in tmpfs_pager_freespace()
234 MPASS(node->tn_type == VREG); in tmpfs_pager_freespace()
235 tm = node->tn_reg.tn_tmp; in tmpfs_pager_freespace()
237 KASSERT(tm->tm_pages_used >= c, in tmpfs_pager_freespace()
239 (uintmax_t)tm->tm_pages_used, (uintmax_t)c)); in tmpfs_pager_freespace()
240 atomic_add_long(&tm->tm_pages_used, -c); in tmpfs_pager_freespace()
241 KASSERT(node->tn_reg.tn_pages >= c, in tmpfs_pager_freespace()
243 (uintmax_t)node->tn_reg.tn_pages, (uintmax_t)c)); in tmpfs_pager_freespace()
244 node->tn_reg.tn_pages -= c; in tmpfs_pager_freespace()
253 if ((obj->flags & OBJ_TMPFS) == 0) in tmpfs_page_inserted()
256 node = obj->un_pager.swp.swp_priv; in tmpfs_page_inserted()
257 MPASS(node->tn_type == VREG); in tmpfs_page_inserted()
258 tm = node->tn_reg.tn_tmp; in tmpfs_page_inserted()
260 if (!vm_pager_has_page(obj, m->pindex, NULL, NULL)) { in tmpfs_page_inserted()
261 atomic_add_long(&tm->tm_pages_used, 1); in tmpfs_page_inserted()
262 node->tn_reg.tn_pages += 1; in tmpfs_page_inserted()
272 if ((obj->flags & OBJ_TMPFS) == 0) in tmpfs_page_removed()
275 node = obj->un_pager.swp.swp_priv; in tmpfs_page_removed()
276 MPASS(node->tn_type == VREG); in tmpfs_page_removed()
277 tm = node->tn_reg.tn_tmp; in tmpfs_page_removed()
279 if (!vm_pager_has_page(obj, m->pindex, NULL, NULL)) { in tmpfs_page_removed()
280 KASSERT(tm->tm_pages_used >= 1, in tmpfs_page_removed()
282 (uintmax_t)tm->tm_pages_used)); in tmpfs_page_removed()
283 atomic_add_long(&tm->tm_pages_used, -1); in tmpfs_page_removed()
284 KASSERT(node->tn_reg.tn_pages >= 1, in tmpfs_page_removed()
286 (uintmax_t)node->tn_reg.tn_pages)); in tmpfs_page_removed()
287 node->tn_reg.tn_pages -= 1; in tmpfs_page_removed()
298 tm->tm_pages_max == 0) in tmpfs_can_alloc_page()
300 if (tm->tm_pages_max == ULONG_MAX) in tmpfs_can_alloc_page()
302 return (tm->tm_pages_max > atomic_load_long(&tm->tm_pages_used)); in tmpfs_can_alloc_page()
325 node->tn_gen++; in tmpfs_node_ctor()
326 node->tn_size = 0; in tmpfs_node_ctor()
327 node->tn_status = 0; in tmpfs_node_ctor()
328 node->tn_accessed = false; in tmpfs_node_ctor()
329 node->tn_flags = 0; in tmpfs_node_ctor()
330 node->tn_links = 0; in tmpfs_node_ctor()
331 node->tn_vnode = NULL; in tmpfs_node_ctor()
332 node->tn_vpstate = 0; in tmpfs_node_ctor()
342 node->tn_type = VNON; in tmpfs_node_dtor()
351 node->tn_id = 0; in tmpfs_node_init()
352 mtx_init(&node->tn_interlock, "tmpfsni", NULL, MTX_DEF | MTX_NEW); in tmpfs_node_init()
353 node->tn_gen = arc4random(); in tmpfs_node_init()
363 mtx_destroy(&node->tn_interlock); in tmpfs_node_fini()
371 if (tmpfs_pager_type == -1) in tmpfs_subr_init()
386 if (tmpfs_pager_type != -1) in tmpfs_subr_uninit()
388 tmpfs_pager_type = -1; in tmpfs_subr_uninit()
402 if (error || !req->newptr) in sysctl_mem_reserved()
425 if (error || !req->newptr) in sysctl_mem_percent()
441 reserved = tmpfs_pages_avail_init * (100 - tmpfs_mem_percent) / 100; in tmpfs_set_reserve_from_percent()
448 "Percent of available memory that can be used if no size limit");
464 return (avail - reserved); in tmpfs_mem_avail()
474 meta_pages = howmany((uintmax_t)tmp->tm_nodes_inuse * node_size, in tmpfs_pages_used()
476 return (meta_pages + tmp->tm_pages_used); in tmpfs_pages_used()
485 if (tmp->tm_pages_max != ULONG_MAX && in tmpfs_pages_check_avail()
486 tmp->tm_pages_max < req_pages + tmpfs_pages_used(tmp)) in tmpfs_pages_check_avail()
512 refcount_acquire(&node->tn_refcount); in tmpfs_ref_node()
524 * to the parent directory of the node being created. It may only be NULL
550 * allocated, this must be the request to do it. */ in tmpfs_alloc_node()
551 MPASS(IMPLIES(tmp->tm_root == NULL, parent == NULL && type == VDIR)); in tmpfs_alloc_node()
556 if (tmp->tm_nodes_inuse >= tmp->tm_nodes_max) in tmpfs_alloc_node()
561 if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) { in tmpfs_alloc_node()
564 * constructed mount point, there must be a parent in tmpfs_alloc_node()
570 * cannot be destroyed until node construction is in tmpfs_alloc_node()
578 if ((mp->mnt_kern_flag & MNT_RDONLY) != 0) in tmpfs_alloc_node()
584 nnode->tn_type = type; in tmpfs_alloc_node()
585 vfs_timestamp(&nnode->tn_atime); in tmpfs_alloc_node()
586 nnode->tn_birthtime = nnode->tn_ctime = nnode->tn_mtime = in tmpfs_alloc_node()
587 nnode->tn_atime; in tmpfs_alloc_node()
588 nnode->tn_uid = uid; in tmpfs_alloc_node()
589 nnode->tn_gid = gid; in tmpfs_alloc_node()
590 nnode->tn_mode = mode; in tmpfs_alloc_node()
591 nnode->tn_id = alloc_unr64(&tmp->tm_ino_unr); in tmpfs_alloc_node()
592 nnode->tn_refcount = 1; in tmpfs_alloc_node()
593 LIST_INIT(&nnode->tn_extattrs); in tmpfs_alloc_node()
595 /* Type-specific initialization. */ in tmpfs_alloc_node()
596 switch (nnode->tn_type) { in tmpfs_alloc_node()
599 nnode->tn_rdev = rdev; in tmpfs_alloc_node()
603 RB_INIT(&nnode->tn_dir.tn_dirhead); in tmpfs_alloc_node()
604 LIST_INIT(&nnode->tn_dir.tn_dupindex); in tmpfs_alloc_node()
606 MPASS(IMPLIES(parent == NULL, tmp->tm_root == NULL)); in tmpfs_alloc_node()
607 nnode->tn_dir.tn_parent = (parent == NULL) ? nnode : parent; in tmpfs_alloc_node()
608 nnode->tn_dir.tn_readdir_lastn = 0; in tmpfs_alloc_node()
609 nnode->tn_dir.tn_readdir_lastp = NULL; in tmpfs_alloc_node()
610 nnode->tn_dir.tn_wht_size = 0; in tmpfs_alloc_node()
611 nnode->tn_links++; in tmpfs_alloc_node()
612 TMPFS_NODE_LOCK(nnode->tn_dir.tn_parent); in tmpfs_alloc_node()
613 nnode->tn_dir.tn_parent->tn_links++; in tmpfs_alloc_node()
614 TMPFS_NODE_UNLOCK(nnode->tn_dir.tn_parent); in tmpfs_alloc_node()
624 nnode->tn_size = strlen(target); in tmpfs_alloc_node()
627 if (!tmp->tm_nonc) { in tmpfs_alloc_node()
628 symlink = cache_symlink_alloc(nnode->tn_size + 1, in tmpfs_alloc_node()
633 symlink = malloc(nnode->tn_size + 1, M_TMPFSNAME, in tmpfs_alloc_node()
637 memcpy(symlink, target, nnode->tn_size + 1); in tmpfs_alloc_node()
653 * may be set to true despite being stale, while the in tmpfs_alloc_node()
656 atomic_store_ptr(&nnode->tn_link_target, symlink); in tmpfs_alloc_node()
657 atomic_store_char((char *)&nnode->tn_link_smr, symlink_smr); in tmpfs_alloc_node()
662 nnode->tn_reg.tn_aobj = in tmpfs_alloc_node()
665 NULL /* XXXKIB - tmpfs needs swap reservation */); in tmpfs_alloc_node()
666 nnode->tn_reg.tn_aobj->un_pager.swp.swp_priv = nnode; in tmpfs_alloc_node()
667 vm_object_set_flag(nnode->tn_reg.tn_aobj, OBJ_TMPFS); in tmpfs_alloc_node()
668 nnode->tn_reg.tn_tmp = tmp; in tmpfs_alloc_node()
669 nnode->tn_reg.tn_pages = 0; in tmpfs_alloc_node()
674 (int)nnode->tn_type); in tmpfs_alloc_node()
678 LIST_INSERT_HEAD(&tmp->tm_nodes_used, nnode, tn_entries); in tmpfs_alloc_node()
679 nnode->tn_attached = true; in tmpfs_alloc_node()
680 tmp->tm_nodes_inuse++; in tmpfs_alloc_node()
681 tmp->tm_refcount++; in tmpfs_alloc_node()
695 if (refcount_release_if_not_last(&node->tn_refcount)) in tmpfs_free_node()
718 last = refcount_release(&node->tn_refcount); in tmpfs_free_node_locked()
719 if (node->tn_attached && (detach || last)) { in tmpfs_free_node_locked()
720 MPASS(tmp->tm_nodes_inuse > 0); in tmpfs_free_node_locked()
721 tmp->tm_nodes_inuse--; in tmpfs_free_node_locked()
723 node->tn_attached = false; in tmpfs_free_node_locked()
731 MPASS(node->tn_vnode == NULL); in tmpfs_free_node_locked()
732 MPASS((node->tn_vpstate & TMPFS_VNODE_ALLOCATING) == 0); in tmpfs_free_node_locked()
740 switch (node->tn_type) { in tmpfs_free_node_locked()
753 (int)node->tn_type, node); in tmpfs_free_node_locked()
757 while ((ea = LIST_FIRST(&node->tn_extattrs)) != NULL) { in tmpfs_free_node_locked()
762 switch (node->tn_type) { in tmpfs_free_node_locked()
764 uobj = node->tn_reg.tn_aobj; in tmpfs_free_node_locked()
765 node->tn_reg.tn_aobj = NULL; in tmpfs_free_node_locked()
768 KASSERT((uobj->flags & OBJ_TMPFS) != 0, in tmpfs_free_node_locked()
771 KASSERT(tmp->tm_pages_used >= node->tn_reg.tn_pages, in tmpfs_free_node_locked()
773 node, (uintmax_t)tmp->tm_pages_used, in tmpfs_free_node_locked()
774 (uintmax_t)node->tn_reg.tn_pages)); in tmpfs_free_node_locked()
775 atomic_add_long(&tmp->tm_pages_used, in tmpfs_free_node_locked()
776 -node->tn_reg.tn_pages); in tmpfs_free_node_locked()
782 * vm_object_deallocate() must not be called while in tmpfs_free_node_locked()
794 symlink = node->tn_link_target; in tmpfs_free_node_locked()
795 atomic_store_ptr(&node->tn_link_target, NULL); in tmpfs_free_node_locked()
796 if (atomic_load_char(&node->tn_link_smr)) { in tmpfs_free_node_locked()
797 cache_symlink_free(symlink, node->tn_size + 1); in tmpfs_free_node_locked()
827 tmpfs_dirent_cookie(struct tmpfs_dirent *de) in tmpfs_dirent_cookie() argument
829 if (de == NULL) in tmpfs_dirent_cookie()
832 MPASS(de->td_cookie >= TMPFS_DIRCOOKIE_MIN); in tmpfs_dirent_cookie()
834 return (de->td_cookie); in tmpfs_dirent_cookie()
838 tmpfs_dirent_dup(struct tmpfs_dirent *de) in tmpfs_dirent_dup() argument
840 return ((de->td_cookie & TMPFS_DIRCOOKIE_DUP) != 0); in tmpfs_dirent_dup()
844 tmpfs_dirent_duphead(struct tmpfs_dirent *de) in tmpfs_dirent_duphead() argument
846 return ((de->td_cookie & TMPFS_DIRCOOKIE_DUPHEAD) != 0); in tmpfs_dirent_duphead()
850 tmpfs_dirent_init(struct tmpfs_dirent *de, const char *name, u_int namelen) in tmpfs_dirent_init() argument
852 de->td_hash = de->td_cookie = tmpfs_dirent_hash(name, namelen); in tmpfs_dirent_init()
853 memcpy(de->ud.td_name, name, namelen); in tmpfs_dirent_init()
854 de->td_namelen = namelen; in tmpfs_dirent_init()
859 * The new directory entry is returned in *de.
868 const char *name, u_int len, struct tmpfs_dirent **de) in tmpfs_alloc_dirent() argument
873 nde->td_node = node; in tmpfs_alloc_dirent()
875 nde->ud.td_name = malloc(len, M_TMPFSNAME, M_WAITOK); in tmpfs_alloc_dirent()
878 nde->td_namelen = 0; in tmpfs_alloc_dirent()
880 node->tn_links++; in tmpfs_alloc_dirent()
882 *de = nde; in tmpfs_alloc_dirent()
897 tmpfs_free_dirent(struct tmpfs_mount *tmp, struct tmpfs_dirent *de) in tmpfs_free_dirent() argument
901 node = de->td_node; in tmpfs_free_dirent()
903 MPASS(node->tn_links > 0); in tmpfs_free_dirent()
904 node->tn_links--; in tmpfs_free_dirent()
906 if (!tmpfs_dirent_duphead(de) && de->ud.td_name != NULL) in tmpfs_free_dirent()
907 free(de->ud.td_name, M_TMPFSNAME); in tmpfs_free_dirent()
908 free(de, M_TMPFSDIR); in tmpfs_free_dirent()
917 if (vp->v_type != VREG || obj == NULL) in tmpfs_destroy_vobject()
922 vp->v_object = NULL; in tmpfs_destroy_vobject()
925 * May be going through forced unmount. in tmpfs_destroy_vobject()
928 if ((obj->flags & OBJ_TMPFS_VREF) != 0) { in tmpfs_destroy_vobject()
933 if (vp->v_writecount < 0) in tmpfs_destroy_vobject()
934 vp->v_writecount = 0; in tmpfs_destroy_vobject()
965 if ((vp = node->tn_vnode) != NULL) { in tmpfs_alloc_vp()
966 MPASS((node->tn_vpstate & TMPFS_VNODE_DOOMED) == 0); in tmpfs_alloc_vp()
967 if ((node->tn_type == VDIR && node->tn_dir.tn_parent == NULL) || in tmpfs_alloc_vp()
976 node->tn_vpstate |= TMPFS_VNODE_WRECLAIM; in tmpfs_alloc_vp()
977 while ((node->tn_vpstate & TMPFS_VNODE_WRECLAIM) != 0) { in tmpfs_alloc_vp()
978 msleep(&node->tn_vnode, TMPFS_NODE_MTX(node), in tmpfs_alloc_vp()
999 if (node->tn_vnode != vp) { in tmpfs_alloc_vp()
1008 if ((node->tn_vpstate & TMPFS_VNODE_DOOMED) || in tmpfs_alloc_vp()
1009 (node->tn_type == VDIR && node->tn_dir.tn_parent == NULL)) { in tmpfs_alloc_vp()
1020 if (node->tn_vpstate & TMPFS_VNODE_ALLOCATING) { in tmpfs_alloc_vp()
1021 node->tn_vpstate |= TMPFS_VNODE_WANT; in tmpfs_alloc_vp()
1022 error = msleep((caddr_t) &node->tn_vpstate, in tmpfs_alloc_vp()
1028 node->tn_vpstate |= TMPFS_VNODE_ALLOCATING; in tmpfs_alloc_vp()
1033 error = getnewvnode("tmpfs", mp, VFS_TO_TMPFS(mp)->tm_nonc ? in tmpfs_alloc_vp()
1042 vp->v_data = node; in tmpfs_alloc_vp()
1043 vp->v_type = node->tn_type; in tmpfs_alloc_vp()
1045 /* Type-specific initialization. */ in tmpfs_alloc_vp()
1046 switch (node->tn_type) { in tmpfs_alloc_vp()
1056 vp->v_op = &tmpfs_fifoop_entries; in tmpfs_alloc_vp()
1059 object = node->tn_reg.tn_aobj; in tmpfs_alloc_vp()
1061 KASSERT((object->flags & OBJ_TMPFS_VREF) == 0, in tmpfs_alloc_vp()
1065 KASSERT(vp->v_object == NULL, ("Not NULL v_object in tmpfs")); in tmpfs_alloc_vp()
1066 vp->v_object = object; in tmpfs_alloc_vp()
1067 vn_irflag_set_locked(vp, (tm->tm_pgread ? VIRF_PGREAD : 0) | in tmpfs_alloc_vp()
1070 VNASSERT((object->flags & OBJ_TMPFS_VREF) == 0, vp, in tmpfs_alloc_vp()
1072 if (object->un_pager.swp.writemappings > 0) { in tmpfs_alloc_vp()
1080 MPASS(node->tn_dir.tn_parent != NULL); in tmpfs_alloc_vp()
1081 if (node->tn_dir.tn_parent == node) in tmpfs_alloc_vp()
1082 vp->v_vflag |= VV_ROOT; in tmpfs_alloc_vp()
1086 panic("tmpfs_alloc_vp: type %p %d", node, (int)node->tn_type); in tmpfs_alloc_vp()
1088 if (vp->v_type != VFIFO) in tmpfs_alloc_vp()
1094 tmpfs_destroy_vobject(vp, vp->v_object); in tmpfs_alloc_vp()
1095 vp->v_object = NULL; in tmpfs_alloc_vp()
1096 vp->v_data = NULL; in tmpfs_alloc_vp()
1097 vp->v_op = &dead_vnodeops; in tmpfs_alloc_vp()
1108 MPASS(node->tn_vpstate & TMPFS_VNODE_ALLOCATING); in tmpfs_alloc_vp()
1109 node->tn_vpstate &= ~TMPFS_VNODE_ALLOCATING; in tmpfs_alloc_vp()
1110 node->tn_vnode = vp; in tmpfs_alloc_vp()
1112 if (node->tn_vpstate & TMPFS_VNODE_WANT) { in tmpfs_alloc_vp()
1113 node->tn_vpstate &= ~TMPFS_VNODE_WANT; in tmpfs_alloc_vp()
1115 wakeup((caddr_t) &node->tn_vpstate); in tmpfs_alloc_vp()
1127 MPASS(*vpp == node->tn_vnode); in tmpfs_alloc_vp()
1148 node->tn_vnode = NULL; in tmpfs_free_vp()
1149 if ((node->tn_vpstate & TMPFS_VNODE_WRECLAIM) != 0) in tmpfs_free_vp()
1150 wakeup(&node->tn_vnode); in tmpfs_free_vp()
1151 node->tn_vpstate &= ~TMPFS_VNODE_WRECLAIM; in tmpfs_free_vp()
1152 vp->v_data = NULL; in tmpfs_free_vp()
1170 struct tmpfs_dirent *de; in tmpfs_alloc_file() local
1178 tmp = VFS_TO_TMPFS(dvp->v_mount); in tmpfs_alloc_file()
1185 if (vap->va_type == VDIR) { in tmpfs_alloc_file()
1188 MPASS(dnode->tn_links <= TMPFS_LINK_MAX); in tmpfs_alloc_file()
1189 if (dnode->tn_links == TMPFS_LINK_MAX) { in tmpfs_alloc_file()
1199 error = tmpfs_alloc_node(dvp->v_mount, tmp, vap->va_type, in tmpfs_alloc_file()
1200 cnp->cn_cred->cr_uid, dnode->tn_gid, vap->va_mode, parent, in tmpfs_alloc_file()
1201 target, vap->va_rdev, &node); in tmpfs_alloc_file()
1206 error = tmpfs_alloc_dirent(tmp, node, cnp->cn_nameptr, cnp->cn_namelen, in tmpfs_alloc_file()
1207 &de); in tmpfs_alloc_file()
1214 error = tmpfs_alloc_vp(dvp->v_mount, node, LK_EXCLUSIVE, vpp); in tmpfs_alloc_file()
1216 tmpfs_free_dirent(tmp, de); in tmpfs_alloc_file()
1224 if (cnp->cn_flags & ISWHITEOUT) in tmpfs_alloc_file()
1226 tmpfs_dir_attach(dvp, de); in tmpfs_alloc_file()
1233 struct tmpfs_dirent *de; in tmpfs_dir_first() local
1235 de = RB_MIN(tmpfs_dir, &dnode->tn_dir.tn_dirhead); in tmpfs_dir_first()
1236 dc->tdc_tree = de; in tmpfs_dir_first()
1237 if (de != NULL && tmpfs_dirent_duphead(de)) in tmpfs_dir_first()
1238 de = LIST_FIRST(&de->ud.td_duphead); in tmpfs_dir_first()
1239 dc->tdc_current = de; in tmpfs_dir_first()
1241 return (dc->tdc_current); in tmpfs_dir_first()
1247 struct tmpfs_dirent *de; in tmpfs_dir_next() local
1249 MPASS(dc->tdc_tree != NULL); in tmpfs_dir_next()
1250 if (tmpfs_dirent_dup(dc->tdc_current)) { in tmpfs_dir_next()
1251 dc->tdc_current = LIST_NEXT(dc->tdc_current, uh.td_dup.entries); in tmpfs_dir_next()
1252 if (dc->tdc_current != NULL) in tmpfs_dir_next()
1253 return (dc->tdc_current); in tmpfs_dir_next()
1255 dc->tdc_tree = dc->tdc_current = RB_NEXT(tmpfs_dir, in tmpfs_dir_next()
1256 &dnode->tn_dir.tn_dirhead, dc->tdc_tree); in tmpfs_dir_next()
1257 if ((de = dc->tdc_current) != NULL && tmpfs_dirent_duphead(de)) { in tmpfs_dir_next()
1258 dc->tdc_current = LIST_FIRST(&de->ud.td_duphead); in tmpfs_dir_next()
1259 MPASS(dc->tdc_current != NULL); in tmpfs_dir_next()
1262 return (dc->tdc_current); in tmpfs_dir_next()
1265 /* Lookup directory entry in RB-Tree. Function may return duphead entry. */
1269 struct tmpfs_dirent *de, dekey; in tmpfs_dir_xlookup_hash() local
1272 de = RB_FIND(tmpfs_dir, &dnode->tn_dir.tn_dirhead, &dekey); in tmpfs_dir_xlookup_hash()
1273 return (de); in tmpfs_dir_xlookup_hash()
1281 struct tmpfs_dir *dirhead = &node->tn_dir.tn_dirhead; in tmpfs_dir_lookup_cookie()
1282 struct tmpfs_dirent *de, dekey; in tmpfs_dir_lookup_cookie() local
1286 if (cookie == node->tn_dir.tn_readdir_lastn && in tmpfs_dir_lookup_cookie()
1287 (de = node->tn_dir.tn_readdir_lastp) != NULL) { in tmpfs_dir_lookup_cookie()
1289 * may be updated with only shared vnode lock held. */ in tmpfs_dir_lookup_cookie()
1290 if (cookie == tmpfs_dirent_cookie(de)) in tmpfs_dir_lookup_cookie()
1295 LIST_FOREACH(de, &node->tn_dir.tn_dupindex, in tmpfs_dir_lookup_cookie()
1297 MPASS(tmpfs_dirent_dup(de)); in tmpfs_dir_lookup_cookie()
1298 if (de->td_cookie == cookie) in tmpfs_dir_lookup_cookie()
1301 if (de->td_cookie < cookie) { in tmpfs_dir_lookup_cookie()
1302 de = NULL; in tmpfs_dir_lookup_cookie()
1306 MPASS(de == NULL); in tmpfs_dir_lookup_cookie()
1311 de = NULL; in tmpfs_dir_lookup_cookie()
1315 de = RB_NFIND(tmpfs_dir, dirhead, &dekey); in tmpfs_dir_lookup_cookie()
1317 dc->tdc_tree = de; in tmpfs_dir_lookup_cookie()
1318 dc->tdc_current = de; in tmpfs_dir_lookup_cookie()
1319 if (de != NULL && tmpfs_dirent_duphead(de)) { in tmpfs_dir_lookup_cookie()
1320 dc->tdc_current = LIST_FIRST(&de->ud.td_duphead); in tmpfs_dir_lookup_cookie()
1321 MPASS(dc->tdc_current != NULL); in tmpfs_dir_lookup_cookie()
1323 return (dc->tdc_current); in tmpfs_dir_lookup_cookie()
1326 dc->tdc_tree = de; in tmpfs_dir_lookup_cookie()
1327 dc->tdc_current = de; in tmpfs_dir_lookup_cookie()
1328 if (de != NULL && tmpfs_dirent_dup(de)) in tmpfs_dir_lookup_cookie()
1329 dc->tdc_tree = tmpfs_dir_xlookup_hash(node, in tmpfs_dir_lookup_cookie()
1330 de->td_hash); in tmpfs_dir_lookup_cookie()
1331 return (dc->tdc_current); in tmpfs_dir_lookup_cookie()
1347 struct tmpfs_dirent *de; in tmpfs_dir_lookup() local
1350 MPASS(IMPLIES(cnp->cn_namelen == 1, cnp->cn_nameptr[0] != '.')); in tmpfs_dir_lookup()
1351 MPASS(IMPLIES(cnp->cn_namelen == 2, !(cnp->cn_nameptr[0] == '.' && in tmpfs_dir_lookup()
1352 cnp->cn_nameptr[1] == '.'))); in tmpfs_dir_lookup()
1355 hash = tmpfs_dirent_hash(cnp->cn_nameptr, cnp->cn_namelen); in tmpfs_dir_lookup()
1356 de = tmpfs_dir_xlookup_hash(node, hash); in tmpfs_dir_lookup()
1357 if (de != NULL && tmpfs_dirent_duphead(de)) { in tmpfs_dir_lookup()
1358 duphead = &de->ud.td_duphead; in tmpfs_dir_lookup()
1359 LIST_FOREACH(de, duphead, uh.td_dup.entries) { in tmpfs_dir_lookup()
1360 if (TMPFS_DIRENT_MATCHES(de, cnp->cn_nameptr, in tmpfs_dir_lookup()
1361 cnp->cn_namelen)) in tmpfs_dir_lookup()
1364 } else if (de != NULL) { in tmpfs_dir_lookup()
1365 if (!TMPFS_DIRENT_MATCHES(de, cnp->cn_nameptr, in tmpfs_dir_lookup()
1366 cnp->cn_namelen)) in tmpfs_dir_lookup()
1367 de = NULL; in tmpfs_dir_lookup()
1369 if (de != NULL && f != NULL && de->td_node != f) in tmpfs_dir_lookup()
1370 de = NULL; in tmpfs_dir_lookup()
1372 return (de); in tmpfs_dir_lookup()
1376 * Attach duplicate-cookie directory entry nde to dnode and insert to dupindex
1384 struct tmpfs_dirent *de, *pde; in tmpfs_dir_attach_dup() local
1386 dupindex = &dnode->tn_dir.tn_dupindex; in tmpfs_dir_attach_dup()
1387 de = LIST_FIRST(dupindex); in tmpfs_dir_attach_dup()
1388 if (de == NULL || de->td_cookie < TMPFS_DIRCOOKIE_DUP_MAX) { in tmpfs_dir_attach_dup()
1389 if (de == NULL) in tmpfs_dir_attach_dup()
1390 nde->td_cookie = TMPFS_DIRCOOKIE_DUP_MIN; in tmpfs_dir_attach_dup()
1392 nde->td_cookie = de->td_cookie + 1; in tmpfs_dir_attach_dup()
1405 pde = de; in tmpfs_dir_attach_dup()
1406 de = LIST_NEXT(de, uh.td_dup.index_entries); in tmpfs_dir_attach_dup()
1407 if (de == NULL && pde->td_cookie != TMPFS_DIRCOOKIE_DUP_MIN) { in tmpfs_dir_attach_dup()
1412 nde->td_cookie = TMPFS_DIRCOOKIE_DUP_MIN; in tmpfs_dir_attach_dup()
1416 } else if (de == NULL) { in tmpfs_dir_attach_dup()
1420 * It should be fine except possible issues with in tmpfs_dir_attach_dup()
1423 nde->td_cookie = TMPFS_DIRCOOKIE_DUP_MAX; in tmpfs_dir_attach_dup()
1429 if (de->td_cookie + 1 == pde->td_cookie || in tmpfs_dir_attach_dup()
1430 de->td_cookie >= TMPFS_DIRCOOKIE_DUP_MAX) in tmpfs_dir_attach_dup()
1432 nde->td_cookie = de->td_cookie + 1; in tmpfs_dir_attach_dup()
1434 MPASS(pde->td_cookie > nde->td_cookie); in tmpfs_dir_attach_dup()
1435 MPASS(nde->td_cookie > de->td_cookie); in tmpfs_dir_attach_dup()
1436 LIST_INSERT_BEFORE(de, nde, uh.td_dup.index_entries); in tmpfs_dir_attach_dup()
1443 * Attaches the directory entry de to the directory represented by vp.
1448 tmpfs_dir_attach(struct vnode *vp, struct tmpfs_dirent *de) in tmpfs_dir_attach() argument
1454 MPASS(de->td_namelen > 0); in tmpfs_dir_attach()
1455 MPASS(de->td_hash >= TMPFS_DIRCOOKIE_MIN); in tmpfs_dir_attach()
1456 MPASS(de->td_cookie == de->td_hash); in tmpfs_dir_attach()
1459 dnode->tn_dir.tn_readdir_lastn = 0; in tmpfs_dir_attach()
1460 dnode->tn_dir.tn_readdir_lastp = NULL; in tmpfs_dir_attach()
1462 MPASS(!tmpfs_dirent_dup(de)); in tmpfs_dir_attach()
1463 xde = RB_INSERT(tmpfs_dir, &dnode->tn_dir.tn_dirhead, de); in tmpfs_dir_attach()
1465 tmpfs_dir_attach_dup(dnode, &xde->ud.td_duphead, de); in tmpfs_dir_attach()
1472 tmpfs_alloc_dirent(VFS_TO_TMPFS(vp->v_mount), NULL, NULL, 0, in tmpfs_dir_attach()
1476 xde->td_cookie |= TMPFS_DIRCOOKIE_DUPHEAD; in tmpfs_dir_attach()
1477 LIST_INIT(&xde->ud.td_duphead); in tmpfs_dir_attach()
1478 xde->td_namelen = 0; in tmpfs_dir_attach()
1479 xde->td_node = NULL; in tmpfs_dir_attach()
1480 tmpfs_dir_attach_dup(dnode, &xde->ud.td_duphead, nde); in tmpfs_dir_attach()
1481 tmpfs_dir_attach_dup(dnode, &xde->ud.td_duphead, de); in tmpfs_dir_attach()
1483 dnode->tn_size += sizeof(struct tmpfs_dirent); in tmpfs_dir_attach()
1484 dnode->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED; in tmpfs_dir_attach()
1485 dnode->tn_accessed = true; in tmpfs_dir_attach()
1490 * Detaches the directory entry de from the directory represented by vp.
1495 tmpfs_dir_detach(struct vnode *vp, struct tmpfs_dirent *de) in tmpfs_dir_detach() argument
1505 head = &dnode->tn_dir.tn_dirhead; in tmpfs_dir_detach()
1506 dnode->tn_dir.tn_readdir_lastn = 0; in tmpfs_dir_detach()
1507 dnode->tn_dir.tn_readdir_lastp = NULL; in tmpfs_dir_detach()
1509 if (tmpfs_dirent_dup(de)) { in tmpfs_dir_detach()
1510 /* Remove duphead if de was last entry. */ in tmpfs_dir_detach()
1511 if (LIST_NEXT(de, uh.td_dup.entries) == NULL) { in tmpfs_dir_detach()
1512 xde = tmpfs_dir_xlookup_hash(dnode, de->td_hash); in tmpfs_dir_detach()
1516 LIST_REMOVE(de, uh.td_dup.entries); in tmpfs_dir_detach()
1517 LIST_REMOVE(de, uh.td_dup.index_entries); in tmpfs_dir_detach()
1519 if (LIST_EMPTY(&xde->ud.td_duphead)) { in tmpfs_dir_detach()
1521 tmp = VFS_TO_TMPFS(vp->v_mount); in tmpfs_dir_detach()
1522 MPASS(xde->td_node == NULL); in tmpfs_dir_detach()
1526 de->td_cookie = de->td_hash; in tmpfs_dir_detach()
1528 RB_REMOVE(tmpfs_dir, head, de); in tmpfs_dir_detach()
1530 dnode->tn_size -= sizeof(struct tmpfs_dirent); in tmpfs_dir_detach()
1531 dnode->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED; in tmpfs_dir_detach()
1532 dnode->tn_accessed = true; in tmpfs_dir_detach()
1539 struct tmpfs_dirent *de, *dde, *nde; in tmpfs_dir_destroy() local
1541 RB_FOREACH_SAFE(de, tmpfs_dir, &dnode->tn_dir.tn_dirhead, nde) { in tmpfs_dir_destroy()
1542 RB_REMOVE(tmpfs_dir, &dnode->tn_dir.tn_dirhead, de); in tmpfs_dir_destroy()
1543 /* Node may already be destroyed. */ in tmpfs_dir_destroy()
1544 de->td_node = NULL; in tmpfs_dir_destroy()
1545 if (tmpfs_dirent_duphead(de)) { in tmpfs_dir_destroy()
1546 while ((dde = LIST_FIRST(&de->ud.td_duphead)) != NULL) { in tmpfs_dir_destroy()
1548 dde->td_node = NULL; in tmpfs_dir_destroy()
1552 tmpfs_free_dirent(tmp, de); in tmpfs_dir_destroy()
1559 * on success, -1 if there was not enough space in the uio structure to
1571 MPASS(uio->uio_offset == TMPFS_DIRCOOKIE_DOT); in tmpfs_dir_getdotdent()
1573 dent.d_fileno = node->tn_id; in tmpfs_dir_getdotdent()
1581 if (dent.d_reclen > uio->uio_resid) in tmpfs_dir_getdotdent()
1594 * on success, -1 if there was not enough space in the uio structure to
1607 MPASS(uio->uio_offset == TMPFS_DIRCOOKIE_DOTDOT); in tmpfs_dir_getdotdotdent()
1613 parent = node->tn_dir.tn_parent; in tmpfs_dir_getdotdotdent()
1617 dent.d_fileno = parent->tn_id; in tmpfs_dir_getdotdotdent()
1626 if (dent.d_reclen > uio->uio_resid) in tmpfs_dir_getdotdotdent()
1638 * as can fit in the uio space. The read starts at uio->uio_offset.
1639 * The function returns 0 on success, -1 if there was not enough space
1648 struct tmpfs_dirent *de, *nde; in tmpfs_dir_getdents() local
1660 * fit into the buffer. Once no more entries are found (de == NULL), in tmpfs_dir_getdents()
1664 switch (uio->uio_offset) { in tmpfs_dir_getdents()
1669 uio->uio_offset = off = TMPFS_DIRCOOKIE_DOTDOT; in tmpfs_dir_getdents()
1674 de = tmpfs_dir_first(node, &dc); in tmpfs_dir_getdents()
1675 off = tmpfs_dirent_cookie(de); in tmpfs_dir_getdents()
1679 uio->uio_offset = off; in tmpfs_dir_getdents()
1683 if (de == NULL) in tmpfs_dir_getdents()
1689 de = tmpfs_dir_lookup_cookie(node, uio->uio_offset, &dc); in tmpfs_dir_getdents()
1690 if (de == NULL) in tmpfs_dir_getdents()
1693 off = tmpfs_dirent_cookie(de); in tmpfs_dir_getdents()
1707 if (de->td_node == NULL) { in tmpfs_dir_getdents()
1711 d.d_fileno = de->td_node->tn_id; in tmpfs_dir_getdents()
1712 switch (de->td_node->tn_type) { in tmpfs_dir_getdents()
1743 de->td_node, (int)de->td_node->tn_type); in tmpfs_dir_getdents()
1746 d.d_namlen = de->td_namelen; in tmpfs_dir_getdents()
1747 MPASS(de->td_namelen < sizeof(d.d_name)); in tmpfs_dir_getdents()
1748 (void)memcpy(d.d_name, de->ud.td_name, de->td_namelen); in tmpfs_dir_getdents()
1753 * than the amount of data that can be returned. in tmpfs_dir_getdents()
1755 if (d.d_reclen > uio->uio_resid) { in tmpfs_dir_getdents()
1770 de = nde; in tmpfs_dir_getdents()
1772 off = tmpfs_dirent_cookie(de); in tmpfs_dir_getdents()
1777 } while (error == 0 && uio->uio_resid > 0 && de != NULL); in tmpfs_dir_getdents()
1781 off = tmpfs_dirent_cookie(de); in tmpfs_dir_getdents()
1784 uio->uio_offset = off; in tmpfs_dir_getdents()
1785 node->tn_dir.tn_readdir_lastn = off; in tmpfs_dir_getdents()
1786 node->tn_dir.tn_readdir_lastp = de; in tmpfs_dir_getdents()
1795 struct tmpfs_dirent *de; in tmpfs_dir_whiteout_add() local
1799 error = tmpfs_alloc_dirent(VFS_TO_TMPFS(dvp->v_mount), NULL, in tmpfs_dir_whiteout_add()
1800 cnp->cn_nameptr, cnp->cn_namelen, &de); in tmpfs_dir_whiteout_add()
1804 tmpfs_dir_attach(dvp, de); in tmpfs_dir_whiteout_add()
1805 dnode->tn_dir.tn_wht_size += sizeof(*de); in tmpfs_dir_whiteout_add()
1812 struct tmpfs_dirent *de; in tmpfs_dir_whiteout_remove() local
1816 de = tmpfs_dir_lookup(dnode, NULL, cnp); in tmpfs_dir_whiteout_remove()
1817 MPASS(de != NULL && de->td_node == NULL); in tmpfs_dir_whiteout_remove()
1818 MPASS(dnode->tn_dir.tn_wht_size >= sizeof(*de)); in tmpfs_dir_whiteout_remove()
1819 dnode->tn_dir.tn_wht_size -= sizeof(*de); in tmpfs_dir_whiteout_remove()
1820 tmpfs_dir_detach(dvp, de); in tmpfs_dir_whiteout_remove()
1821 tmpfs_free_dirent(VFS_TO_TMPFS(dvp->v_mount), de); in tmpfs_dir_whiteout_remove()
1834 struct tmpfs_dirent *de; in tmpfs_dir_clear_whiteouts() local
1839 while ((de = tmpfs_dir_first(dnode, &dc)) != NULL) { in tmpfs_dir_clear_whiteouts()
1840 KASSERT(de->td_node == NULL, ("%s: non-whiteout dirent %p", in tmpfs_dir_clear_whiteouts()
1841 __func__, de)); in tmpfs_dir_clear_whiteouts()
1842 dnode->tn_dir.tn_wht_size -= sizeof(*de); in tmpfs_dir_clear_whiteouts()
1843 tmpfs_dir_detach(dvp, de); in tmpfs_dir_clear_whiteouts()
1844 tmpfs_free_dirent(VFS_TO_TMPFS(dvp->v_mount), de); in tmpfs_dir_clear_whiteouts()
1846 MPASS(dnode->tn_size == 0); in tmpfs_dir_clear_whiteouts()
1847 MPASS(dnode->tn_dir.tn_wht_size == 0); in tmpfs_dir_clear_whiteouts()
1853 * 'newsize' must be positive.
1866 MPASS(vp->v_type == VREG); in tmpfs_reg_resize()
1870 uobj = node->tn_reg.tn_aobj; in tmpfs_reg_resize()
1878 oldsize = node->tn_size; in tmpfs_reg_resize()
1880 MPASS(oldpages == uobj->size); in tmpfs_reg_resize()
1884 node->tn_size = newsize; in tmpfs_reg_resize()
1910 uobj->size = newpages; in tmpfs_reg_resize()
1913 node->tn_size = newsize; in tmpfs_reg_resize()
1919 * Requests completely beyond the end-of-file are converted to no-op.
1934 KASSERT(*length <= OFF_MAX - *offset, ("%s: offset + length overflows", in tmpfs_reg_punch_hole()
1937 KASSERT(node->tn_type == VREG, ("%s: node is not regular file", in tmpfs_reg_punch_hole()
1939 object = node->tn_reg.tn_aobj; in tmpfs_reg_punch_hole()
1941 len = omin(node->tn_size - off, *length); in tmpfs_reg_punch_hole()
1958 * If there is a partial page at the beginning of the hole-punching in tmpfs_reg_punch_hole()
1967 off += end - startofs; in tmpfs_reg_punch_hole()
1968 len -= end - startofs; in tmpfs_reg_punch_hole()
1976 off += IDX_TO_OFF(piend - pi); in tmpfs_reg_punch_hole()
1977 len -= IDX_TO_OFF(piend - pi); in tmpfs_reg_punch_hole()
1981 * If there is a partial page at the end of the hole-punching request, in tmpfs_reg_punch_hole()
1990 len -= endofs; in tmpfs_reg_punch_hole()
2007 if (vp->v_type != VREG) in tmpfs_check_mtime()
2009 obj = vp->v_object; in tmpfs_check_mtime()
2010 KASSERT(obj->type == tmpfs_pager_type && in tmpfs_check_mtime()
2011 (obj->flags & (OBJ_SWAP | OBJ_TMPFS)) == in tmpfs_check_mtime()
2012 (OBJ_SWAP | OBJ_TMPFS), ("non-tmpfs obj")); in tmpfs_check_mtime()
2014 if (obj->generation != obj->cleangeneration) { in tmpfs_check_mtime()
2016 if (obj->generation != obj->cleangeneration) { in tmpfs_check_mtime()
2017 obj->cleangeneration = obj->generation; in tmpfs_check_mtime()
2019 node->tn_status |= TMPFS_NODE_MODIFIED | in tmpfs_check_mtime()
2029 * The vnode must be locked on entry and remain locked on exit.
2048 /* Disallow this operation if the file system is mounted read-only. */ in tmpfs_chflags()
2049 if (vp->v_mount->mnt_flag & MNT_RDONLY) in tmpfs_chflags()
2063 if (node->tn_flags & in tmpfs_chflags()
2070 if (node->tn_flags & in tmpfs_chflags()
2072 ((flags ^ node->tn_flags) & SF_SETTABLE)) in tmpfs_chflags()
2075 node->tn_flags = flags; in tmpfs_chflags()
2076 node->tn_status |= TMPFS_NODE_CHANGED; in tmpfs_chflags()
2086 * The vnode must be locked on entry and remain locked on exit.
2101 /* Disallow this operation if the file system is mounted read-only. */ in tmpfs_chmod()
2102 if (vp->v_mount->mnt_flag & MNT_RDONLY) in tmpfs_chmod()
2105 /* Immutable or append-only files cannot be modified, either. */ in tmpfs_chmod()
2106 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chmod()
2117 * Privileged processes may set the sticky bit on non-directories, in tmpfs_chmod()
2121 if (vp->v_type != VDIR && (mode & S_ISTXT)) { in tmpfs_chmod()
2125 if (!groupmember(node->tn_gid, cred) && (mode & S_ISGID)) { in tmpfs_chmod()
2131 newmode = node->tn_mode & ~ALLPERMS; in tmpfs_chmod()
2133 atomic_store_short(&node->tn_mode, newmode); in tmpfs_chmod()
2135 node->tn_status |= TMPFS_NODE_CHANGED; in tmpfs_chmod()
2144 * be different than VNOVAL. If one is set to that value, the attribute
2147 * The vnode must be locked on entry and remain locked on exit.
2167 uid = node->tn_uid; in tmpfs_chown()
2169 gid = node->tn_gid; in tmpfs_chown()
2172 /* Disallow this operation if the file system is mounted read-only. */ in tmpfs_chown()
2173 if (vp->v_mount->mnt_flag & MNT_RDONLY) in tmpfs_chown()
2176 /* Immutable or append-only files cannot be modified, either. */ in tmpfs_chown()
2177 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chown()
2192 if ((uid != node->tn_uid || in tmpfs_chown()
2193 (gid != node->tn_gid && !groupmember(gid, cred))) && in tmpfs_chown()
2197 ogid = node->tn_gid; in tmpfs_chown()
2198 ouid = node->tn_uid; in tmpfs_chown()
2200 node->tn_uid = uid; in tmpfs_chown()
2201 node->tn_gid = gid; in tmpfs_chown()
2203 node->tn_status |= TMPFS_NODE_CHANGED; in tmpfs_chown()
2205 if ((node->tn_mode & (S_ISUID | S_ISGID)) != 0 && in tmpfs_chown()
2208 newmode = node->tn_mode & ~(S_ISUID | S_ISGID); in tmpfs_chown()
2209 atomic_store_short(&node->tn_mode, newmode); in tmpfs_chown()
2221 * The vnode must be locked on entry and remain locked on exit.
2236 switch (vp->v_type) { in tmpfs_chsize()
2241 if (vp->v_mount->mnt_flag & MNT_RDONLY) in tmpfs_chsize()
2252 * system is mounted read-only (we are not modifying the in tmpfs_chsize()
2262 /* Immutable or append-only files cannot be modified, either. */ in tmpfs_chsize()
2263 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chsize()
2284 * The vnode must be locked on entry and remain locked on exit.
2297 /* Disallow this operation if the file system is mounted read-only. */ in tmpfs_chtimes()
2298 if (vp->v_mount->mnt_flag & MNT_RDONLY) in tmpfs_chtimes()
2301 /* Immutable or append-only files cannot be modified, either. */ in tmpfs_chtimes()
2302 if (node->tn_flags & (IMMUTABLE | APPEND)) in tmpfs_chtimes()
2309 if (vap->va_atime.tv_sec != VNOVAL) in tmpfs_chtimes()
2310 node->tn_accessed = true; in tmpfs_chtimes()
2311 if (vap->va_mtime.tv_sec != VNOVAL) in tmpfs_chtimes()
2312 node->tn_status |= TMPFS_NODE_MODIFIED; in tmpfs_chtimes()
2313 if (vap->va_birthtime.tv_sec != VNOVAL) in tmpfs_chtimes()
2314 node->tn_status |= TMPFS_NODE_MODIFIED; in tmpfs_chtimes()
2315 tmpfs_itimes(vp, &vap->va_atime, &vap->va_mtime); in tmpfs_chtimes()
2316 if (vap->va_birthtime.tv_sec != VNOVAL) in tmpfs_chtimes()
2317 node->tn_birthtime = vap->va_birthtime; in tmpfs_chtimes()
2327 if ((node->tn_status & status) == status || tm->tm_ronly) in tmpfs_set_status()
2330 node->tn_status |= status; in tmpfs_set_status()
2337 if (node->tn_accessed || tm->tm_ronly) in tmpfs_set_accessed()
2339 atomic_store_8(&node->tn_accessed, true); in tmpfs_set_accessed()
2353 if (!node->tn_accessed && in tmpfs_itimes()
2354 (node->tn_status & (TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED)) == 0) in tmpfs_itimes()
2359 if (node->tn_accessed) { in tmpfs_itimes()
2362 node->tn_atime = *acc; in tmpfs_itimes()
2364 if (node->tn_status & TMPFS_NODE_MODIFIED) { in tmpfs_itimes()
2367 node->tn_mtime = *mod; in tmpfs_itimes()
2369 if (node->tn_status & TMPFS_NODE_CHANGED) in tmpfs_itimes()
2370 node->tn_ctime = now; in tmpfs_itimes()
2371 node->tn_status &= ~(TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED); in tmpfs_itimes()
2372 node->tn_accessed = false; in tmpfs_itimes()
2375 /* XXX: FIX? The entropy here is desirable, but the harvesting may be expensive */ in tmpfs_itimes()
2387 if (length > VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize) in tmpfs_truncate()
2391 error = node->tn_size == length ? 0 : tmpfs_reg_resize(vp, length, in tmpfs_truncate()
2394 node->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED; in tmpfs_truncate()
2403 if (a->td_hash > b->td_hash) in tmpfs_dirtree_cmp()
2405 else if (a->td_hash < b->td_hash) in tmpfs_dirtree_cmp()
2406 return (-1); in tmpfs_dirtree_cmp()