diff options
author | Mike Karels <karels@FreeBSD.org> | 2023-12-19 15:32:58 +0000 |
---|---|---|
committer | Mike Karels <karels@FreeBSD.org> | 2023-12-19 15:32:58 +0000 |
commit | ed19c0989fe77ec3c9d7bdb752bab6bbef4c0be6 (patch) | |
tree | 6cb2a250a9540ada57be9339da08ef8aff9af2c5 | |
parent | 2134b35e0f71a7cafa3602a4d362ee7ef8b65ebb (diff) | |
download | src-ed19c0989fe77ec3c9d7bdb752bab6bbef4c0be6.tar.gz src-ed19c0989fe77ec3c9d7bdb752bab6bbef4c0be6.zip |
tmpfs: enforce size limit on writes when file system size is default
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
-rw-r--r-- | sys/fs/tmpfs/tmpfs_subr.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index 2fe7f7e3ca58..e255c6488613 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -290,6 +290,8 @@ tmpfs_can_alloc_page(vm_object_t obj, vm_pindex_t pindex) if (tm == NULL || vm_pager_has_page(obj, pindex, NULL, NULL) || tm->tm_pages_max == 0) return (true); + if (tm->tm_pages_max == ULONG_MAX) + return (tmpfs_mem_avail() >= 1); return (tm->tm_pages_max > atomic_load_long(&tm->tm_pages_used)); } |