From 3bdcc4d938a4c50152559bb2c55b7395862418d0 Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Tue, 8 May 2012 05:33:56 -0700 Subject: [PATCH] kernel -- vn: Implement BUF_CMD_FLUSH for vn(ode) devices. File-backed vnode devices implement BUF_CMD_FLUSH by VOP_FSYNC-ing the backing vnode. --- sys/dev/disk/vn/vn.c | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/dev/disk/vn/vn.c b/sys/dev/disk/vn/vn.c index c0fa2a3..18e4053 100644 --- a/sys/dev/disk/vn/vn.c +++ b/sys/dev/disk/vn/vn.c @@ -341,14 +341,28 @@ vnstrategy(struct dev_strategy_args *ap) * fs backing the VN device and whatever is running on * the VN device. */ - if (bp->b_cmd == BUF_CMD_READ) { + switch (bp->b_cmd) { + case (BUF_CMD_READ): vn_lock(vn->sc_vp, LK_SHARED | LK_RETRY); error = VOP_READ(vn->sc_vp, &auio, IO_RECURSE, vn->sc_cred); - } else { + break; + + case (BUF_CMD_WRITE): vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_WRITE(vn->sc_vp, &auio, IO_RECURSE, vn->sc_cred); + break; + + case (BUF_CMD_FLUSH): + auio.uio_resid = 0; + vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY); + error = VOP_FSYNC(vn->sc_vp, MNT_WAIT, 0); + break; + default: + auio.uio_resid = 0; + error = 0; + break; } vn_unlock(vn->sc_vp); bp->b_resid = auio.uio_resid; -- 1.7.7.2