Lines Matching +full:vm +full:- +full:map
3 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
39 * sub-system to store file data and metadata in an efficient way.
40 * This means that it does not follow the structure of an on-disk file
42 * memory-specific data structures and algorithms to automatically
66 #include <vm/vm.h>
67 #include <vm/vm_param.h>
68 #include <vm/pmap.h>
69 #include <vm/vm_extern.h>
70 #include <vm/vm_map.h>
71 #include <vm/vm_object.h>
72 #include <vm/vm_param.h>
105 if (vp->v_type != VREG) in tmpfs_update_mtime_lazy_filter()
108 obj = atomic_load_ptr(&vp->v_object); in tmpfs_update_mtime_lazy_filter()
133 if (VFS_TO_TMPFS(mp)->tm_nomtime) in tmpfs_update_mtime_all()
136 if (vp->v_type != VREG) { in tmpfs_update_mtime_all()
153 tmpfs_check_rw_maps_cb(struct mount *mp __unused, vm_map_t map __unused, in tmpfs_check_rw_maps_cb()
159 a->found = true; in tmpfs_check_rw_maps_cb()
168 tmpfs_revoke_rw_maps_cb(struct mount *mp __unused, vm_map_t map, in tmpfs_revoke_rw_maps_cb() argument
177 entry->max_protection &= ~VM_PROT_WRITE; in tmpfs_revoke_rw_maps_cb()
178 if ((entry->protection & VM_PROT_WRITE) != 0) { in tmpfs_revoke_rw_maps_cb()
179 entry->protection &= ~VM_PROT_WRITE; in tmpfs_revoke_rw_maps_cb()
180 pmap_protect(map->pmap, entry->start, entry->end, in tmpfs_revoke_rw_maps_cb()
181 entry->protection); in tmpfs_revoke_rw_maps_cb()
191 struct vmspace *vm; in tmpfs_all_rw_maps() local
192 vm_map_t map; in tmpfs_all_rw_maps() local
205 if (p->p_state != PRS_NORMAL || (p->p_flag & (P_INEXEC | in tmpfs_all_rw_maps()
210 vm = vmspace_acquire_ref(p); in tmpfs_all_rw_maps()
213 if (vm == NULL) { in tmpfs_all_rw_maps()
218 map = &vm->vm_map; in tmpfs_all_rw_maps()
220 vm_map_lock(map); in tmpfs_all_rw_maps()
221 if (map->busy) in tmpfs_all_rw_maps()
222 vm_map_wait_busy(map); in tmpfs_all_rw_maps()
223 VM_MAP_ENTRY_FOREACH(entry, map) { in tmpfs_all_rw_maps()
224 if ((entry->eflags & (MAP_ENTRY_GUARD | in tmpfs_all_rw_maps()
226 (entry->max_protection & VM_PROT_WRITE) == 0) in tmpfs_all_rw_maps()
228 object = entry->object.vm_object; in tmpfs_all_rw_maps()
229 if (object == NULL || object->type != tmpfs_pager_type) in tmpfs_all_rw_maps()
237 if (object->type == OBJT_DEAD) { in tmpfs_all_rw_maps()
241 MPASS(object->ref_count > 1); in tmpfs_all_rw_maps()
242 if ((object->flags & OBJ_TMPFS) == 0) { in tmpfs_all_rw_maps()
247 if (vp->v_mount != mp) { in tmpfs_all_rw_maps()
252 terminate = cb(mp, map, entry, cb_arg); in tmpfs_all_rw_maps()
257 vm_map_unlock(map); in tmpfs_all_rw_maps()
259 vmspace_free(vm); in tmpfs_all_rw_maps()
286 forced = (mp->mnt_flag & MNT_FORCE) != 0; in tmpfs_rw_to_ro()
298 VFS_TO_TMPFS(mp)->tm_ronly = 1; in tmpfs_rw_to_ro()
300 mp->mnt_flag |= MNT_RDONLY; in tmpfs_rw_to_ro()
307 VFS_TO_TMPFS(mp)->tm_ronly = 0; in tmpfs_rw_to_ro()
309 mp->mnt_flag &= ~MNT_RDONLY; in tmpfs_rw_to_ro()
341 if (vfs_filteropt(mp->mnt_optnew, tmpfs_opts)) in tmpfs_mount()
344 if (mp->mnt_flag & MNT_UPDATE) { in tmpfs_mount()
346 if (vfs_filteropt(mp->mnt_optnew, tmpfs_updateopts) != 0) in tmpfs_mount()
349 if (vfs_getopt_size(mp->mnt_optnew, "size", &size_max) == 0) { in tmpfs_mount()
351 * On-the-fly resizing is not supported (yet). We still in tmpfs_mount()
357 if (size_max != tmp->tm_size_max) in tmpfs_mount()
360 if (vfs_getopt_size(mp->mnt_optnew, "easize", &ea_max_size) == 0) { in tmpfs_mount()
361 tmp->tm_ea_memory_max = ea_max_size; in tmpfs_mount()
363 if (vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) && in tmpfs_mount()
364 !tmp->tm_ronly) { in tmpfs_mount()
365 /* RW -> RO */ in tmpfs_mount()
367 } else if (!vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) && in tmpfs_mount()
368 tmp->tm_ronly) { in tmpfs_mount()
369 /* RO -> RW */ in tmpfs_mount()
370 tmp->tm_ronly = 0; in tmpfs_mount()
372 mp->mnt_flag &= ~MNT_RDONLY; in tmpfs_mount()
375 tmp->tm_nomtime = vfs_getopt(mp->mnt_optnew, "nomtime", NULL, in tmpfs_mount()
378 if ((mp->mnt_flag & MNT_UNION) == 0) { in tmpfs_mount()
379 mp->mnt_kern_flag |= MNTK_FPLOOKUP; in tmpfs_mount()
381 mp->mnt_kern_flag &= ~MNTK_FPLOOKUP; in tmpfs_mount()
387 vn_lock(mp->mnt_vnodecovered, LK_SHARED | LK_RETRY); in tmpfs_mount()
388 error = VOP_GETATTR(mp->mnt_vnodecovered, &va, mp->mnt_cred); in tmpfs_mount()
389 VOP_UNLOCK(mp->mnt_vnodecovered); in tmpfs_mount()
393 if (mp->mnt_cred->cr_ruid != 0 || in tmpfs_mount()
394 vfs_scanopt(mp->mnt_optnew, "gid", "%d", &root_gid) != 1) in tmpfs_mount()
396 if (mp->mnt_cred->cr_ruid != 0 || in tmpfs_mount()
397 vfs_scanopt(mp->mnt_optnew, "uid", "%d", &root_uid) != 1) in tmpfs_mount()
399 if (mp->mnt_cred->cr_ruid != 0 || in tmpfs_mount()
400 vfs_scanopt(mp->mnt_optnew, "mode", "%ho", &root_mode) != 1) in tmpfs_mount()
402 if (vfs_getopt_size(mp->mnt_optnew, "inodes", &nodes_max) != 0) in tmpfs_mount()
404 if (vfs_getopt_size(mp->mnt_optnew, "size", &size_max) != 0) in tmpfs_mount()
406 if (vfs_getopt_size(mp->mnt_optnew, "maxfilesize", &maxfilesize) != 0) in tmpfs_mount()
408 if (vfs_getopt_size(mp->mnt_optnew, "easize", &ea_max_size) != 0) in tmpfs_mount()
410 nonc = vfs_getopt(mp->mnt_optnew, "nonc", NULL, NULL) == 0; in tmpfs_mount()
411 nomtime = vfs_getopt(mp->mnt_optnew, "nomtime", NULL, NULL) == 0; in tmpfs_mount()
412 pgread = vfs_getopt(mp->mnt_optnew, "pgread", NULL, NULL) == 0; in tmpfs_mount()
423 if (size_max == 0 || size_max > OFF_MAX - PAGE_SIZE || in tmpfs_mount()
446 mtx_init(&tmp->tm_allnode_lock, "tmpfs allnode lock", NULL, MTX_DEF); in tmpfs_mount()
447 tmp->tm_nodes_max = nodes_max; in tmpfs_mount()
448 tmp->tm_nodes_inuse = 0; in tmpfs_mount()
449 tmp->tm_ea_memory_inuse = 0; in tmpfs_mount()
450 tmp->tm_refcount = 1; in tmpfs_mount()
451 tmp->tm_maxfilesize = maxfilesize > 0 ? maxfilesize : OFF_MAX; in tmpfs_mount()
452 tmp->tm_ea_memory_max = ea_max_size > 0 ? in tmpfs_mount()
454 LIST_INIT(&tmp->tm_nodes_used); in tmpfs_mount()
456 tmp->tm_size_max = size_max; in tmpfs_mount()
457 tmp->tm_pages_max = pages; in tmpfs_mount()
458 tmp->tm_pages_used = 0; in tmpfs_mount()
459 new_unrhdr64(&tmp->tm_ino_unr, 2); in tmpfs_mount()
460 tmp->tm_ronly = (mp->mnt_flag & MNT_RDONLY) != 0; in tmpfs_mount()
461 tmp->tm_nonc = nonc; in tmpfs_mount()
462 tmp->tm_nomtime = nomtime; in tmpfs_mount()
463 tmp->tm_pgread = pgread; in tmpfs_mount()
473 KASSERT(root->tn_id == 2, in tmpfs_mount()
474 ("tmpfs root with invalid ino: %ju", (uintmax_t)root->tn_id)); in tmpfs_mount()
475 tmp->tm_root = root; in tmpfs_mount()
478 mp->mnt_flag |= MNT_LOCAL; in tmpfs_mount()
479 mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED | in tmpfs_mount()
481 if (!nonc && (mp->mnt_flag & MNT_UNION) == 0) in tmpfs_mount()
482 mp->mnt_kern_flag |= MNTK_FPLOOKUP; in tmpfs_mount()
485 mp->mnt_data = tmp; in tmpfs_mount()
486 mp->mnt_stat.f_namemax = MAXNAMLEN; in tmpfs_mount()
520 if (mp->mnt_nvnodelistsize == 0) { in tmpfs_unmount()
532 while ((node = LIST_FIRST(&tmp->tm_nodes_used)) != NULL) { in tmpfs_unmount()
534 if (node->tn_type == VDIR) in tmpfs_unmount()
542 mp->mnt_data = NULL; in tmpfs_unmount()
553 MPASS(tmp->tm_refcount > 0); in tmpfs_free_tmp()
555 tmp->tm_refcount--; in tmpfs_free_tmp()
556 if (tmp->tm_refcount > 0) { in tmpfs_free_tmp()
562 mtx_destroy(&tmp->tm_allnode_lock); in tmpfs_free_tmp()
564 * We cannot assert that tmp->tm_pages_used == 0 there, in tmpfs_free_tmp()
568 MPASS(tmp->tm_nodes_inuse == 0); in tmpfs_free_tmp()
578 error = tmpfs_alloc_vp(mp, VFS_TO_TMPFS(mp)->tm_root, flags, vpp); in tmpfs_root()
580 (*vpp)->v_vflag |= VV_ROOT; in tmpfs_root()
593 if (fhp->fid_len != sizeof(*tfd)) in tmpfs_fhtovp()
600 if (tfd->tfd_id >= tmp->tm_nodes_max) in tmpfs_fhtovp()
604 LIST_FOREACH(node, &tmp->tm_nodes_used, tn_entries) { in tmpfs_fhtovp()
605 if (node->tn_id == tfd->tfd_id && in tmpfs_fhtovp()
606 node->tn_gen == tfd->tfd_gen) { in tmpfs_fhtovp()
630 sbp->f_iosize = PAGE_SIZE; in tmpfs_statfs()
631 sbp->f_bsize = PAGE_SIZE; in tmpfs_statfs()
634 if (tmp->tm_pages_max != ULONG_MAX) in tmpfs_statfs()
635 sbp->f_blocks = tmp->tm_pages_max; in tmpfs_statfs()
637 sbp->f_blocks = used + tmpfs_mem_avail(); in tmpfs_statfs()
638 if (sbp->f_blocks <= used) in tmpfs_statfs()
639 sbp->f_bavail = 0; in tmpfs_statfs()
641 sbp->f_bavail = sbp->f_blocks - used; in tmpfs_statfs()
642 sbp->f_bfree = sbp->f_bavail; in tmpfs_statfs()
643 used = tmp->tm_nodes_inuse; in tmpfs_statfs()
644 sbp->f_files = tmp->tm_nodes_max; in tmpfs_statfs()
645 if (sbp->f_files <= used) in tmpfs_statfs()
646 sbp->f_ffree = 0; in tmpfs_statfs()
648 sbp->f_ffree = sbp->f_files - used; in tmpfs_statfs()
649 /* sbp->f_owner = tmp->tn_uid; */ in tmpfs_statfs()
660 mp->mnt_kern_flag |= MNTK_SUSPEND2 | MNTK_SUSPENDED; in tmpfs_sync()
711 mp->mnt_stat.f_mntonname, tmp); in db_print_tmpfs()
716 (uintmax_t)tmp->tm_size_max, tmp->tm_pages_max, tmp->tm_pages_used, in db_print_tmpfs()
717 (uintmax_t)tmp->tm_nodes_max, (uintmax_t)tmp->tm_nodes_inuse, in db_print_tmpfs()
718 (uintmax_t)tmp->tm_ea_memory_inuse, (uintmax_t)tmp->tm_refcount, in db_print_tmpfs()
719 (uintmax_t)tmp->tm_maxfilesize, in db_print_tmpfs()
720 tmp->tm_ronly ? 'o' : 'w', tmp->tm_nonc ? "no" : "", in db_print_tmpfs()
721 tmp->tm_nomtime ? "no" : ""); in db_print_tmpfs()
737 if (strcmp(mp->mnt_stat.f_fstypename, tmpfs_vfsconf.vfc_name) == in DB_SHOW_COMMAND()