Page MenuHomeFreeBSD

D16573.id46860.diff
No OneTemporary

D16573.id46860.diff

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

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)

Event Timeline