Date: Tue, 30 Jun 2009 10:07:33 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r195187 - head/sys/ufs/ffs Message-ID: <200906301007.n5UA7XKl074900@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Tue Jun 30 10:07:33 2009 New Revision: 195187 URL: http://svn.freebsd.org/changeset/base/195187 Log: 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 Modified: head/sys/ufs/ffs/ffs_vnops.c Modified: head/sys/ufs/ffs/ffs_vnops.c ============================================================================== --- head/sys/ufs/ffs/ffs_vnops.c Tue Jun 30 10:07:00 2009 (r195186) +++ head/sys/ufs/ffs/ffs_vnops.c Tue Jun 30 10:07:33 2009 (r195187) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906301007.n5UA7XKl074900>