version 1.55, 2007/12/08 19:29:43 |
version 1.56, 2008/01/02 11:48:41 |
Line 937 msdosfs_sync(mp, waitfor, cred) |
|
Line 937 msdosfs_sync(mp, waitfor, cred) |
|
int waitfor; |
int waitfor; |
kauth_cred_t cred; |
kauth_cred_t cred; |
{ |
{ |
struct vnode *vp, *nvp; |
struct vnode *vp, *mvp; |
struct denode *dep; |
struct denode *dep; |
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); |
struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); |
int error, allerror = 0; |
int error, allerror = 0; |
Line 953 msdosfs_sync(mp, waitfor, cred) |
|
Line 953 msdosfs_sync(mp, waitfor, cred) |
|
/* update fats here */ |
/* update fats here */ |
} |
} |
} |
} |
|
/* Allocate a marker vnode. */ |
|
if ((mvp = valloc(mp)) == NULL) |
|
return ENOMEM; |
/* |
/* |
* Write back each (modified) denode. |
* Write back each (modified) denode. |
*/ |
*/ |
simple_lock(&mntvnode_slock); |
mutex_enter(&mntvnode_lock); |
loop: |
loop: |
for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) { |
for (vp = TAILQ_FIRST(&mp->mnt_vnodelist); vp; vp = vunmark(mvp)) { |
/* |
vmark(mvp, vp); |
* If the vnode that we are about to sync is no longer |
if (vp->v_mount != mp || vismarker(vp)) |
* associated with this mount point, start over. |
continue; |
*/ |
mutex_enter(&vp->v_interlock); |
if (vp->v_mount != mp) |
|
goto loop; |
|
simple_lock(&vp->v_interlock); |
|
nvp = TAILQ_NEXT(vp, v_mntvnodes); |
|
dep = VTODE(vp); |
dep = VTODE(vp); |
if (waitfor == MNT_LAZY || vp->v_type == VNON || |
if (waitfor == MNT_LAZY || vp->v_type == VNON || |
(((dep->de_flag & |
(((dep->de_flag & |
(DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0) && |
(DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0) && |
(LIST_EMPTY(&vp->v_dirtyblkhd) && |
(LIST_EMPTY(&vp->v_dirtyblkhd) && |
UVM_OBJ_IS_CLEAN(&vp->v_uobj)))) { |
UVM_OBJ_IS_CLEAN(&vp->v_uobj)))) { |
simple_unlock(&vp->v_interlock); |
mutex_exit(&vp->v_interlock); |
continue; |
continue; |
} |
} |
simple_unlock(&mntvnode_slock); |
mutex_exit(&mntvnode_lock); |
error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK); |
error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK); |
if (error) { |
if (error) { |
simple_lock(&mntvnode_slock); |
mutex_enter(&mntvnode_lock); |
if (error == ENOENT) |
if (error == ENOENT) { |
|
(void)vunmark(mvp); |
goto loop; |
goto loop; |
|
} |
continue; |
continue; |
} |
} |
if ((error = VOP_FSYNC(vp, cred, |
if ((error = VOP_FSYNC(vp, cred, |
waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0) |
waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0) |
allerror = error; |
allerror = error; |
vput(vp); |
vput(vp); |
simple_lock(&mntvnode_slock); |
mutex_enter(&mntvnode_lock); |
} |
} |
simple_unlock(&mntvnode_slock); |
mutex_exit(&mntvnode_lock); |
|
vfree(mvp); |
|
|
/* |
/* |
* Force stale file system control information to be flushed. |
* Force stale file system control information to be flushed. |
*/ |
*/ |