Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Apr 2009 09:37:48 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r191136 - head/sys/kern
Message-ID:  <200904160937.n3G9bmwb075614@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Apr 16 09:37:48 2009
New Revision: 191136
URL: http://svn.freebsd.org/changeset/base/191136

Log:
  In flushbufqueues(), do not allocate sentinel buffer on the stack,
  struct buf is large. Use sleeping malloc(9) call, and zero the allocated
  buf as a debugging feature.

Modified:
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==============================================================================
--- head/sys/kern/vfs_bio.c	Thu Apr 16 09:33:52 2009	(r191135)
+++ head/sys/kern/vfs_bio.c	Thu Apr 16 09:37:48 2009	(r191136)
@@ -2189,7 +2189,7 @@ SYSCTL_INT(_vfs, OID_AUTO, flushwithdeps
 static int
 flushbufqueues(struct vnode *lvp, int queue, int flushdeps)
 {
-	struct buf sentinel;
+	struct buf *sentinel;
 	struct vnode *vp;
 	struct mount *mp;
 	struct buf *bp;
@@ -2205,14 +2205,15 @@ flushbufqueues(struct vnode *lvp, int qu
 		target = flushbufqtarget;
 	flushed = 0;
 	bp = NULL;
-	sentinel.b_qindex = QUEUE_SENTINEL;
+	sentinel = malloc(sizeof(struct buf), M_TEMP, M_WAITOK | M_ZERO);
+	sentinel->b_qindex = QUEUE_SENTINEL;
 	mtx_lock(&bqlock);
-	TAILQ_INSERT_HEAD(&bufqueues[queue], &sentinel, b_freelist);
+	TAILQ_INSERT_HEAD(&bufqueues[queue], sentinel, b_freelist);
 	while (flushed != target) {
-		bp = TAILQ_NEXT(&sentinel, b_freelist);
+		bp = TAILQ_NEXT(sentinel, b_freelist);
 		if (bp != NULL) {
-			TAILQ_REMOVE(&bufqueues[queue], &sentinel, b_freelist);
-			TAILQ_INSERT_AFTER(&bufqueues[queue], bp, &sentinel,
+			TAILQ_REMOVE(&bufqueues[queue], sentinel, b_freelist);
+			TAILQ_INSERT_AFTER(&bufqueues[queue], bp, sentinel,
 			    b_freelist);
 		} else
 			break;
@@ -2304,8 +2305,9 @@ flushbufqueues(struct vnode *lvp, int qu
 		vn_finished_write(mp);
 		BUF_UNLOCK(bp);
 	}
-	TAILQ_REMOVE(&bufqueues[queue], &sentinel, b_freelist);
+	TAILQ_REMOVE(&bufqueues[queue], sentinel, b_freelist);
 	mtx_unlock(&bqlock);
+	free(sentinel, M_TEMP);
 	return (flushed);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904160937.n3G9bmwb075614>