Replace the checks for MNTK_UNMOUNTF with a macro that does the same thing.
This patch defines a macro that checks for MNTK_UNMOUNTF and replaces explicit checks with this macro. It has no effect on semantics, but prepares the code for a future patch where there will also be a NFS specific flag for "forced dismount about to occur". Suggested by: kib MFC after: 2 weeks
This commit is contained in:
parent
7ceeb35bd8
commit
16f300fa4a
@ -511,7 +511,7 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmount *nmp,
|
||||
if (xidp != NULL)
|
||||
*xidp = 0;
|
||||
/* Reject requests while attempting a forced unmount. */
|
||||
if (nmp != NULL && (nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF)) {
|
||||
if (nmp != NULL && NFSCL_FORCEDISM(nmp->nm_mountp)) {
|
||||
m_freem(nd->nd_mreq);
|
||||
return (ESTALE);
|
||||
}
|
||||
@ -1231,7 +1231,7 @@ newnfs_sigintr(struct nfsmount *nmp, struct thread *td)
|
||||
sigset_t tmpset;
|
||||
|
||||
/* Terminate all requests while attempting a forced unmount. */
|
||||
if (nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF)
|
||||
if (NFSCL_FORCEDISM(nmp->nm_mountp))
|
||||
return (EIO);
|
||||
if (!(nmp->nm_flag & NFSMNT_INT))
|
||||
return (0);
|
||||
|
@ -1839,7 +1839,7 @@ nfsv4_lock(struct nfsv4lock *lp, int iwantlock, int *isleptp,
|
||||
lp->nfslock_lock |= NFSV4LOCK_LOCKWANTED;
|
||||
}
|
||||
while (lp->nfslock_lock & (NFSV4LOCK_LOCK | NFSV4LOCK_LOCKWANTED)) {
|
||||
if (mp != NULL && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
|
||||
if (mp != NULL && NFSCL_FORCEDISM(mp)) {
|
||||
lp->nfslock_lock &= ~NFSV4LOCK_LOCKWANTED;
|
||||
return (0);
|
||||
}
|
||||
@ -1893,7 +1893,7 @@ nfsv4_relref(struct nfsv4lock *lp)
|
||||
* not wait for threads that want the exclusive lock. If priority needs
|
||||
* to be given to threads that need the exclusive lock, a call to nfsv4_lock()
|
||||
* with the 2nd argument == 0 should be done before calling nfsv4_getref().
|
||||
* If the mp argument is not NULL, check for MNTK_UNMOUNTF being set and
|
||||
* If the mp argument is not NULL, check for NFSCL_FORCEDISM() being set and
|
||||
* return without getting a refcnt for that case.
|
||||
*/
|
||||
APPLESTATIC void
|
||||
@ -1908,7 +1908,7 @@ nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void *mutex,
|
||||
* Wait for a lock held.
|
||||
*/
|
||||
while (lp->nfslock_lock & NFSV4LOCK_LOCK) {
|
||||
if (mp != NULL && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0)
|
||||
if (mp != NULL && NFSCL_FORCEDISM(mp))
|
||||
return;
|
||||
lp->nfslock_lock |= NFSV4LOCK_WANTED;
|
||||
if (isleptp)
|
||||
@ -1916,7 +1916,7 @@ nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void *mutex,
|
||||
(void) nfsmsleep(&lp->nfslock_lock, mutex,
|
||||
PZERO - 1, "nfsv4gr", NULL);
|
||||
}
|
||||
if (mp != NULL && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0)
|
||||
if (mp != NULL && NFSCL_FORCEDISM(mp))
|
||||
return;
|
||||
|
||||
lp->nfslock_usecnt++;
|
||||
@ -4197,9 +4197,7 @@ nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsclsession *sep,
|
||||
* This RPC attempt will fail when it calls
|
||||
* newnfs_request().
|
||||
*/
|
||||
if (nmp != NULL &&
|
||||
(nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF)
|
||||
!= 0) {
|
||||
if (nmp != NULL && NFSCL_FORCEDISM(nmp->nm_mountp)) {
|
||||
mtx_unlock(&sep->nfsess_mtx);
|
||||
return (ESTALE);
|
||||
}
|
||||
|
@ -59,6 +59,9 @@ struct nfsv4node {
|
||||
#define NFSCL_RENEW(l) (((l) < 2) ? 1 : ((l) / 2))
|
||||
#define NFSCL_LEASE(r) ((r) * 2)
|
||||
|
||||
/* This macro checks to see if a forced dismount is about to occur. */
|
||||
#define NFSCL_FORCEDISM(m) (((m)->mnt_kern_flag & MNTK_UNMOUNTF) != 0)
|
||||
|
||||
/*
|
||||
* These flag bits are used for the argument to nfscl_fillsattr() to
|
||||
* indicate special handling of the attributes.
|
||||
|
@ -1342,7 +1342,7 @@ ncl_vinvalbuf(struct vnode *vp, int flags, struct thread *td, int intrflg)
|
||||
|
||||
if ((nmp->nm_flag & NFSMNT_INT) == 0)
|
||||
intrflg = 0;
|
||||
if ((nmp->nm_mountp->mnt_kern_flag & MNTK_UNMOUNTF))
|
||||
if (NFSCL_FORCEDISM(nmp->nm_mountp))
|
||||
intrflg = 1;
|
||||
if (intrflg) {
|
||||
slpflag = PCATCH;
|
||||
|
@ -313,7 +313,7 @@ nfscl_ngetreopen(struct mount *mntp, u_int8_t *fhp, int fhsize,
|
||||
|
||||
*npp = NULL;
|
||||
/* For forced dismounts, just return error. */
|
||||
if ((mntp->mnt_kern_flag & MNTK_UNMOUNTF))
|
||||
if (NFSCL_FORCEDISM(mntp))
|
||||
return (EINTR);
|
||||
MALLOC(nfhp, struct nfsfh *, sizeof (struct nfsfh) + fhsize,
|
||||
M_NFSFH, M_WAITOK);
|
||||
@ -336,7 +336,7 @@ nfscl_ngetreopen(struct mount *mntp, u_int8_t *fhp, int fhsize,
|
||||
* stopped and the MNTK_UNMOUNTF flag is set before doing
|
||||
* a vflush() with FORCECLOSE, we should be ok here.
|
||||
*/
|
||||
if ((mntp->mnt_kern_flag & MNTK_UNMOUNTF))
|
||||
if (NFSCL_FORCEDISM(mntp))
|
||||
error = EINTR;
|
||||
else {
|
||||
vfs_hash_ref(mntp, hash, td, &nvp, newnfs_vncmpf, nfhp);
|
||||
|
@ -803,7 +803,7 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p,
|
||||
* allocate a new clientid and get out now. For the case where
|
||||
* clp != NULL, this is a harmless optimization.
|
||||
*/
|
||||
if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
|
||||
if (NFSCL_FORCEDISM(mp)) {
|
||||
NFSUNLOCKCLSTATE();
|
||||
if (newclp != NULL)
|
||||
free(newclp, M_NFSCLCLIENT);
|
||||
@ -843,7 +843,7 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p,
|
||||
}
|
||||
NFSLOCKCLSTATE();
|
||||
while ((clp->nfsc_flags & NFSCLFLAGS_HASCLIENTID) == 0 && !igotlock &&
|
||||
(mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0)
|
||||
!NFSCL_FORCEDISM(mp))
|
||||
igotlock = nfsv4_lock(&clp->nfsc_lock, 1, NULL,
|
||||
NFSCLSTATEMUTEXPTR, mp);
|
||||
if (igotlock == 0) {
|
||||
@ -858,10 +858,10 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSPROC_T *p,
|
||||
nfsv4_lock(&clp->nfsc_lock, 0, NULL, NFSCLSTATEMUTEXPTR, mp);
|
||||
nfsv4_getref(&clp->nfsc_lock, NULL, NFSCLSTATEMUTEXPTR, mp);
|
||||
}
|
||||
if (igotlock == 0 && (mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
|
||||
if (igotlock == 0 && NFSCL_FORCEDISM(mp)) {
|
||||
/*
|
||||
* Both nfsv4_lock() and nfsv4_getref() know to check
|
||||
* for MNTK_UNMOUNTF and return without sleeping to
|
||||
* for NFSCL_FORCEDISM() and return without sleeping to
|
||||
* wait for the exclusive lock to be released, since it
|
||||
* might be held by nfscl_umount() and we need to get out
|
||||
* now for that case and not wait until nfscl_umount()
|
||||
@ -4844,7 +4844,7 @@ nfscl_layout(struct nfsmount *nmp, vnode_t vp, u_int8_t *fhp, int fhlen,
|
||||
lyp->nfsly_timestamp = NFSD_MONOSEC + 120;
|
||||
}
|
||||
nfsv4_getref(&lyp->nfsly_lock, NULL, NFSCLSTATEMUTEXPTR, mp);
|
||||
if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
|
||||
if (NFSCL_FORCEDISM(mp)) {
|
||||
NFSUNLOCKCLSTATE();
|
||||
if (tlyp != NULL)
|
||||
free(tlyp, M_NFSLAYOUT);
|
||||
@ -4903,11 +4903,10 @@ nfscl_getlayout(struct nfsclclient *clp, uint8_t *fhp, int fhlen,
|
||||
do {
|
||||
igotlock = nfsv4_lock(&lyp->nfsly_lock,
|
||||
1, NULL, NFSCLSTATEMUTEXPTR, mp);
|
||||
} while (igotlock == 0 &&
|
||||
(mp->mnt_kern_flag & MNTK_UNMOUNTF) == 0);
|
||||
} while (igotlock == 0 && !NFSCL_FORCEDISM(mp));
|
||||
*retflpp = NULL;
|
||||
}
|
||||
if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
|
||||
if (NFSCL_FORCEDISM(mp)) {
|
||||
lyp = NULL;
|
||||
*recalledp = 1;
|
||||
}
|
||||
@ -5298,7 +5297,7 @@ nfscl_layoutcommit(vnode_t vp, NFSPROC_T *p)
|
||||
return (EPERM);
|
||||
}
|
||||
nfsv4_getref(&lyp->nfsly_lock, NULL, NFSCLSTATEMUTEXPTR, mp);
|
||||
if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
|
||||
if (NFSCL_FORCEDISM(mp)) {
|
||||
NFSUNLOCKCLSTATE();
|
||||
return (EPERM);
|
||||
}
|
||||
|
@ -1775,7 +1775,7 @@ nfs_sync(struct mount *mp, int waitfor)
|
||||
* the umount(2) syscall doesn't get stuck in VFS_SYNC() before
|
||||
* calling VFS_UNMOUNT().
|
||||
*/
|
||||
if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
|
||||
if (NFSCL_FORCEDISM(mp)) {
|
||||
MNT_IUNLOCK(mp);
|
||||
return (EBADF);
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ nfs_close(struct vop_close_args *ap)
|
||||
int error = 0, ret, localcred = 0;
|
||||
int fmode = ap->a_fflag;
|
||||
|
||||
if ((vp->v_mount->mnt_kern_flag & MNTK_UNMOUNTF))
|
||||
if (NFSCL_FORCEDISM(vp->v_mount))
|
||||
return (0);
|
||||
/*
|
||||
* During shutdown, a_cred isn't valid, so just use root.
|
||||
|
Loading…
x
Reference in New Issue
Block a user