summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2003-03-11 22:15:10 +0000
committerkan <kan@FreeBSD.org>2003-03-11 22:15:10 +0000
commit378cd3b05d24e35b8f882e3eff724bb1ad5459f7 (patch)
treeefabc12de7b77fafe029a678e61151926f8cec1c
parentb2bb08b487890b3c3ed6adca7372f3d742354a76 (diff)
downloadFreeBSD-src-378cd3b05d24e35b8f882e3eff724bb1ad5459f7.zip
FreeBSD-src-378cd3b05d24e35b8f882e3eff724bb1ad5459f7.tar.gz
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
-rw-r--r--sys/fs/cd9660/cd9660_vfsops.c2
-rw-r--r--sys/fs/devfs/devfs_vfsops.c2
-rw-r--r--sys/fs/fdescfs/fdesc_vfsops.c2
-rw-r--r--sys/fs/hpfs/hpfs_vfsops.c2
-rw-r--r--sys/fs/ntfs/ntfs_vfsops.c2
-rw-r--r--sys/fs/nwfs/nwfs_vfsops.c53
-rw-r--r--sys/fs/portalfs/portal_vfsops.c2
-rw-r--r--sys/fs/pseudofs/pseudofs.h2
-rw-r--r--sys/fs/smbfs/smbfs_vfsops.c46
-rw-r--r--sys/fs/udf/udf_vfsops.c2
-rw-r--r--sys/fs/umapfs/umap_vfsops.c2
-rw-r--r--sys/fs/unionfs/union_vfsops.c2
-rw-r--r--sys/isofs/cd9660/cd9660_vfsops.c2
-rw-r--r--sys/kern/vfs_default.c57
-rw-r--r--sys/sys/mount.h1
15 files changed, 70 insertions, 109 deletions
diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c
index a44df4c..b5aff73 100644
--- a/sys/fs/cd9660/cd9660_vfsops.c
+++ b/sys/fs/cd9660/cd9660_vfsops.c
@@ -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,
diff --git a/sys/fs/devfs/devfs_vfsops.c b/sys/fs/devfs/devfs_vfsops.c
index 64d4cde..c1af1cd 100644
--- a/sys/fs/devfs/devfs_vfsops.c
+++ b/sys/fs/devfs/devfs_vfsops.c
@@ -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,
diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c
index a4741bc..fbe73d9 100644
--- a/sys/fs/fdescfs/fdesc_vfsops.c
+++ b/sys/fs/fdescfs/fdesc_vfsops.c
@@ -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,
diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c
index 1242e84..225f340 100644
--- a/sys/fs/hpfs/hpfs_vfsops.c
+++ b/sys/fs/hpfs/hpfs_vfsops.c
@@ -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,
diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c
index 1e267a9..2506b28 100644
--- a/sys/fs/ntfs/ntfs_vfsops.c
+++ b/sys/fs/ntfs/ntfs_vfsops.c
@@ -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,
diff --git a/sys/fs/nwfs/nwfs_vfsops.c b/sys/fs/nwfs/nwfs_vfsops.c
index f097b3e..868bcec 100644
--- a/sys/fs/nwfs/nwfs_vfsops.c
+++ b/sys/fs/nwfs/nwfs_vfsops.c
@@ -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);
-}
diff --git a/sys/fs/portalfs/portal_vfsops.c b/sys/fs/portalfs/portal_vfsops.c
index 66e516d..f731dc0 100644
--- a/sys/fs/portalfs/portal_vfsops.c
+++ b/sys/fs/portalfs/portal_vfsops.c
@@ -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,
diff --git a/sys/fs/pseudofs/pseudofs.h b/sys/fs/pseudofs/pseudofs.h
index e09f25d..3c9b34a 100644
--- a/sys/fs/pseudofs/pseudofs.h
+++ b/sys/fs/pseudofs/pseudofs.h
@@ -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, \
diff --git a/sys/fs/smbfs/smbfs_vfsops.c b/sys/fs/smbfs/smbfs_vfsops.c
index b1d1c68..17ce21d 100644
--- a/sys/fs/smbfs/smbfs_vfsops.c
+++ b/sys/fs/smbfs/smbfs_vfsops.c
@@ -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);
-}
-
diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c
index b41b86b..fed899e 100644
--- a/sys/fs/udf/udf_vfsops.c
+++ b/sys/fs/udf/udf_vfsops.c
@@ -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,
diff --git a/sys/fs/umapfs/umap_vfsops.c b/sys/fs/umapfs/umap_vfsops.c
index c1ed751..17bee46 100644
--- a/sys/fs/umapfs/umap_vfsops.c
+++ b/sys/fs/umapfs/umap_vfsops.c
@@ -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,
diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c
index 637b350..0da935e 100644
--- a/sys/fs/unionfs/union_vfsops.c
+++ b/sys/fs/unionfs/union_vfsops.c
@@ -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,
diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c
index a44df4c..b5aff73 100644
--- a/sys/isofs/cd9660/cd9660_vfsops.c
+++ b/sys/isofs/cd9660/cd9660_vfsops.c
@@ -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,
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index 10d1154..1921abf 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -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;
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index 7c4a935..0d834e7 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -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;
OpenPOWER on IntegriCloud