For SU mounts, softdep_fsync() might drop vnode lock, allowing other

threads to put dirty buffers on the vnode bufobj list. For regular files
and synchronous fsync requests, check for the condition and restart the
fsync vop if a new dirty buffer arrived.

Tested by:	pho
Approved by:	re (kensmith)
MFC after:	1 month
This commit is contained in:
Konstantin Belousov 2009-06-30 10:07:33 +00:00
parent a50d1b2a66
commit cfba50c070

View File

@ -180,15 +180,36 @@ struct vop_vector ffs_fifoops2 = {
static int
ffs_fsync(struct vop_fsync_args *ap)
{
struct vnode *vp;
struct bufobj *bo;
int error;
error = ffs_syncvnode(ap->a_vp, ap->a_waitfor);
vp = ap->a_vp;
bo = &vp->v_bufobj;
retry:
error = ffs_syncvnode(vp, ap->a_waitfor);
if (error)
return (error);
if (ap->a_waitfor == MNT_WAIT &&
(ap->a_vp->v_mount->mnt_flag & MNT_SOFTDEP))
error = softdep_fsync(ap->a_vp);
return (error);
(vp->v_mount->mnt_flag & MNT_SOFTDEP)) {
error = softdep_fsync(vp);
if (error)
return (error);
/*
* The softdep_fsync() function may drop vp lock,
* allowing for dirty buffers to reappear on the
* bo_dirty list. Recheck and resync as needed.
*/
BO_LOCK(bo);
if (vp->v_type == VREG && (bo->bo_numoutput > 0 ||
bo->bo_dirty.bv_cnt > 0)) {
BO_UNLOCK(bo);
goto retry;
}
BO_UNLOCK(bo);
}
return (0);
}
int