aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/tmpfs
Commit message (Collapse)AuthorAgeFilesLines
* tmpfs: Remove uses of DEBUG_VFS_LOCKSMark Johnston2 days1-1/+1
| | | | | | | | | This assertion can reasonably be checked when plain INVARIANTS is configured, there's no need to configure a separate option. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D51697
* pathconf: Add a new variable for hidden/systemRick Macklem2025-07-051-0/+4
| | | | | | | | | | | | | | | | | | For the NFSv4 server to implement the "hidden" and "system" attributes, it needs to know if UF_HIDDEN, UF_SYSTEM are supported for the file. This patch adds a new pathconf variable called _PC_HAS_HIDDENSYSTEM to do that. The ZFS patch will be handled separately as a OpenZFS pull request. Although this pathconf variable may be queried by applications using pathconf(2), the current interface where chflags(2) returns EOPNOTSUPP may still be used to check if the flags are set. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D51172
* tmpfs: turn vfs.tmpfs.memory_percent into CTLFLAG_RWTUNKa Ho Ng2025-04-111-1/+1
| | | | | | | | | | So sysctl is not the only way to set the value of this knob, this can be set by loader tunables as well. Sponsored by: Juniper Networks, Inc. MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D49763
* vm_page: define partial page invalidateDoug Moore2025-02-221-43/+4
| | | | | | | | | Two different functions in different files do the same thing - fill a partial page with zeroes. Add that functionality to vm_page.c and remove it elsewhere to avoid code duplication. Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D49096
* Revert "vm_page: define partial page invalidate"Doug Moore2025-02-211-4/+43
| | | | | | | A negative review arrived as this was being committed, so undo and reevaluate. This reverts commit 5611a38d818587b307e1fb110f72d2996c170035.
* vm_page: define partial page invalidateDoug Moore2025-02-211-43/+4
| | | | | | | | | Two different functions in different files do the same thing - fill a partial page with zeroes. Add that functionality to vm_page.c and remove it elsewhere to avoid code duplication. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D49096
* stat(2): add st_filerevKonstantin Belousov2025-01-161-0/+1
| | | | | | | Reviewed by: asomers, markj, olce, rmacklem Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D48452
* tmpfs: Rework file handlesOlivier Certner2024-12-233-25/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Change 'struct tmpfs_fid_data' to behave consistently with the private structure other FSes use. In a nutshell, make it a full alias of 'struct fid', instead of just using it to fill 'fid_data'. This implies adding a length field at start (aliasing 'fid_len' of 'struct fid'), and filling 'fid_len' with the full size of the aliased structure. To ensure that the new 'struct tmpfs_fid_data' is smaller than 'struct fid', which the compile-time assert introduced in commit 91b5592a1e1af974 ("fs: Add static asserts for the size of fid structures") checks (and thus was not strong enough when added), use '__packed'. A consequence of this change is that copying the 'struct tmpfs_fid_data' into a stack-allocated variable becomes unnecessary, we simply rely on the compiler emitting the proper code on seeing '__packed' (and on the start of 'struct tmpfs_fid_data' being naturally aligned, which is normally guaranteed by kernel's malloc() and/or inclusion in 'struct fhandle'). Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D47956
* fs: Add static asserts for the size of fid structuresRick Macklem2024-12-061-0/+2
| | | | | | | | | | | | | | File system specific *fid structures are copied into the generic struct fid defined in sys/mount.h. As such, they cannot be larger than struct fid. This patch adds _Static_assert()s to check for this. ZFS and fuse already have _Static_assert()s. Reviewed by: imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47936
* tmpfs_vnops: move swap work to swap_pagerDoug Moore2024-10-241-56/+4
| | | | | | | | | | Two functions in tmpfs_vnops.c use an interface provided by swap_pager.c. Move most of the implementation of those functions to swap_pager.c so that they can be implemented more effectively, with access to implementation details of the swap pager. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D47212
* tmpfs: remove duplicate flags check in tmpfs_rmdirClaudiu2024-10-131-7/+1
| | | | | | MFC after: 2 weeks Reviewed By: asomers Differential Revision: https://reviews.freebsd.org/D47100
* tmpfs: check residence in data_lockedDoug Moore2024-10-041-4/+13
| | | | | | | | | tmpfs_seek_data_locked should return the offset of the first page either resident in memory or in swap, but may return an offset to a nonresident page. Check for residence to fix that. Reviewed by: alc, kib Differential Revision: https://reviews.freebsd.org/D46879
* tmpfs: Account for whiteouts during rename/rmdirJason A. Harmening2024-09-083-14/+88
| | | | | | | | | | | | | | | | | | | | | | The existing tmpfs implementation will return ENOTEMPTY for VOP_RMDIR, or for the destination directory of VOP_RENAME, for any case in which the directory is non-empty, even if the directory only contains whiteouts. Fix this by tracking total whiteout dirent allocation separately for each directory, and avoid returning ENOTEMPTY if IGNOREWHITEOUT has been specified by the caller and the total allocation of dirents is not greater than the total whiteout allocation. This addresses "directory not empty" failures seen on some recently-added unionfs stress2 tests which use tmpfs as a base-layer filesystem. A separate issue for independent consideration is that unionfs' default behavior when deleting files or directories is to create whiteouts even when it does not truly need to do so. Differential Revision: https://reviews.freebsd.org/D45987 Reviewed by: kib (prior version), olce Tested by: pho
* tmpfs: Fix OOB write when setting vfs.tmpfs.memory_percentJessica Clarke2024-08-151-1/+1
| | | | | | | | | tmpfs_mem_percent is an int not a long, so on a 64-bit system this writes 4 bytes past the end of the variable. The read above is correct, so this was likely a copy paste error from sysctl_mem_reserved. Found by: CHERI Fixes: 636592343c3e ("tmpfs: increase memory reserve to a percent of available memory + swap")
* vm: Remove kernel stack swapping support, part 3Mark Johnston2024-07-291-1/+1
| | | | | | | | | | | - Modify PHOLD() to no longer fault in the process. - Remove _PHOLD_LITE(), which is now the same as _PHOLD(), fix up consumers. - Remove faultin() and its callees. Tested by: pho Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D46114
* tmpfs_node_init: use MTX_NEW on lock from uninitialized memoryRyan Libby2024-05-261-1/+1
| | | | | | Reported by: netchild Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D45364
* tmpfs_destroy_vobject(): clear v_object under the object lockKonstantin Belousov2024-05-131-1/+3
| | | | | | | | | | | | | Which allows tmpfs_pager_writecount_recalc() to reliably detect reclaimed vnode and make its accesses to object->un_pager.swp.private (== vp) safe against reclaim. Note that vnode instantiation already assigns v_object under the object lock. Reviewed by: markj Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D45119
* swap-like pagers: assert that writemapping decrease does not pass zeroKonstantin Belousov2024-05-131-0/+3
| | | | | | | | Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D45119
* tmpfs: recalculate OBJ_TMPFS_VREF on reinstantiating node' vnodeKonstantin Belousov2024-05-131-3/+7
| | | | | | | | Reported and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D45119
* Reduce reliance on sys/sysproto.h pollutionBrooks Davis2024-04-151-0/+1
| | | | | | | | | | | Add sys/errno.h, sys/malloc.h, sys/queue.h, and vm/uma.h as needed. sys/sysproto.h currently includes sys/acl.h which currently includes sys/param.h, sys/queue.h, and vm/uma.h which in turn bring in sys/errno.h sys/malloc.h. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44465
* tmpfs: increase vfs.tmpfs.memory_percent to 100 as workaroundMike Karels2024-01-231-1/+1
| | | | | | | | | | The changes to avoid letting tmpfs use all of memory + swap do not work well with ZFS ARC. The ARC can grow quite large, and will shrink when there is memory pressure, but tmpfs does not allow for that. Pending investigation of the right way to handle this, change the default value of the vfs.tmpfs.memory_percent sysctl to 100 as a workaround. The sysctl can be set to 95 to get back to the previous default.
* tmpfs: increase memory reserve to a percent of available memory + swapMike Karels2023-12-192-1/+47
| | | | | | | | | | | | | | | | | | | | | | | | The tmpfs memory reserve defaulted to 4 MB, and other than that, all of available memory + swap could be allocated to tmpfs files. This was dangerous, as the page daemon attempts to keep some memory free, using up swap, and then resulting in processes being killed. Increase the reserve to a fraction of available memory + swap at file system startup time. The limit is expressed as a percentage of available memory + swap that can be used, and defaults to 95%. The percentage can be changed via the vfs.tmpfs.memory_percent sysctl, recomputing the reserve with the new percentage but the initial available memory + swap. Note that the reserve can also be set directly with an existing sysctl, ignoring the percentage. The previous behavior can be specified by setting vfs.tmpfs.memory_percent to 100. Add sysctl for vfs.tmpfs.memory_percent and the pre-existing vfs.tmpfs.memory_reserved to tmpfs(5). PR: 275436 MFC after: 1 month Reviewed by: rgrimes Differential Revision: https://reviews.freebsd.org/D43011
* tmpfs: enforce size limit on writes when file system size is defaultMike Karels2023-12-191-0/+2
| | | | | | | | | | | | | | tmpfs enforced the file system size limit on writes for file systems with a specified size, but not when the size was the default. Add enforcement when the size is default: do not allocate additional pages if the available memory + swap falls to the reserve level. Note, enforcement is also done when attempting to create a file, both with and without an explicit file system size. PR: 275436 MFC after: 1 month Reviewed by: cy Differential Revision: https://reviews.freebsd.org/D43010
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-273-3/+2
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-163-6/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^#include\s+<sys/cdefs.h>.*$\n\s+__FBSDID\("\$FreeBSD\$"\);\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-163-6/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* tmpfs: add the "pgread" mount option to the allowed options list for mountKonstantin Belousov2023-08-111-1/+1
| | | | | | Fixes: 0f613ab85e5a5274704d179f39fb15163d46e7c4 Sponsored by: The FreeBSD Foundation MFC after: 1 week
* tmpfs: add a knob to enable pgcache read for mountKonstantin Belousov2023-08-093-2/+8
| | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41334
* vfs: use __enum_uint8 for vtype and vstateMateusz Guzik2023-07-052-3/+3
| | | | | | This whacks hackery around only reading v_type once. Bump __FreeBSD_version to 1400093
* spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSDWarner Losh2023-05-127-7/+7
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* tmpfs: add missing vop_fplookup ops to tmpfs_fifoop_entriesMateusz Guzik2023-04-181-0/+2
| | | | | Reported by: gbe PR: 270917
* tmpfs: support the nosymfollow mount optionKonstantin Belousov2023-02-231-2/+2
| | | | | | | PR: 269772 Reported by: firk@cantconnect.ru Sponsored by: The FreeBSD Foundation MFC after: 1 week
* tmpfs: remove IFF macroKonstantin Belousov2023-02-152-3/+2
| | | | | | | | Requested by: mjg Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38576
* tmpfs: remove bogus MPASS(VOP_ISLOCKED(vp)) assertsKonstantin Belousov2023-02-152-17/+10
| | | | | | | | | | | | | | | VOP_ISLOCKED() does not return bool, its only reliable use it to check that the vnode is exclusively locked by the calling thread. Almost all asserts of this form repeated auto-generated assertions from vnode_if.src for VOPs, in the incorrect way. In two places where the assertions would be meaningful, convert them to ASSERT_VOP_LOCKED() statements. Reviewed by: markj, mjg Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38576
* tmpfs_rename(): use tmpfs_access_locked instead of VOP_ACCESS()Konstantin Belousov2023-02-131-1/+4
| | | | | | | | | | | | | | | | | Protect the call with the node lock. We cannot lock the fvp vnode sleepable there, because we already own other participating vnode's locks. Taking it without sleeping require unwinding the whole locking state in one more place. Note that the liveness of the node is guaranteed by the lock on the parent directory vnode. Reported and tested by: pho Fixes: cbac1f3464956185cf95955344b6009e2cc3ae40ESC Reviewed by: markj, mjg Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38557
* Extract tmpfs-specific part of tmpfs_access() into a helperKonstantin Belousov2023-02-131-17/+21
| | | | | | | | | | | The helper tmpfs_access_locked() requires either the vnode or node locked for consistency of the access check, unlike the pure vnode op. Reviewed by: markj, mjg Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38557
* tmpfs_access(): style fixes and remove redundand assertionsKonstantin Belousov2023-02-131-12/+8
| | | | | | | | | | Note that MPASS(VOP_ISLOCKED(vp)) is simply broken. Reviewed by: markj, mjg Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38557
* Fix pjfstest issue tests/rename/09.tFedor Uporov2023-02-111-0/+7
| | | | | | | | | Fix rename when renamed directory not owned by user, but when user owns the sticky parent directory. Reviewed by: kib MFC after: 2 week Differential revision: https://reviews.freebsd.org/D38245
* Add extended attributesFedor Uporov2023-01-294-7/+271
| | | | | | | | | | | | | | | | | | | The extattrs follows semantic of ufs, mean it cannot be set to char/block devices and fifos. The attributes are allocated using regular malloc with M_WAITOK allocation with the own malloc tag M_TMPFSEA. The memory consumed by extended attributes is limited to avoid OOM triggereing by tmpfs_mount variable tm_ea_memory_max, which is set initialy to 16 MB. The extended attributes entries are stored as linked list in the tmpfs node. The mount point lock is required only under setextattr and deleteextattr to update extended attributes memory-inuse counter, all other operations are doing under vnode lock. Reviewed by: kib MFC after: 2 week Differential revision: https://reviews.freebsd.org/D38052
* Fix pjfstest issue tests/rename/23.tFedor Uporov2023-01-291-0/+4
| | | | | | | | | | | | | | This test creates two files like file0 and file1, then creates link to file1 and checks ctime on it. Then renames file0 to file1. Then checks ctime on link again. It is expected, that second ctime will be higher then first ctime, because rename happen. Add ctime updating for directory entry, which will be deleted on rename. Reviewed by: kib MFC after: 2 week Differential revision: https://reviews.freebsd.org/D38051
* Fix pjfstest issue tests/rename/19.tFedor Uporov2023-01-291-2/+10
| | | | | | | | | | | | The rename call with args like: "./dir0/dir1/.." "./dir2" will cause MPASS failure. The tmpfs_dir_lookup() does not accept names like '.' and '..' for lookup. Move the '.' and '..' entry check before tmpfs_dir_lookup() call. Reviewed by: kib MFC after: 2 week Differential revision: https://reviews.freebsd.org/D38051
* Stop cleaning MNT_LOCAL on unmountKonstantin Belousov2023-01-141-4/+0
| | | | | | | | | | There is no point in clearing just this flag. Flags are reset on the struct mount re-allocation for reuse anyway. Reviewed by: mckusick Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37966
* vfs: add the concept of vnode state transitionsMateusz Guzik2022-12-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | To quote from a comment above vput_final: <quote> * XXX Some filesystems pass in an exclusively locked vnode and strongly depend * on the lock being held all the way until VOP_INACTIVE. This in particular * happens with UFS which adds half-constructed vnodes to the hash, where they * can be found by other code. </quote> As is there is no mechanism which allows filesystems to denote that a vnode is fully initialized, consequently problems like the above are only found the hard way(tm). Add rudimentary support for state transitions, which in particular allow to assert the vnode is not legally unlocked until its fate is decided (either construction finishes or vgone is called to abort it). The new field lands in a 1-byte hole, thus it does not grow the struct. Bump __FreeBSD_version to 1400077 Reviewed by: kib (previous version) Tested by: pho Differential Revision: https://reviews.freebsd.org/D37759
* tmpfs: update changed/modified timestamps for truncates that do not change sizeKonstantin Belousov2022-12-241-16/+6
| | | | | | | | | | | | While there, move all error checks into the common place at the start, and eliminate the 'out' label. PR: 268528 Analyzed and tested by: Mark Millard <marklmi@yahoo.com> Reviewed by: mckusick Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37866
* tmpfs_getattr(): Only take vm_object lock on 32bit machinesKonstantin Belousov2022-12-171-2/+6
| | | | | | | | | | Torn reads are only possible for 32bit arches. Requested by: mjg Reviewed by: mjg, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37725
* tmpfs: for used pages, account really allocated pages, instead of file sizesKonstantin Belousov2022-12-094-16/+143
| | | | | | | | | | | | | This makes tmpfs size accounting correct for the sparce files. Also correct report st_blocks/va_bytes. Previously the reported value did not accounted for the swapped out pages. PR: 223015 Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37097
* tmpfs: make vm_object point to the tmpfs node instead of vnodeKonstantin Belousov2022-12-093-18/+26
| | | | | | | | | | | | | | | | | | | The vnode could be reclaimed and allocated again during the lifecycle of the node, but the node cannot. Also, referencing the node would allow to reach it and tmpfs mount data from the object, regardless of the state of the possibly absent vnode. Still use swp_tmpfs for back-pointer, instead of using handle. Use of named swap objects would incur taking the sw_alloc_sx on node allocation and deallocation. swp_tmpfs is renamed to swp_priv to remove the last bit of tmpfs in vm/. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37097
* Add 'show tmpfs' ddb commandKonstantin Belousov2022-12-091-0/+42
| | | | | | | | Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37097
* tmpfs: minor styleKonstantin Belousov2022-12-091-3/+5
| | | | | | | | Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37097