Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F141944152
D16573.id46860.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D16573.id46860.diff
View Options
Index: sys/kern/vfs_bio.c
===================================================================
--- sys/kern/vfs_bio.c
+++ sys/kern/vfs_bio.c
@@ -4170,6 +4170,23 @@
}
/*
+ * 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 +4228,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 +4288,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
Wed, Jan 14, 10:05 PM (14 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27640076
Default Alt Text
D16573.id46860.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