FreeBSD Bugzilla – Attachment 246673 Details for
Bug 275436
tmpfs does not honor memory limits on writes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
sample patch that works around the problem
tmpfs.mem.patch (text/plain), 1.50 KB, created by
Mike Karels
on 2023-11-29 19:19:02 UTC
(
hide
)
Description:
sample patch that works around the problem
Filename:
MIME Type:
Creator:
Mike Karels
Created:
2023-11-29 19:19:02 UTC
Size:
1.50 KB
patch
obsolete
>diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c >index 2fe7f7e3ca58..ef496a16bd7b 100644 >--- a/sys/fs/tmpfs/tmpfs_subr.c >+++ b/sys/fs/tmpfs/tmpfs_subr.c >@@ -413,7 +413,7 @@ tmpfs_mem_avail(void) > size_t avail; > long reserved; > >- avail = swap_pager_avail + vm_free_count(); >+ avail = swap_pager_avail / 2 + vm_free_avail(); > reserved = atomic_load_long(&tmpfs_pages_reserved); > if (__predict_false(avail < reserved)) > return (0); >@@ -1862,6 +1862,12 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr) > if (newpages < oldpages) > vm_object_page_remove(uobj, newpages, 0, 0); > } >+ if (newpages > oldpages) { >+ if (tmpfs_mem_avail() < newpages - oldpages) { >+ VM_OBJECT_WUNLOCK(uobj); >+ return (ENOSPC); >+ } >+ } > uobj->size = newpages; > VM_OBJECT_WUNLOCK(uobj); > >diff --git a/sys/sys/vmmeter.h b/sys/sys/vmmeter.h >index 36321be22205..fb298bf4bac1 100644 >--- a/sys/sys/vmmeter.h >+++ b/sys/sys/vmmeter.h >@@ -166,6 +166,7 @@ vm_wire_sub(int cnt) > VM_CNT_ADD(v_wire_count, -cnt); > } > >+u_int vm_free_avail(void); > u_int vm_free_count(void); > static inline u_int > vm_wire_count(void) >diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c >index d255f8e8f358..a00ce2ee04e5 100644 >--- a/sys/vm/vm_meter.c >+++ b/sys/vm/vm_meter.c >@@ -424,6 +424,16 @@ vm_free_count(void) > return (v); > } > >+u_int >+vm_free_avail(void) >+{ >+ u_int free = vm_free_count(); >+ >+ if (free <= vm_cnt.v_free_target) >+ return (0); >+ return (free - vm_cnt.v_free_target); >+} >+ > static u_int > vm_pagequeue_count(int pq) > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 275436
:
246673
|
246718
|
246880