From 8df6bac4c74fad8167cbb05a2a358a36b1ce6f78 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 11 Jan 2005 07:36:22 +0000 Subject: [PATCH] Remove the unused credential argument from VOP_FSYNC() and VFS_SYNC(). I'm not sure why a credential was added to these in the first place, it is not used anywhere and it doesn't make much sense: The credentials for syncing a file (ability to write to the file) should be checked at the system call level. Credentials for syncing one or more filesystems ("none") should be checked at the system call level as well. If the filesystem implementation needs a particular credential to carry out the syncing it would logically have to the cached mount credential, or a credential cached along with any delayed write data. Discussed with: rwatson --- sys/coda/coda_venus.c | 5 ++--- sys/coda/coda_venus.h | 3 +-- sys/coda/coda_vfsops.c | 3 +-- sys/coda/coda_vnops.c | 5 ++--- sys/fs/coda/coda_venus.c | 5 ++--- sys/fs/coda/coda_venus.h | 3 +-- sys/fs/coda/coda_vfsops.c | 3 +-- sys/fs/coda/coda_vnops.c | 5 ++--- sys/fs/msdosfs/msdosfs_vfsops.c | 9 ++++----- sys/fs/nullfs/null_vfsops.c | 3 +-- sys/fs/unionfs/union_vnops.c | 2 +- sys/gnu/ext2fs/ext2_vfsops.c | 9 ++++----- sys/gnu/fs/ext2fs/ext2_vfsops.c | 9 ++++----- sys/kern/vfs_bio.c | 2 +- sys/kern/vfs_default.c | 8 +++----- sys/kern/vfs_extattr.c | 5 ++--- sys/kern/vfs_mount.c | 2 +- sys/kern/vfs_subr.c | 6 +++--- sys/kern/vfs_syscalls.c | 5 ++--- sys/kern/vfs_vnops.c | 2 +- sys/kern/vnode_if.src | 1 - sys/nfs4client/nfs4_vfsops.c | 4 ++-- sys/nfs4client/nfs4_vnops.c | 12 ++++++------ sys/nfsclient/nfs_vfsops.c | 4 ++-- sys/nfsclient/nfs_vnops.c | 14 +++++++------- sys/nfsserver/nfs_serv.c | 2 +- sys/sys/mount.h | 5 ++--- sys/ufs/ffs/ffs_balloc.c | 8 ++++---- sys/ufs/ffs/ffs_inode.c | 6 +++--- sys/ufs/ffs/ffs_rawread.c | 2 +- sys/ufs/ffs/ffs_snapshot.c | 18 +++++++++--------- sys/ufs/ffs/ffs_softdep.c | 14 +++++++------- sys/ufs/ffs/ffs_vfsops.c | 12 +++++------- sys/ufs/ufs/ufs_lookup.c | 2 +- sys/vm/vm_object.c | 2 +- 35 files changed, 90 insertions(+), 110 deletions(-) diff --git a/sys/coda/coda_venus.c b/sys/coda/coda_venus.c index a222e7deaead..5982367625e4 100644 --- a/sys/coda/coda_venus.c +++ b/sys/coda/coda_venus.c @@ -395,14 +395,13 @@ venus_readlink(void *mdp, CodaFid *fid, } int -venus_fsync(void *mdp, CodaFid *fid, - struct ucred *cred, struct proc *p) +venus_fsync(void *mdp, CodaFid *fid, struct proc *p) { DECL_NO_OUT(coda_fsync); /* sets Isize & Osize */ ALLOC_NO_OUT(coda_fsync); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_FSYNC, cred, p); + INIT_IN(&inp->ih, CODA_FSYNC, NOCRED, p); /* XXX: should be cached mount cred */ inp->Fid = *fid; error = coda_call(mdp, Isize, &Osize, (char *)inp); diff --git a/sys/coda/coda_venus.h b/sys/coda/coda_venus.h index 533ddcbf2b3e..1d1e0cfd39b5 100644 --- a/sys/coda/coda_venus.h +++ b/sys/coda/coda_venus.h @@ -75,8 +75,7 @@ venus_readlink(void *mdp, CodaFid *fid, /*out*/ char **str, int *len); int -venus_fsync(void *mdp, CodaFid *fid, - struct ucred *cred, struct proc *p); +venus_fsync(void *mdp, CodaFid *fid, struct proc *p); int venus_lookup(void *mdp, CodaFid *fid, diff --git a/sys/coda/coda_vfsops.c b/sys/coda/coda_vfsops.c index 103946bb6f4e..5e7c2508eb55 100644 --- a/sys/coda/coda_vfsops.c +++ b/sys/coda/coda_vfsops.c @@ -419,10 +419,9 @@ coda_nb_statfs(vfsp, sbp, td) * Flush any pending I/O. */ int -coda_sync(vfsp, waitfor, cred, td) +coda_sync(vfsp, waitfor, td) struct mount *vfsp; int waitfor; - struct ucred *cred; struct thread *td; { ENTRY; diff --git a/sys/coda/coda_vnops.c b/sys/coda/coda_vnops.c index c204ef6329f6..71b69763d23c 100644 --- a/sys/coda/coda_vnops.c +++ b/sys/coda/coda_vnops.c @@ -763,7 +763,6 @@ coda_fsync(struct vop_fsync_args *ap) /* true args */ struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); - struct ucred *cred = ap->a_cred; struct thread *td = ap->a_td; /* locals */ struct vnode *convp = cp->c_ovp; @@ -787,7 +786,7 @@ coda_fsync(struct vop_fsync_args *ap) } if (convp) - VOP_FSYNC(convp, cred, MNT_WAIT, td); + VOP_FSYNC(convp, MNT_WAIT, td); /* * We see fsyncs with usecount == 1 then usecount == 0. @@ -815,7 +814,7 @@ coda_fsync(struct vop_fsync_args *ap) /* needs research */ return 0; - error = venus_fsync(vtomi(vp), &cp->c_fid, cred, td->td_proc); + error = venus_fsync(vtomi(vp), &cp->c_fid, td->td_proc); CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); ); return(error); diff --git a/sys/fs/coda/coda_venus.c b/sys/fs/coda/coda_venus.c index a222e7deaead..5982367625e4 100644 --- a/sys/fs/coda/coda_venus.c +++ b/sys/fs/coda/coda_venus.c @@ -395,14 +395,13 @@ venus_readlink(void *mdp, CodaFid *fid, } int -venus_fsync(void *mdp, CodaFid *fid, - struct ucred *cred, struct proc *p) +venus_fsync(void *mdp, CodaFid *fid, struct proc *p) { DECL_NO_OUT(coda_fsync); /* sets Isize & Osize */ ALLOC_NO_OUT(coda_fsync); /* sets inp & outp */ /* send the open to venus. */ - INIT_IN(&inp->ih, CODA_FSYNC, cred, p); + INIT_IN(&inp->ih, CODA_FSYNC, NOCRED, p); /* XXX: should be cached mount cred */ inp->Fid = *fid; error = coda_call(mdp, Isize, &Osize, (char *)inp); diff --git a/sys/fs/coda/coda_venus.h b/sys/fs/coda/coda_venus.h index 533ddcbf2b3e..1d1e0cfd39b5 100644 --- a/sys/fs/coda/coda_venus.h +++ b/sys/fs/coda/coda_venus.h @@ -75,8 +75,7 @@ venus_readlink(void *mdp, CodaFid *fid, /*out*/ char **str, int *len); int -venus_fsync(void *mdp, CodaFid *fid, - struct ucred *cred, struct proc *p); +venus_fsync(void *mdp, CodaFid *fid, struct proc *p); int venus_lookup(void *mdp, CodaFid *fid, diff --git a/sys/fs/coda/coda_vfsops.c b/sys/fs/coda/coda_vfsops.c index 103946bb6f4e..5e7c2508eb55 100644 --- a/sys/fs/coda/coda_vfsops.c +++ b/sys/fs/coda/coda_vfsops.c @@ -419,10 +419,9 @@ coda_nb_statfs(vfsp, sbp, td) * Flush any pending I/O. */ int -coda_sync(vfsp, waitfor, cred, td) +coda_sync(vfsp, waitfor, td) struct mount *vfsp; int waitfor; - struct ucred *cred; struct thread *td; { ENTRY; diff --git a/sys/fs/coda/coda_vnops.c b/sys/fs/coda/coda_vnops.c index c204ef6329f6..71b69763d23c 100644 --- a/sys/fs/coda/coda_vnops.c +++ b/sys/fs/coda/coda_vnops.c @@ -763,7 +763,6 @@ coda_fsync(struct vop_fsync_args *ap) /* true args */ struct vnode *vp = ap->a_vp; struct cnode *cp = VTOC(vp); - struct ucred *cred = ap->a_cred; struct thread *td = ap->a_td; /* locals */ struct vnode *convp = cp->c_ovp; @@ -787,7 +786,7 @@ coda_fsync(struct vop_fsync_args *ap) } if (convp) - VOP_FSYNC(convp, cred, MNT_WAIT, td); + VOP_FSYNC(convp, MNT_WAIT, td); /* * We see fsyncs with usecount == 1 then usecount == 0. @@ -815,7 +814,7 @@ coda_fsync(struct vop_fsync_args *ap) /* needs research */ return 0; - error = venus_fsync(vtomi(vp), &cp->c_fid, cred, td->td_proc); + error = venus_fsync(vtomi(vp), &cp->c_fid, td->td_proc); CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); ); return(error); diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index a79f08f9ce90..91dfb5c838af 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -270,7 +270,7 @@ msdosfs_mount(struct mount *mp, struct thread *td) } if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0)) { - error = VFS_SYNC(mp, MNT_WAIT, td->td_ucred, td); + error = VFS_SYNC(mp, MNT_WAIT, td); if (error) return (error); flags = WRITECLOSE; @@ -852,10 +852,9 @@ msdosfs_statfs(mp, sbp, td) } static int -msdosfs_sync(mp, waitfor, cred, td) +msdosfs_sync(mp, waitfor, td) struct mount *mp; int waitfor; - struct ucred *cred; struct thread *td; { struct vnode *vp, *nvp; @@ -902,7 +901,7 @@ loop: goto loop; continue; } - error = VOP_FSYNC(vp, cred, waitfor, td); + error = VOP_FSYNC(vp, waitfor, td); if (error) allerror = error; VOP_UNLOCK(vp, 0, td); @@ -916,7 +915,7 @@ loop: */ if (waitfor != MNT_LAZY) { vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY, td); - error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, td); + error = VOP_FSYNC(pmp->pm_devvp, waitfor, td); if (error) allerror = error; VOP_UNLOCK(pmp->pm_devvp, 0, td); diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c index bfc26b4f7fe2..ad6e1e910bd5 100644 --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -296,10 +296,9 @@ nullfs_statfs(mp, sbp, td) } static int -nullfs_sync(mp, waitfor, cred, td) +nullfs_sync(mp, waitfor, td) struct mount *mp; int waitfor; - struct ucred *cred; struct thread *td; { /* diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 46110b54717f..596adc942595 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -1169,7 +1169,7 @@ union_fsync(ap) struct union_node *un = VTOUNION(ap->a_vp); if ((targetvp = union_lock_other(un, td)) != NULLVP) { - error = VOP_FSYNC(targetvp, ap->a_cred, ap->a_waitfor, td); + error = VOP_FSYNC(targetvp, ap->a_waitfor, td); union_unlock_other(targetvp, td); } diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index bce81c9b6880..9cd89167bbba 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -152,7 +152,7 @@ ext2_mount(mp, td) error = 0; if (fs->s_rd_only == 0 && vfs_flagopt(opts, "ro", NULL, 0)) { - error = VFS_SYNC(mp, MNT_WAIT, td->td_ucred, td); + error = VFS_SYNC(mp, MNT_WAIT, td); if (error) return (error); flags = WRITECLOSE; @@ -837,10 +837,9 @@ ext2_statfs(mp, sbp, td) * Note: we are always called with the filesystem marked `MPBUSY'. */ static int -ext2_sync(mp, waitfor, cred, td) +ext2_sync(mp, waitfor, td) struct mount *mp; int waitfor; - struct ucred *cred; struct thread *td; { struct vnode *nvp, *vp; @@ -882,7 +881,7 @@ loop: goto loop; continue; } - if ((error = VOP_FSYNC(vp, cred, waitfor, td)) != 0) + if ((error = VOP_FSYNC(vp, waitfor, td)) != 0) allerror = error; VOP_UNLOCK(vp, 0, td); vrele(vp); @@ -894,7 +893,7 @@ loop: */ if (waitfor != MNT_LAZY) { vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); - if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, td)) != 0) + if ((error = VOP_FSYNC(ump->um_devvp, waitfor, td)) != 0) allerror = error; VOP_UNLOCK(ump->um_devvp, 0, td); } diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index bce81c9b6880..9cd89167bbba 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -152,7 +152,7 @@ ext2_mount(mp, td) error = 0; if (fs->s_rd_only == 0 && vfs_flagopt(opts, "ro", NULL, 0)) { - error = VFS_SYNC(mp, MNT_WAIT, td->td_ucred, td); + error = VFS_SYNC(mp, MNT_WAIT, td); if (error) return (error); flags = WRITECLOSE; @@ -837,10 +837,9 @@ ext2_statfs(mp, sbp, td) * Note: we are always called with the filesystem marked `MPBUSY'. */ static int -ext2_sync(mp, waitfor, cred, td) +ext2_sync(mp, waitfor, td) struct mount *mp; int waitfor; - struct ucred *cred; struct thread *td; { struct vnode *nvp, *vp; @@ -882,7 +881,7 @@ loop: goto loop; continue; } - if ((error = VOP_FSYNC(vp, cred, waitfor, td)) != 0) + if ((error = VOP_FSYNC(vp, waitfor, td)) != 0) allerror = error; VOP_UNLOCK(vp, 0, td); vrele(vp); @@ -894,7 +893,7 @@ loop: */ if (waitfor != MNT_LAZY) { vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); - if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, td)) != 0) + if ((error = VOP_FSYNC(ump->um_devvp, waitfor, td)) != 0) allerror = error; VOP_UNLOCK(ump->um_devvp, 0, td); } diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 5562c9e45686..d1cc3638598a 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1028,7 +1028,7 @@ bdwrite(struct buf *bp) recursiveflushes++; } else if (bo->bo_dirty.bv_cnt > dirtybufthresh + 10) { BO_UNLOCK(bo); - (void) VOP_FSYNC(vp, td->td_ucred, MNT_NOWAIT, td); + (void) VOP_FSYNC(vp, MNT_NOWAIT, td); BO_LOCK(bo); altbufferflushes++; } else if (bo->bo_dirty.bv_cnt > dirtybufthresh) { diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index ba253e760d72..970861aabcbb 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -686,10 +686,9 @@ vfs_stdquotactl (mp, cmds, uid, arg, td) } int -vfs_stdsync(mp, waitfor, cred, td) +vfs_stdsync(mp, waitfor, td) struct mount *mp; int waitfor; - struct ucred *cred; struct thread *td; { struct vnode *vp, *nvp; @@ -718,7 +717,7 @@ loop: goto loop; continue; } - error = VOP_FSYNC(vp, cred, waitfor, td); + error = VOP_FSYNC(vp, waitfor, td); if (error) allerror = error; @@ -731,10 +730,9 @@ loop: } int -vfs_stdnosync (mp, waitfor, cred, td) +vfs_stdnosync (mp, waitfor, td) struct mount *mp; int waitfor; - struct ucred *cred; struct thread *td; { diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 82a5f1ff612a..17ef241c8646 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -133,8 +133,7 @@ sync(td, uap) asyncflag = mp->mnt_flag & MNT_ASYNC; mp->mnt_flag &= ~MNT_ASYNC; vfs_msync(mp, MNT_NOWAIT); - VFS_SYNC(mp, MNT_NOWAIT, - ((td != NULL) ? td->td_ucred : NOCRED), td); + VFS_SYNC(mp, MNT_NOWAIT, td); mp->mnt_flag |= asyncflag; vn_finished_write(mp); } @@ -3053,7 +3052,7 @@ fsync(td, uap) vm_object_page_clean(obj, 0, 0, 0); VM_OBJECT_UNLOCK(obj); } - error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, td); + error = VOP_FSYNC(vp, MNT_WAIT, td); if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) && softdep_fsync_hook != NULL) error = (*softdep_fsync_hook)(vp); diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 8a635f339bed..5e007e8154c0 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -950,7 +950,7 @@ dounmount(mp, flags, td) vput(fsrootvp); } if (((mp->mnt_flag & MNT_RDONLY) || - (error = VFS_SYNC(mp, MNT_WAIT, td->td_ucred, td)) == 0) || + (error = VFS_SYNC(mp, MNT_WAIT, td)) == 0) || (flags & MNT_FORCE)) { error = VFS_UNMOUNT(mp, flags, td); } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 2b6f7a1a14cc..3f5d431c9a4a 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -936,7 +936,7 @@ vinvalbuf(vp, flags, cred, td, slpflag, slptimeo) } if (bo->bo_dirty.bv_cnt > 0) { VI_UNLOCK(vp); - if ((error = VOP_FSYNC(vp, cred, MNT_WAIT, td)) != 0) + if ((error = VOP_FSYNC(vp, MNT_WAIT, td)) != 0) return (error); /* * XXX We could save a lock/unlock if this was only @@ -1487,7 +1487,7 @@ sync_vnode(struct bufobj *bo, struct thread *td) vholdl(vp); mtx_unlock(&sync_mtx); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, td); - (void) VOP_FSYNC(vp, td->td_ucred, MNT_LAZY, td); + (void) VOP_FSYNC(vp, MNT_LAZY, td); VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); VI_LOCK(vp); @@ -3135,7 +3135,7 @@ sync_fsync(ap) asyncflag = mp->mnt_flag & MNT_ASYNC; mp->mnt_flag &= ~MNT_ASYNC; vfs_msync(mp, MNT_NOWAIT); - error = VFS_SYNC(mp, MNT_LAZY, ap->a_cred, td); + error = VFS_SYNC(mp, MNT_LAZY, td); if (asyncflag) mp->mnt_flag |= MNT_ASYNC; vn_finished_write(mp); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 82a5f1ff612a..17ef241c8646 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -133,8 +133,7 @@ sync(td, uap) asyncflag = mp->mnt_flag & MNT_ASYNC; mp->mnt_flag &= ~MNT_ASYNC; vfs_msync(mp, MNT_NOWAIT); - VFS_SYNC(mp, MNT_NOWAIT, - ((td != NULL) ? td->td_ucred : NOCRED), td); + VFS_SYNC(mp, MNT_NOWAIT, td); mp->mnt_flag |= asyncflag; vn_finished_write(mp); } @@ -3053,7 +3052,7 @@ fsync(td, uap) vm_object_page_clean(obj, 0, 0, 0); VM_OBJECT_UNLOCK(obj); } - error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, td); + error = VOP_FSYNC(vp, MNT_WAIT, td); if (error == 0 && vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) && softdep_fsync_hook != NULL) error = (*softdep_fsync_hook)(vp); diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index e69cedaf69a2..3e98446c2dd8 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1021,7 +1021,7 @@ vfs_write_suspend(mp) mp->mnt_kern_flag |= MNTK_SUSPEND; if (mp->mnt_writeopcount > 0) (void) tsleep(&mp->mnt_writeopcount, PUSER - 1, "suspwt", 0); - if ((error = VFS_SYNC(mp, MNT_WAIT, td->td_ucred, td)) != 0) { + if ((error = VFS_SYNC(mp, MNT_WAIT, td)) != 0) { vfs_write_resume(mp); return (error); } diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index 17efba77934b..03f63037b91c 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -247,7 +247,6 @@ vop_revoke { # vop_fsync { IN struct vnode *vp; - IN struct ucred *cred; IN int waitfor; IN struct thread *td; }; diff --git a/sys/nfs4client/nfs4_vfsops.c b/sys/nfs4client/nfs4_vfsops.c index a1985359b0f2..fa066c788f03 100644 --- a/sys/nfs4client/nfs4_vfsops.c +++ b/sys/nfs4client/nfs4_vfsops.c @@ -733,7 +733,7 @@ nfs_root(struct mount *mp, struct vnode **vpp, struct thread *td) */ /* ARGSUSED */ static int -nfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *td) +nfs_sync(struct mount *mp, int waitfor, struct thread *td) { struct vnode *vp, *nvp; int error, allerror = 0; @@ -756,7 +756,7 @@ loop: if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) { goto loop; } - error = VOP_FSYNC(vp, cred, waitfor, td); + error = VOP_FSYNC(vp, waitfor, td); if (error) allerror = error; VOP_UNLOCK(vp, 0, td); diff --git a/sys/nfs4client/nfs4_vnops.c b/sys/nfs4client/nfs4_vnops.c index abb6b332c511..e61c7794d9a3 100644 --- a/sys/nfs4client/nfs4_vnops.c +++ b/sys/nfs4client/nfs4_vnops.c @@ -127,7 +127,7 @@ __FBSDID("$FreeBSD$"); #define vfs_busy_pages(bp, f) #endif -static int nfs4_flush(struct vnode *, struct ucred *, int, struct thread *, +static int nfs4_flush(struct vnode *, int, struct thread *, int); static int nfs4_setattrrpc(struct vnode *, struct vattr *, struct ucred *, struct thread *); @@ -1791,10 +1791,10 @@ nfs4_rename(struct vop_rename_args *ap) * ( as far as I can tell ) it flushes dirty buffers more * often. */ - VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_thread); + VOP_FSYNC(fvp, MNT_WAIT, fcnp->cn_thread); VOP_UNLOCK(fvp, 0, fcnp->cn_thread); if (tvp) - VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_thread); + VOP_FSYNC(tvp, MNT_WAIT, tcnp->cn_thread); /* * If the tvp exists and is in use, sillyrename it before doing the @@ -1869,7 +1869,7 @@ nfs4_link(struct vop_link_args *ap) * doesn't get "out of sync" with the server. * XXX There should be a better way! */ - VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_thread); + VOP_FSYNC(vp, MNT_WAIT, cnp->cn_thread); nfsstats.rpccnt[NFSPROC_LINK]++; @@ -2549,7 +2549,7 @@ nfs4_strategy(struct vop_strategy_args *ap) static int nfs4_fsync(struct vop_fsync_args *ap) { - return (nfs4_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_td, 1)); + return (nfs4_flush(ap->a_vp, ap->a_waitfor, ap->a_td, 1)); } /* @@ -2558,7 +2558,7 @@ nfs4_fsync(struct vop_fsync_args *ap) * associated with the vnode. */ static int -nfs4_flush(struct vnode *vp, struct ucred *cred, int waitfor, struct thread *td, +nfs4_flush(struct vnode *vp, int waitfor, struct thread *td, int commit) { struct nfsnode *np = VTONFS(vp); diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index 4a4d5d23a6e8..81defd982467 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -977,7 +977,7 @@ nfs_root(struct mount *mp, struct vnode **vpp, struct thread *td) */ /* ARGSUSED */ static int -nfs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *td) +nfs_sync(struct mount *mp, int waitfor, struct thread *td) { struct vnode *vp, *nvp; int error, allerror = 0; @@ -1001,7 +1001,7 @@ loop: MNT_ILOCK(mp); goto loop; } - error = VOP_FSYNC(vp, cred, waitfor, td); + error = VOP_FSYNC(vp, waitfor, td); if (error) allerror = error; VOP_UNLOCK(vp, 0, td); diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index f2074ddcb305..36540c295c6d 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -99,7 +99,7 @@ __FBSDID("$FreeBSD$"); static vop_read_t nfsfifo_read; static vop_write_t nfsfifo_write; static vop_close_t nfsfifo_close; -static int nfs_flush(struct vnode *, struct ucred *, int, struct thread *, +static int nfs_flush(struct vnode *, int, struct thread *, int); static int nfs_setattrrpc(struct vnode *, struct vattr *, struct ucred *, struct thread *); @@ -534,7 +534,7 @@ nfs_close(struct vop_close_args *ap) * cannot clear it if we don't commit. */ int cm = nfsv3_commit_on_close ? 1 : 0; - error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_td, cm); + error = nfs_flush(vp, MNT_WAIT, ap->a_td, cm); /* np->n_flag &= ~NMODIFIED; */ } else { error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_td, 1); @@ -1585,10 +1585,10 @@ nfs_rename(struct vop_rename_args *ap) * that was written back to our cache earlier. Not checking for * this condition can result in potential (silent) data loss. */ - error = VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_thread); + error = VOP_FSYNC(fvp, MNT_WAIT, fcnp->cn_thread); VOP_UNLOCK(fvp, 0, fcnp->cn_thread); if (!error && tvp) - error = VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_thread); + error = VOP_FSYNC(tvp, MNT_WAIT, tcnp->cn_thread); if (error) goto out; @@ -1704,7 +1704,7 @@ nfs_link(struct vop_link_args *ap) * doesn't get "out of sync" with the server. * XXX There should be a better way! */ - VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_thread); + VOP_FSYNC(vp, MNT_WAIT, cnp->cn_thread); v3 = NFS_ISV3(vp); nfsstats.rpccnt[NFSPROC_LINK]++; @@ -2661,7 +2661,7 @@ static int nfs_fsync(struct vop_fsync_args *ap) { - return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_td, 1)); + return (nfs_flush(ap->a_vp, ap->a_waitfor, ap->a_td, 1)); } /* @@ -2670,7 +2670,7 @@ nfs_fsync(struct vop_fsync_args *ap) * associated with the vnode. */ static int -nfs_flush(struct vnode *vp, struct ucred *cred, int waitfor, struct thread *td, +nfs_flush(struct vnode *vp, int waitfor, struct thread *td, int commit) { struct nfsnode *np = VTONFS(vp); diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c index 778dc5ecf635..21aff156ee49 100644 --- a/sys/nfsserver/nfs_serv.c +++ b/sys/nfsserver/nfs_serv.c @@ -4042,7 +4042,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, vm_object_page_clean(vp->v_object, 0, 0, OBJPC_SYNC); VM_OBJECT_UNLOCK(vp->v_object); } - error = VOP_FSYNC(vp, cred, MNT_WAIT, td); + error = VOP_FSYNC(vp, MNT_WAIT, td); } else { /* * Locate and synchronously write any buffers that fall diff --git a/sys/sys/mount.h b/sys/sys/mount.h index fce0d9a62b9f..c377e818c3f3 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -469,8 +469,7 @@ typedef int vfs_quotactl_t(struct mount *mp, int cmds, uid_t uid, caddr_t arg, struct thread *td); typedef int vfs_statfs_t(struct mount *mp, struct statfs *sbp, struct thread *td); -typedef int vfs_sync_t(struct mount *mp, int waitfor, struct ucred *cred, - struct thread *td); +typedef int vfs_sync_t(struct mount *mp, int waitfor, struct thread *td); typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags, struct vnode **vpp); typedef int vfs_fhtovp_t(struct mount *mp, struct fid *fhp, struct vnode **vpp); @@ -513,7 +512,7 @@ vfs_statfs_t __vfs_statfs; #define VFS_ROOT(MP, VPP, P) (*(MP)->mnt_op->vfs_root)(MP, VPP, P) #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) #define VFS_STATFS(MP, SBP, P) __vfs_statfs((MP), (SBP), (P)) -#define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P) +#define VFS_SYNC(MP, WAIT, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, P) #define VFS_VGET(MP, INO, FLAGS, VPP) \ (*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP) #define VFS_FHTOVP(MP, FIDP, VPP) \ diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index 4d5cedc18edb..04a40811328f 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -395,7 +395,7 @@ fail: * occurence. The error return from fsync is ignored as we already * have an error to return to the user. */ - (void) VOP_FSYNC(vp, cred, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); for (deallocated = 0, blkp = allociblk; blkp < allocblk; blkp++) { ffs_blkfree(fs, ip->i_devvp, *blkp, fs->fs_bsize, ip->i_number); deallocated += fs->fs_bsize; @@ -432,7 +432,7 @@ fail: dp->di_blocks -= btodb(deallocated); ip->i_flag |= IN_CHANGE | IN_UPDATE; } - (void) VOP_FSYNC(vp, cred, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); return (error); } @@ -862,7 +862,7 @@ fail: * occurence. The error return from fsync is ignored as we already * have an error to return to the user. */ - (void) VOP_FSYNC(vp, cred, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); for (deallocated = 0, blkp = allociblk; blkp < allocblk; blkp++) { ffs_blkfree(fs, ip->i_devvp, *blkp, fs->fs_bsize, ip->i_number); deallocated += fs->fs_bsize; @@ -899,6 +899,6 @@ fail: dp->di_blocks -= btodb(deallocated); ip->i_flag |= IN_CHANGE | IN_UPDATE; } - (void) VOP_FSYNC(vp, cred, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); return (error); } diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index f1bddc029ffe..3987e6eafa3c 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -192,7 +192,7 @@ ffs_truncate(vp, length, flags, cred, td) } else { if (length != 0) panic("ffs_truncate: partial trunc of extdata"); - if ((error = VOP_FSYNC(ovp, cred, MNT_WAIT, td)) != 0) + if ((error = VOP_FSYNC(ovp, MNT_WAIT, td)) != 0) return (error); osize = oip->i_din2->di_extsize; oip->i_din2->di_blocks -= extblocks; @@ -262,7 +262,7 @@ ffs_truncate(vp, length, flags, cred, td) * rarely, we solve the problem by syncing the file * so that it will have no data structures left. */ - if ((error = VOP_FSYNC(ovp, cred, MNT_WAIT, td)) != 0) + if ((error = VOP_FSYNC(ovp, MNT_WAIT, td)) != 0) return (error); if (oip->i_flag & IN_SPACECOUNTED) fs->fs_pendingblocks -= datablocks; @@ -330,7 +330,7 @@ ffs_truncate(vp, length, flags, cred, td) */ if (DOINGSOFTDEP(ovp) && lbn < NDADDR && fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize && - (error = VOP_FSYNC(ovp, cred, MNT_WAIT, td)) != 0) + (error = VOP_FSYNC(ovp, MNT_WAIT, td)) != 0) return (error); oip->i_size = length; DIP_SET(oip, i_size, length); diff --git a/sys/ufs/ffs/ffs_rawread.c b/sys/ufs/ffs/ffs_rawread.c index 2594ae48a750..e147b4a3e16e 100644 --- a/sys/ufs/ffs/ffs_rawread.c +++ b/sys/ufs/ffs/ffs_rawread.c @@ -151,7 +151,7 @@ ffs_rawread_sync(struct vnode *vp, struct thread *td) if (bo->bo_dirty.bv_cnt > 0) { splx(spl); VI_UNLOCK(vp); - if ((error = VOP_FSYNC(vp, NOCRED, MNT_WAIT, td)) != 0) { + if ((error = VOP_FSYNC(vp, MNT_WAIT, td)) != 0) { if (upgraded != 0) VOP_LOCK(vp, LK_DOWNGRADE, td); return (error); diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index e867c71699a7..e5d8b42d7538 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -308,7 +308,7 @@ restart: * Since we have marked it as a snapshot it is safe to * unlock it as no process will be allowed to write to it. */ - if ((error = VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td)) != 0) + if ((error = VOP_FSYNC(vp, MNT_WAIT, td)) != 0) goto out; VOP_UNLOCK(vp, 0, td); /* @@ -690,7 +690,7 @@ out: mp->mnt_flag = flag; if (error) (void) UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, td); - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); if (error) vput(vp); else @@ -1711,7 +1711,7 @@ retry: bcopy(savedcbp->b_data, cbp->b_data, fs->fs_bsize); bawrite(cbp); if (dopersistence && ip->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); continue; } /* @@ -1721,7 +1721,7 @@ retry: bzero(cbp->b_data, fs->fs_bsize); bawrite(cbp); if (dopersistence && ip->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); break; } savedcbp = cbp; @@ -1735,7 +1735,7 @@ retry: vp = savedcbp->b_vp; bawrite(savedcbp); if (dopersistence && VTOI(vp)->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); } /* * If we have been unable to allocate a block in which to do @@ -1797,7 +1797,7 @@ ffs_snapshot_mount(mp) } else { reason = "old format snapshot"; (void)UFS_TRUNCATE(vp, (off_t)0, 0, NOCRED, td); - (void)VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + (void)VOP_FSYNC(vp, MNT_WAIT, td); } printf("ffs_snapshot_mount: %s inode %d\n", reason, fs->fs_snapinum[snaploc]); @@ -2078,7 +2078,7 @@ retry: bcopy(savedcbp->b_data, cbp->b_data, fs->fs_bsize); bawrite(cbp); if (dopersistence && ip->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); continue; } /* @@ -2088,7 +2088,7 @@ retry: bzero(cbp->b_data, fs->fs_bsize); bawrite(cbp); if (dopersistence && ip->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); break; } savedcbp = cbp; @@ -2102,7 +2102,7 @@ retry: vp = savedcbp->b_vp; bawrite(savedcbp); if (dopersistence && VTOI(vp)->i_effnlink > 0) - (void) VOP_FSYNC(vp, KERNCRED, MNT_WAIT, td); + (void) VOP_FSYNC(vp, MNT_WAIT, td); } if (snapshot_locked) VOP_UNLOCK(vp, 0, td); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index a673645be8b9..a9c1d7401e4e 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -844,7 +844,7 @@ softdep_flushworklist(oldmnt, countp, td) while ((count = softdep_process_worklist(oldmnt)) > 0) { *countp += count; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td); - error = VOP_FSYNC(devvp, td->td_ucred, MNT_WAIT, td); + error = VOP_FSYNC(devvp, MNT_WAIT, td); VOP_UNLOCK(devvp, 0, td); if (error) break; @@ -4882,7 +4882,7 @@ softdep_fsync(vp) return (error); } if ((pagedep->pd_state & NEWBLOCK) && - (error = VOP_FSYNC(pvp, td->td_ucred, MNT_WAIT, td))) { + (error = VOP_FSYNC(pvp, MNT_WAIT, td))) { vput(pvp); return (error); } @@ -5362,8 +5362,8 @@ flush_pagedep_deps(pvp, mp, diraddhdp) FREE_LOCK(&lk); if ((error = VFS_VGET(mp, inum, LK_EXCLUSIVE, &vp))) break; - if ((error=VOP_FSYNC(vp, td->td_ucred, MNT_NOWAIT, td)) || - (error=VOP_FSYNC(vp, td->td_ucred, MNT_NOWAIT, td))) { + if ((error=VOP_FSYNC(vp, MNT_NOWAIT, td)) || + (error=VOP_FSYNC(vp, MNT_NOWAIT, td))) { vput(vp); break; } @@ -5641,7 +5641,7 @@ clear_remove(td) vn_finished_write(mp); return; } - if ((error = VOP_FSYNC(vp, td->td_ucred, MNT_NOWAIT, td))) + if ((error = VOP_FSYNC(vp, MNT_NOWAIT, td))) softdep_error("clear_remove: fsync", error); VI_LOCK(vp); drain_output(vp, 0); @@ -5717,10 +5717,10 @@ clear_inodedeps(td) return; } if (ino == lastino) { - if ((error = VOP_FSYNC(vp, td->td_ucred, MNT_WAIT, td))) + if ((error = VOP_FSYNC(vp, MNT_WAIT, td))) softdep_error("clear_inodedeps: fsync1", error); } else { - if ((error = VOP_FSYNC(vp, td->td_ucred, MNT_NOWAIT, td))) + if ((error = VOP_FSYNC(vp, MNT_NOWAIT, td))) softdep_error("clear_inodedeps: fsync2", error); VI_LOCK(vp); drain_output(vp, 0); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index bb7b61484bbc..754d10e574a4 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -157,8 +157,7 @@ ffs_mount(struct mount *mp, struct thread *td) /* * Flush any dirty data. */ - if ((error = VFS_SYNC(mp, MNT_WAIT, - td->td_ucred, td)) != 0) { + if ((error = VFS_SYNC(mp, MNT_WAIT, td)) != 0) { vn_finished_write(mp); return (error); } @@ -1001,7 +1000,7 @@ ffs_flushfiles(mp, flags, td) * Flush filesystem metadata. */ vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, td); - error = VOP_FSYNC(ump->um_devvp, td->td_ucred, MNT_WAIT, td); + error = VOP_FSYNC(ump->um_devvp, MNT_WAIT, td); VOP_UNLOCK(ump->um_devvp, 0, td); return (error); } @@ -1044,10 +1043,9 @@ ffs_statfs(mp, sbp, td) * Note: we are always called with the filesystem marked `MPBUSY'. */ int -ffs_sync(mp, waitfor, cred, td) +ffs_sync(mp, waitfor, td) struct mount *mp; int waitfor; - struct ucred *cred; struct thread *td; { struct vnode *nvp, *vp, *devvp; @@ -1100,7 +1098,7 @@ loop: goto loop; continue; } - if ((error = VOP_FSYNC(vp, cred, waitfor, td)) != 0) + if ((error = VOP_FSYNC(vp, waitfor, td)) != 0) allerror = error; VOP_UNLOCK(vp, 0, td); vrele(vp); @@ -1128,7 +1126,7 @@ loop: if (waitfor != MNT_LAZY && (bo->bo_numoutput > 0 || bo->bo_dirty.bv_cnt > 0)) { vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, td); - if ((error = VOP_FSYNC(devvp, cred, waitfor, td)) != 0) + if ((error = VOP_FSYNC(devvp, waitfor, td)) != 0) allerror = error; VOP_UNLOCK(devvp, 0, td); if (allerror == 0 && waitfor == MNT_WAIT) { diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 9f534ce81773..8e5a757442cd 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -805,7 +805,7 @@ ufs_direnter(dvp, tvp, dirp, cnp, newdirbp) return (error); if (tvp != NULL) VOP_UNLOCK(tvp, 0, td); - error = VOP_FSYNC(dvp, td->td_ucred, MNT_WAIT, td); + error = VOP_FSYNC(dvp, MNT_WAIT, td); if (tvp != NULL) vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, td); return (error); diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index df904a5c9d80..264150f407d1 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -835,7 +835,7 @@ again: } vm_page_unlock_queues(); #if 0 - VOP_FSYNC(vp, NULL, (pagerflags & VM_PAGER_PUT_SYNC)?MNT_WAIT:0, curproc); + VOP_FSYNC(vp, (pagerflags & VM_PAGER_PUT_SYNC)?MNT_WAIT:0, curproc); #endif vm_object_clear_flag(object, OBJ_CLEANING);