From f5bbefdb21d46e15b6b0d55ffe7a9bf6646a36c3 Mon Sep 17 00:00:00 2001 From: joerg Date: Mon, 1 Dec 2008 11:22:12 +0000 Subject: [PATCH] Check that the filesystem acutally uses WAPBL before initiating a transaction for the directio case. Fixes PR 39929 and similiar issues seen with PostgreSQL. --- sys/miscfs/genfs/genfs_io.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/miscfs/genfs/genfs_io.c b/sys/miscfs/genfs/genfs_io.c index 2a07e5ef768d..761f41653f02 100644 --- a/sys/miscfs/genfs/genfs_io.c +++ b/sys/miscfs/genfs/genfs_io.c @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.15 2008/11/16 19:34:29 pooka Exp $ */ +/* $NetBSD: genfs_io.c,v 1.16 2008/12/01 11:22:12 joerg Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.15 2008/11/16 19:34:29 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.16 2008/12/01 11:22:12 joerg Exp $"); #include #include @@ -1560,6 +1560,8 @@ genfs_directio(struct vnode *vp, struct uio *uio, int ioflag) size_t len; const int mask = DEV_BSIZE - 1; int error; + bool need_wapbl = (vp->v_mount && vp->v_mount->mnt_wapbl && + (ioflag & IO_JOURNALLOCKED) == 0); /* * We only support direct I/O to user space for now. @@ -1581,7 +1583,7 @@ genfs_directio(struct vnode *vp, struct uio *uio, int ioflag) return; } - if ((ioflag & IO_JOURNALLOCKED) == 0) { + if (need_wapbl) { error = WAPBL_BEGIN(vp->v_mount); if (error) return; @@ -1633,7 +1635,7 @@ genfs_directio(struct vnode *vp, struct uio *uio, int ioflag) uio->uio_resid -= len; } - if ((ioflag & IO_JOURNALLOCKED) == 0) + if (need_wapbl) WAPBL_END(vp->v_mount); }