From: markj Date: Thu, 1 Oct 2015 16:34:53 +0000 (+0000) Subject: Ensure that vop_stdadvise() does not call getblk() on vnodes that have an X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=49cededc7e35f14e10f5df9a819ef835b4073dfb;p=people%2Fjulieng%2Ffreebsd.git Ensure that vop_stdadvise() does not call getblk() on vnodes that have an empty bufobj. Otherwise, vnodes belonging to filesystems that do not use the buffer cache may trigger assertion failures. Reported by: Fabien Keil --- diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d0074d3e34ed..6ee094b9144b 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1077,16 +1077,15 @@ vop_stdadvise(struct vop_advise_args *ap) BO_RLOCK(&vp->v_bufobj); bsize = vp->v_bufobj.bo_bsize; startn = ap->a_start / bsize; - if (ap->a_end == OFF_MAX) { - endn = -1; - bl = &vp->v_bufobj.bo_clean.bv_hd; - if (!TAILQ_EMPTY(bl)) - endn = TAILQ_LAST(bl, buflists)->b_lblkno; - bl = &vp->v_bufobj.bo_dirty.bv_hd; - if (!TAILQ_EMPTY(bl) && - endn < TAILQ_LAST(bl, buflists)->b_lblkno) - endn = TAILQ_LAST(bl, buflists)->b_lblkno; - } else + endn = -1; + bl = &vp->v_bufobj.bo_clean.bv_hd; + if (!TAILQ_EMPTY(bl)) + endn = TAILQ_LAST(bl, buflists)->b_lblkno; + bl = &vp->v_bufobj.bo_dirty.bv_hd; + if (!TAILQ_EMPTY(bl) && + endn < TAILQ_LAST(bl, buflists)->b_lblkno) + endn = TAILQ_LAST(bl, buflists)->b_lblkno; + if (ap->a_end != OFF_MAX && endn != -1) endn = ap->a_end / bsize; BO_RUNLOCK(&vp->v_bufobj); /*