From 1ca79c111c1bd7d92d2ef792de5253b29169b0c7 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 27 Aug 2013 01:31:12 +0000 Subject: [PATCH] When allocating a pbuf for the cluster write, do not sleep waiting for the available pbuf when passed vnode is backing md(4). Other i/o directed to the same md device might already hold pbufs, and then we could deadlock since only our progress can free a pbuf needed for wakeup. Obtained from: projects/vm6 Reminded and tested by: pho MFC after: 1 week --- sys/kern/vfs_cluster.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index c98db817d93..960108253e7 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -837,7 +837,9 @@ cluster_wbuild(struct vnode *vp, long size, daddr_t start_lbn, int len, (tbp->b_bcount != tbp->b_bufsize) || (tbp->b_bcount != size) || (len == 1) || - ((bp = getpbuf(&cluster_pbuf_freecnt)) == NULL)) { + ((bp = (vp->v_vflag & VV_MD) != 0 ? + trypbuf(&cluster_pbuf_freecnt) : + getpbuf(&cluster_pbuf_freecnt)) == NULL)) { totalwritten += tbp->b_bufsize; bawrite(tbp); ++start_lbn;