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
This commit is contained in:
Mike Karels
2023-12-19 09:32:58 -06:00
parent 2134b35e0f
commit ed19c0989f
+2
View File
@@ -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));
}