Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148275008
D16573.1786083080.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D16573.1786083080.diff
View Options
Index: sys/kern/vfs_bio.c
===================================================================
--- sys/kern/vfs_bio.c
+++ sys/kern/vfs_bio.c
@@ -4170,6 +4170,25 @@
}
/*
+ * Return true if new buffer should be malloc'ed.
+ */
+
+static bool
+want_malloc_buf(struct buf *bp, int newbsize)
+{
+ if (bp->b_bufsize != 0)
+ return false;
+
+ if (newbsize > PAGE_SIZE / 2)
+ return false;
+
+ if (bufmallocspace >= maxbufmallocspace)
+ return false;
+
+ return true;
+}
+
+/*
* Truncate the backing store for a non-vmio buffer.
*/
static void
@@ -4211,8 +4230,7 @@
* is probably extremely rare and not worth worrying
* over.
*/
- if (bp->b_bufsize == 0 && newbsize <= PAGE_SIZE/2 &&
- bufmallocspace < maxbufmallocspace) {
+ if (want_malloc_buf(bp, newbsize)) {
bp->b_data = malloc(newbsize, M_BIOBUF, M_WAITOK);
bp->b_flags |= B_MALLOC;
bufmallocadjust(bp, newbsize);
@@ -4272,7 +4290,8 @@
newbsize = roundup2(size, DEV_BSIZE);
if ((bp->b_flags & B_VMIO) == 0) {
- if ((bp->b_flags & B_MALLOC) == 0)
+ if ((bp->b_flags & B_MALLOC) == 0 &&
+ !want_malloc_buf(bp, newbsize))
newbsize = round_page(newbsize);
/*
* Just get anonymous memory from the kernel. Don't
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Aug 7, 6:11 AM (18 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29365120
Default Alt Text
D16573.1786083080.diff (1 KB)
Attached To
Mode
D16573: Fix code preventing sufficiently small buffers from being malloc buffers.
Attached
Detach File
Event Timeline
Log In to Comment