Rename vfs_stdsync function to vfs_stdnosync which matches more
closely what function is really doing. Update all existing consumers to use the new name. Introduce a new vfs_stdsync function, which iterates over mount point's vnodes and call FSYNC on each one of them in turn. Make nwfs and smbfs use this new function instead of rolling their own identical sync implementations. Reviewed by: jeff
This commit is contained in:
parent
b2bb08b487
commit
378cd3b05d
@ -79,7 +79,7 @@ static struct vfsops cd9660_vfsops = {
|
||||
cd9660_root,
|
||||
vfs_stdquotactl,
|
||||
cd9660_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
cd9660_vget,
|
||||
cd9660_fhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -194,7 +194,7 @@ static struct vfsops devfs_vfsops = {
|
||||
devfs_root,
|
||||
vfs_stdquotactl,
|
||||
devfs_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
vfs_stdvget,
|
||||
vfs_stdfhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -213,7 +213,7 @@ static struct vfsops fdesc_vfsops = {
|
||||
fdesc_root,
|
||||
vfs_stdquotactl,
|
||||
fdesc_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
vfs_stdvget,
|
||||
vfs_stdfhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -577,7 +577,7 @@ static struct vfsops hpfs_vfsops = {
|
||||
hpfs_root,
|
||||
vfs_stdquotactl,
|
||||
hpfs_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
hpfs_vget,
|
||||
hpfs_fhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -781,7 +781,7 @@ static struct vfsops ntfs_vfsops = {
|
||||
ntfs_root,
|
||||
vfs_stdquotactl,
|
||||
ntfs_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
ntfs_vget,
|
||||
ntfs_fhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -76,7 +76,6 @@ static int nwfs_quotactl(struct mount *, int, uid_t, caddr_t, struct thread *);
|
||||
static int nwfs_root(struct mount *, struct vnode **);
|
||||
static int nwfs_start(struct mount *, int, struct thread *);
|
||||
static int nwfs_statfs(struct mount *, struct statfs *, struct thread *);
|
||||
static int nwfs_sync(struct mount *, int, struct ucred *, struct thread *);
|
||||
static int nwfs_unmount(struct mount *, int, struct thread *);
|
||||
static int nwfs_init(struct vfsconf *vfsp);
|
||||
static int nwfs_uninit(struct vfsconf *vfsp);
|
||||
@ -88,7 +87,7 @@ static struct vfsops nwfs_vfsops = {
|
||||
nwfs_root,
|
||||
nwfs_quotactl,
|
||||
nwfs_statfs,
|
||||
nwfs_sync,
|
||||
vfs_stdsync,
|
||||
vfs_stdvget,
|
||||
vfs_stdfhtovp, /* shouldn't happen */
|
||||
vfs_stdcheckexp,
|
||||
@ -460,53 +459,3 @@ nwfs_statfs(mp, sbp, td)
|
||||
strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush out the buffer cache
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
nwfs_sync(mp, waitfor, cred, td)
|
||||
struct mount *mp;
|
||||
int waitfor;
|
||||
struct ucred *cred;
|
||||
struct thread *td;
|
||||
{
|
||||
struct vnode *vp, *nvp;
|
||||
int error, allerror = 0;
|
||||
/*
|
||||
* Force stale buffer cache information to be flushed.
|
||||
*/
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
loop:
|
||||
for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist);
|
||||
vp != NULL;
|
||||
vp = nvp) {
|
||||
/*
|
||||
* If the vnode that we are about to sync is no longer
|
||||
* associated with this mount point, start over.
|
||||
*/
|
||||
if (vp->v_mount != mp)
|
||||
goto loop;
|
||||
nvp = TAILQ_NEXT(vp, v_nmntvnodes);
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
VI_LOCK(vp);
|
||||
if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) ||
|
||||
waitfor == MNT_LAZY) {
|
||||
VI_UNLOCK(vp);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
continue;
|
||||
}
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) {
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
goto loop;
|
||||
}
|
||||
error = VOP_FSYNC(vp, cred, waitfor, td);
|
||||
if (error)
|
||||
allerror = error;
|
||||
vput(vp);
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
}
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
return (allerror);
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ static struct vfsops portal_vfsops = {
|
||||
portal_root,
|
||||
vfs_stdquotactl,
|
||||
portal_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
vfs_stdvget,
|
||||
vfs_stdfhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -256,7 +256,7 @@ static struct vfsops name##_vfsops = { \
|
||||
pfs_root, \
|
||||
vfs_stdquotactl, \
|
||||
pfs_statfs, \
|
||||
vfs_stdsync, \
|
||||
vfs_stdnosync, \
|
||||
vfs_stdvget, \
|
||||
vfs_stdfhtovp, \
|
||||
vfs_stdcheckexp, \
|
||||
|
@ -83,7 +83,6 @@ static int smbfs_quotactl(struct mount *, int, uid_t, caddr_t, struct thread *);
|
||||
static int smbfs_root(struct mount *, struct vnode **);
|
||||
static int smbfs_start(struct mount *, int, struct thread *);
|
||||
static int smbfs_statfs(struct mount *, struct statfs *, struct thread *);
|
||||
static int smbfs_sync(struct mount *, int, struct ucred *, struct thread *);
|
||||
static int smbfs_unmount(struct mount *, int, struct thread *);
|
||||
static int smbfs_init(struct vfsconf *vfsp);
|
||||
static int smbfs_uninit(struct vfsconf *vfsp);
|
||||
@ -95,7 +94,7 @@ static struct vfsops smbfs_vfsops = {
|
||||
smbfs_root,
|
||||
smbfs_quotactl,
|
||||
smbfs_statfs,
|
||||
smbfs_sync,
|
||||
vfs_stdsync,
|
||||
vfs_stdvget,
|
||||
vfs_stdfhtovp, /* shouldn't happen */
|
||||
vfs_stdcheckexp,
|
||||
@ -401,46 +400,3 @@ smbfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
|
||||
strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush out the buffer cache
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
smbfs_sync(mp, waitfor, cred, td)
|
||||
struct mount *mp;
|
||||
int waitfor;
|
||||
struct ucred *cred;
|
||||
struct thread *td;
|
||||
{
|
||||
struct vnode *vp;
|
||||
int error, allerror = 0;
|
||||
/*
|
||||
* Force stale buffer cache information to be flushed.
|
||||
*/
|
||||
loop:
|
||||
for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist);
|
||||
vp != NULL;
|
||||
vp = TAILQ_NEXT(vp, v_nmntvnodes)) {
|
||||
/*
|
||||
* If the vnode that we are about to sync is no longer
|
||||
* associated with this mount point, start over.
|
||||
*/
|
||||
if (vp->v_mount != mp)
|
||||
goto loop;
|
||||
VI_LOCK(vp);
|
||||
if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) ||
|
||||
waitfor == MNT_LAZY) {
|
||||
VI_UNLOCK(vp);
|
||||
continue;
|
||||
}
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td))
|
||||
goto loop;
|
||||
error = VOP_FSYNC(vp, cred, waitfor, td);
|
||||
if (error)
|
||||
allerror = error;
|
||||
vput(vp);
|
||||
}
|
||||
return (allerror);
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ static struct vfsops udf_vfsops = {
|
||||
udf_root,
|
||||
vfs_stdquotactl,
|
||||
udf_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
udf_vget,
|
||||
udf_fhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -443,7 +443,7 @@ static struct vfsops umap_vfsops = {
|
||||
umapfs_root,
|
||||
umapfs_quotactl,
|
||||
umapfs_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
umapfs_vget,
|
||||
umapfs_fhtovp,
|
||||
umapfs_checkexp,
|
||||
|
@ -502,7 +502,7 @@ static struct vfsops union_vfsops = {
|
||||
union_root,
|
||||
vfs_stdquotactl,
|
||||
union_statfs,
|
||||
vfs_stdsync, /* XXX assumes no cached data on union level */
|
||||
vfs_stdnosync, /* XXX assumes no cached data on union level */
|
||||
vfs_stdvget,
|
||||
vfs_stdfhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -79,7 +79,7 @@ static struct vfsops cd9660_vfsops = {
|
||||
cd9660_root,
|
||||
vfs_stdquotactl,
|
||||
cd9660_statfs,
|
||||
vfs_stdsync,
|
||||
vfs_stdnosync,
|
||||
cd9660_vget,
|
||||
cd9660_fhtovp,
|
||||
vfs_stdcheckexp,
|
||||
|
@ -879,7 +879,62 @@ vfs_stdquotactl (mp, cmds, uid, arg, td)
|
||||
}
|
||||
|
||||
int
|
||||
vfs_stdsync (mp, waitfor, cred, td)
|
||||
vfs_stdsync(mp, waitfor, cred, td)
|
||||
struct mount *mp;
|
||||
int waitfor;
|
||||
struct ucred *cred;
|
||||
struct thread *td;
|
||||
{
|
||||
struct vnode *vp, *nvp;
|
||||
int error, lockreq, allerror = 0;
|
||||
|
||||
lockreq = LK_EXCLUSIVE | LK_INTERLOCK;
|
||||
if (waitfor != MNT_WAIT)
|
||||
lockreq |= LK_NOWAIT;
|
||||
/*
|
||||
* Force stale buffer cache information to be flushed.
|
||||
*/
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
loop:
|
||||
for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist); vp != NULL; vp = nvp) {
|
||||
/*
|
||||
* If the vnode that we are about to sync is no longer
|
||||
* associated with this mount point, start over.
|
||||
*/
|
||||
if (vp->v_mount != mp)
|
||||
goto loop;
|
||||
|
||||
nvp = TAILQ_NEXT(vp, v_nmntvnodes);
|
||||
|
||||
VI_LOCK(vp);
|
||||
if (TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
|
||||
VI_UNLOCK(vp);
|
||||
continue;
|
||||
}
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
|
||||
if ((error = vget(vp, lockreq, td)) != 0) {
|
||||
if (error == ENOENT)
|
||||
goto loop;
|
||||
continue;
|
||||
}
|
||||
error = VOP_FSYNC(vp, cred, waitfor, td);
|
||||
if (error)
|
||||
allerror = error;
|
||||
|
||||
mtx_lock(&mntvnode_mtx);
|
||||
if (nvp != TAILQ_NEXT(vp, v_nmntvnodes)) {
|
||||
vput(vp);
|
||||
goto loop;
|
||||
}
|
||||
vput(vp);
|
||||
}
|
||||
mtx_unlock(&mntvnode_mtx);
|
||||
return (allerror);
|
||||
}
|
||||
|
||||
int
|
||||
vfs_stdnosync (mp, waitfor, cred, td)
|
||||
struct mount *mp;
|
||||
int waitfor;
|
||||
struct ucred *cred;
|
||||
|
@ -499,6 +499,7 @@ vfs_root_t vfs_stdroot;
|
||||
vfs_quotactl_t vfs_stdquotactl;
|
||||
vfs_statfs_t vfs_stdstatfs;
|
||||
vfs_sync_t vfs_stdsync;
|
||||
vfs_sync_t vfs_stdnosync;
|
||||
vfs_vget_t vfs_stdvget;
|
||||
vfs_fhtovp_t vfs_stdfhtovp;
|
||||
vfs_checkexp_t vfs_stdcheckexp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user