Lines Matching defs:node
201 * Tmpfs VREG node, which was reclaimed, has tmpfs_pager_type
225 struct tmpfs_node *node;
233 node = obj->un_pager.swp.swp_priv;
234 MPASS(node->tn_type == VREG);
235 tm = node->tn_reg.tn_tmp;
241 KASSERT(node->tn_reg.tn_pages >= c,
242 ("tmpfs node %p pages %jd free %jd", node,
243 (uintmax_t)node->tn_reg.tn_pages, (uintmax_t)c));
244 node->tn_reg.tn_pages -= c;
250 struct tmpfs_node *node;
256 node = obj->un_pager.swp.swp_priv;
257 MPASS(node->tn_type == VREG);
258 tm = node->tn_reg.tn_tmp;
262 node->tn_reg.tn_pages += 1;
269 struct tmpfs_node *node;
275 node = obj->un_pager.swp.swp_priv;
276 MPASS(node->tn_type == VREG);
277 tm = node->tn_reg.tn_tmp;
284 KASSERT(node->tn_reg.tn_pages >= 1,
285 ("tmpfs node %p pages %jd free 1", node,
286 (uintmax_t)node->tn_reg.tn_pages));
287 node->tn_reg.tn_pages -= 1;
322 struct tmpfs_node *node;
324 node = mem;
325 node->tn_gen++;
326 node->tn_size = 0;
327 node->tn_status = 0;
328 node->tn_accessed = false;
329 node->tn_flags = 0;
330 node->tn_links = 0;
331 node->tn_vnode = NULL;
332 node->tn_vpstate = 0;
339 struct tmpfs_node *node;
341 node = mem;
342 node->tn_type = VNON;
348 struct tmpfs_node *node;
350 node = mem;
351 node->tn_id = 0;
352 mtx_init(&node->tn_interlock, "tmpfsni", NULL, MTX_DEF | MTX_NEW);
353 node->tn_gen = arc4random();
360 struct tmpfs_node *node;
362 node = mem;
363 mtx_destroy(&node->tn_interlock);
373 tmpfs_node_pool = uma_zcreate("TMPFS node",
544 tmpfs_ref_node(struct tmpfs_node *node)
551 refcount_acquire(&node->tn_refcount);
553 KASSERT(old > 0, ("node %p zero refcount", node));
558 * Allocates a new node of type 'type' inside the 'tmp' mount point, with
562 * If the node type is set to 'VDIR', then the parent parameter must point
563 * to the parent directory of the node being created. It may only be NULL
564 * while allocating the root node.
566 * If the node type is set to 'VBLK' or 'VCHR', then the rdev parameter
567 * specifies the device the node represents.
569 * If the node type is set to 'VLNK', then the parameter target specifies
574 * items or, if it is empty, from the node pool as long as there is enough
582 const char *target, dev_t rdev, struct tmpfs_node **node)
602 * When a new tmpfs node is created for fully
604 * node, which vnode is locked exclusively. As
609 * cannot be destroyed until node construction is
685 * 4. tn_link_target content is immutable until node
690 * on the node pointer to also get the above content
723 *node = nnode;
728 * Destroys the node pointed to by node from the file system 'tmp'.
729 * If the node references a directory, no entries are allowed.
732 tmpfs_free_node(struct tmpfs_mount *tmp, struct tmpfs_node *node)
734 if (refcount_release_if_not_last(&node->tn_refcount))
738 TMPFS_NODE_LOCK(node);
739 if (!tmpfs_free_node_locked(tmp, node, false)) {
740 TMPFS_NODE_UNLOCK(node);
746 tmpfs_free_node_locked(struct tmpfs_mount *tmp, struct tmpfs_node *node,
755 TMPFS_NODE_ASSERT_LOCKED(node);
757 last = refcount_release(&node->tn_refcount);
758 if (node->tn_attached && (detach || last)) {
761 LIST_REMOVE(node, tn_entries);
762 node->tn_attached = false;
767 TMPFS_NODE_UNLOCK(node);
770 MPASS(node->tn_vnode == NULL);
771 MPASS((node->tn_vpstate & TMPFS_VNODE_ALLOCATING) == 0);
774 * Make sure this is a node type we can deal with. Everything
779 switch (node->tn_type) {
791 panic("%s: bad type %d for node %p", __func__,
792 (int)node->tn_type, node);
796 while ((ea = LIST_FIRST(&node->tn_extattrs)) != NULL) {
801 switch (node->tn_type) {
803 uobj = node->tn_reg.tn_aobj;
804 node->tn_reg.tn_aobj = NULL;
808 ("tmpfs node %p uobj %p not tmpfs", node, uobj));
810 KASSERT(tmp->tm_pages_used >= node->tn_reg.tn_pages,
811 ("tmpfs tmp %p node %p pages %jd free %jd", tmp,
812 node, (uintmax_t)tmp->tm_pages_used,
813 (uintmax_t)node->tn_reg.tn_pages));
815 -node->tn_reg.tn_pages);
833 symlink = node->tn_link_target;
834 atomic_store_ptr(&node->tn_link_target, NULL);
835 if (atomic_load_char(&node->tn_link_smr)) {
836 cache_symlink_free(symlink, node->tn_size + 1);
846 uma_zfree_smr(tmpfs_node_pool, node);
897 * Allocates a new directory entry for the node node with a name of name.
900 * The link count of node is increased by one to reflect the new object
906 tmpfs_alloc_dirent(struct tmpfs_mount *tmp, struct tmpfs_node *node,
912 nde->td_node = node;
918 if (node != NULL)
919 node->tn_links++;
928 * the node referenced by it if needed.
930 * The link count of node is decreased by one to reflect the removal of an
932 * otherwise the function will not access the node referred to by the
938 struct tmpfs_node *node;
940 node = de->td_node;
941 if (node != NULL) {
942 MPASS(node->tn_links > 0);
943 node->tn_links--;
982 * Allocates a new vnode for the node node or returns a new reference to
983 * an existing one if the node had already a vnode referencing it. The
989 tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, int lkflag,
1000 TMPFS_NODE_LOCK(node);
1001 tmpfs_ref_node(node);
1003 TMPFS_NODE_ASSERT_LOCKED(node);
1004 if ((vp = node->tn_vnode) != NULL) {
1005 MPASS((node->tn_vpstate & TMPFS_VNODE_DOOMED) == 0);
1006 if ((node->tn_type == VDIR && node->tn_dir.tn_parent == NULL) ||
1009 TMPFS_NODE_UNLOCK(node);
1015 node->tn_vpstate |= TMPFS_VNODE_WRECLAIM;
1016 while ((node->tn_vpstate & TMPFS_VNODE_WRECLAIM) != 0) {
1017 msleep(&node->tn_vnode, TMPFS_NODE_MTX(node),
1023 TMPFS_NODE_UNLOCK(node);
1026 TMPFS_NODE_LOCK(node);
1038 if (node->tn_vnode != vp) {
1040 TMPFS_NODE_LOCK(node);
1047 if ((node->tn_vpstate & TMPFS_VNODE_DOOMED) ||
1048 (node->tn_type == VDIR && node->tn_dir.tn_parent == NULL)) {
1049 TMPFS_NODE_UNLOCK(node);
1059 if (node->tn_vpstate & TMPFS_VNODE_ALLOCATING) {
1060 node->tn_vpstate |= TMPFS_VNODE_WANT;
1061 error = msleep((caddr_t) &node->tn_vpstate,
1062 TMPFS_NODE_MTX(node), 0, "tmpfs_alloc_vp", 0);
1067 node->tn_vpstate |= TMPFS_VNODE_ALLOCATING;
1069 TMPFS_NODE_UNLOCK(node);
1071 /* Get a new vnode and associate it with our node. */
1081 vp->v_data = node;
1082 vp->v_type = node->tn_type;
1085 switch (node->tn_type) {
1098 object = node->tn_reg.tn_aobj;
1119 MPASS(node->tn_dir.tn_parent != NULL);
1120 if (node->tn_dir.tn_parent == node)
1125 panic("tmpfs_alloc_vp: type %p %d", node, (int)node->tn_type);
1145 TMPFS_NODE_LOCK(node);
1147 MPASS(node->tn_vpstate & TMPFS_VNODE_ALLOCATING);
1148 node->tn_vpstate &= ~TMPFS_VNODE_ALLOCATING;
1149 node->tn_vnode = vp;
1151 if (node->tn_vpstate & TMPFS_VNODE_WANT) {
1152 node->tn_vpstate &= ~TMPFS_VNODE_WANT;
1153 TMPFS_NODE_UNLOCK(node);
1154 wakeup((caddr_t) &node->tn_vpstate);
1156 TMPFS_NODE_UNLOCK(node);
1165 TMPFS_NODE_LOCK(node);
1166 MPASS(*vpp == node->tn_vnode);
1167 TMPFS_NODE_UNLOCK(node);
1170 tmpfs_free_node(tm, node);
1176 * Destroys the association between the vnode vp and the node it
1182 struct tmpfs_node *node;
1184 node = VP_TO_TMPFS_NODE(vp);
1186 TMPFS_NODE_ASSERT_LOCKED(node);
1187 node->tn_vnode = NULL;
1188 if ((node->tn_vpstate & TMPFS_VNODE_WRECLAIM) != 0)
1189 wakeup(&node->tn_vnode);
1190 node->tn_vpstate &= ~TMPFS_VNODE_WRECLAIM;
1212 struct tmpfs_node *node;
1237 /* Allocate a node that represents the new file. */
1240 target, vap->va_rdev, &node);
1245 error = tmpfs_alloc_dirent(tmp, node, cnp->cn_nameptr, cnp->cn_namelen,
1248 tmpfs_free_node(tmp, node);
1253 error = tmpfs_alloc_vp(dvp->v_mount, node, LK_EXCLUSIVE, vpp);
1256 tmpfs_free_node(tmp, node);
1261 * insert the new node into the directory, an operation that
1317 tmpfs_dir_lookup_cookie(struct tmpfs_node *node, off_t cookie,
1320 struct tmpfs_dir *dirhead = &node->tn_dir.tn_dirhead;
1325 if (cookie == node->tn_dir.tn_readdir_lastn &&
1326 (de = node->tn_dir.tn_readdir_lastp) != NULL) {
1334 LIST_FOREACH(de, &node->tn_dir.tn_dupindex,
1368 dc->tdc_tree = tmpfs_dir_xlookup_hash(node,
1374 * Looks for a directory entry in the directory represented by node.
1382 tmpfs_dir_lookup(struct tmpfs_node *node, struct tmpfs_node *f,
1392 TMPFS_VALIDATE_DIR(node);
1395 de = tmpfs_dir_xlookup_hash(node, hash);
1483 * Note that this does not change the link count of the node pointed by
1530 * Note that this does not change the link count of the node pointed by
1603 tmpfs_dir_getdotdent(struct tmpfs_mount *tm, struct tmpfs_node *node,
1609 TMPFS_VALIDATE_DIR(node);
1612 dent.d_fileno = node->tn_id;
1625 tmpfs_set_accessed(tm, node);
1638 tmpfs_dir_getdotdotdent(struct tmpfs_mount *tm, struct tmpfs_node *node,
1645 TMPFS_VALIDATE_DIR(node);
1649 * Return ENOENT if the current node is already removed.
1651 TMPFS_ASSERT_LOCKED(node);
1652 parent = node->tn_dir.tn_parent;
1670 tmpfs_set_accessed(tm, node);
1683 tmpfs_dir_getdents(struct tmpfs_mount *tm, struct tmpfs_node *node,
1691 TMPFS_VALIDATE_DIR(node);
1696 * Lookup the node from the current offset. The starting offset of
1705 error = tmpfs_dir_getdotdent(tm, node, uio);
1713 de = tmpfs_dir_first(node, &dc);
1715 error = tmpfs_dir_getdotdotdent(tm, node, uio, off);
1728 de = tmpfs_dir_lookup_cookie(node, uio->uio_offset, &dc);
1799 nde = tmpfs_dir_next(node, &dc);
1824 node->tn_dir.tn_readdir_lastn = off;
1825 node->tn_dir.tn_readdir_lastp = de;
1827 tmpfs_set_accessed(tm, node);
1899 struct tmpfs_node *node;
1908 node = VP_TO_TMPFS_NODE(vp);
1909 uobj = node->tn_reg.tn_aobj;
1917 oldsize = node->tn_size;
1923 node->tn_size = newsize;
1952 node->tn_size = newsize;
1966 struct tmpfs_node *node;
1975 node = VP_TO_TMPFS_NODE(vp);
1976 KASSERT(node->tn_type == VREG, ("%s: node is not regular file",
1978 object = node->tn_reg.tn_aobj;
1980 len = omin(node->tn_size - off, *length);
2042 struct tmpfs_node *node;
2057 node = VP_TO_TMPFS_NODE(vp);
2058 node->tn_status |= TMPFS_NODE_MODIFIED |
2075 struct tmpfs_node *node;
2079 node = VP_TO_TMPFS_NODE(vp);
2102 if (node->tn_flags &
2109 if (node->tn_flags &
2111 ((flags ^ node->tn_flags) & SF_SETTABLE))
2114 node->tn_flags = flags;
2115 node->tn_status |= TMPFS_NODE_CHANGED;
2132 struct tmpfs_node *node;
2138 node = VP_TO_TMPFS_NODE(vp);
2145 if (node->tn_flags & (IMMUTABLE | APPEND))
2164 if (!groupmember(node->tn_gid, cred) && (mode & S_ISGID)) {
2170 newmode = node->tn_mode & ~ALLPERMS;
2172 atomic_store_short(&node->tn_mode, newmode);
2174 node->tn_status |= TMPFS_NODE_CHANGED;
2193 struct tmpfs_node *node;
2201 node = VP_TO_TMPFS_NODE(vp);
2206 uid = node->tn_uid;
2208 gid = node->tn_gid;
2216 if (node->tn_flags & (IMMUTABLE | APPEND))
2231 if ((uid != node->tn_uid ||
2232 (gid != node->tn_gid && !groupmember(gid, cred))) &&
2236 ogid = node->tn_gid;
2237 ouid = node->tn_uid;
2239 node->tn_uid = uid;
2240 node->tn_gid = gid;
2242 node->tn_status |= TMPFS_NODE_CHANGED;
2244 if ((node->tn_mode & (S_ISUID | S_ISGID)) != 0 &&
2247 newmode = node->tn_mode & ~(S_ISUID | S_ISGID);
2248 atomic_store_short(&node->tn_mode, newmode);
2267 struct tmpfs_node *node;
2271 node = VP_TO_TMPFS_NODE(vp);
2302 if (node->tn_flags & (IMMUTABLE | APPEND))
2330 struct tmpfs_node *node;
2334 node = VP_TO_TMPFS_NODE(vp);
2341 if (node->tn_flags & (IMMUTABLE | APPEND))
2349 node->tn_accessed = true;
2351 node->tn_status |= TMPFS_NODE_MODIFIED;
2353 node->tn_status |= TMPFS_NODE_MODIFIED;
2356 node->tn_birthtime = vap->va_birthtime;
2363 tmpfs_set_status(struct tmpfs_mount *tm, struct tmpfs_node *node, int status)
2366 if ((node->tn_status & status) == status || tm->tm_ronly)
2368 TMPFS_NODE_LOCK(node);
2369 node->tn_status |= status;
2370 TMPFS_NODE_UNLOCK(node);
2374 tmpfs_set_accessed(struct tmpfs_mount *tm, struct tmpfs_node *node)
2376 if (node->tn_accessed || tm->tm_ronly)
2378 atomic_store_8(&node->tn_accessed, true);
2386 struct tmpfs_node *node;
2390 node = VP_TO_TMPFS_NODE(vp);
2392 if (!node->tn_accessed &&
2393 (node->tn_status & (TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED)) == 0)
2397 TMPFS_NODE_LOCK(node);
2398 if (node->tn_accessed) {
2401 node->tn_atime = *acc;
2403 if (node->tn_status & TMPFS_NODE_MODIFIED) {
2406 node->tn_mtime = *mod;
2408 if (node->tn_status & TMPFS_NODE_CHANGED)
2409 node->tn_ctime = now;
2410 node->tn_status &= ~(TMPFS_NODE_MODIFIED | TMPFS_NODE_CHANGED);
2411 node->tn_accessed = false;
2412 TMPFS_NODE_UNLOCK(node);
2415 random_harvest_queue(node, sizeof(*node), RANDOM_FS_ATIME);
2421 struct tmpfs_node *node;
2429 node = VP_TO_TMPFS_NODE(vp);
2430 error = node->tn_size == length ? 0 : tmpfs_reg_resize(vp, length,
2433 node->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED;