nfsv4 client: fix forced dismount when sleeping on nfsv4lck
During a recent NFSv4 testing event a test server caused a hang where "umount -N" failed. The renew thread was sleeping on "nfsv4lck" and the "umount" was sleeping, waiting for the renew thread to terminate. This is the first of two patches that is hoped to fix the renew thread so that it will terminate when "umount -N" is done on the mount. nfsv4_lock() checks for forced dismount, but only after it wakes up from msleep(). Without this patch, a wakeup() call was required. This patch adds a 1second timeout on the msleep(), so that it will wake up and see the forced dismount flag. Normally a wakeup() will occur in less than 1second, but if a premature return from msleep() does occur, it will simply loop around and msleep() again. While here, replace the nfsmsleep() wrapper that was used for portability with the actual msleep() call and make the same change for nfsv4_getref(). MFC after: 2 weeks
This commit is contained in:
parent
3cc6f777be
commit
5f742d3879
@ -2252,7 +2252,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
|
||||
*/
|
||||
int
|
||||
nfsv4_lock(struct nfsv4lock *lp, int iwantlock, int *isleptp,
|
||||
void *mutex, struct mount *mp)
|
||||
struct mtx *mutex, struct mount *mp)
|
||||
{
|
||||
|
||||
if (isleptp)
|
||||
@ -2280,8 +2280,7 @@ nfsv4_lock(struct nfsv4lock *lp, int iwantlock, int *isleptp,
|
||||
lp->nfslock_lock |= NFSV4LOCK_WANTED;
|
||||
if (isleptp)
|
||||
*isleptp = 1;
|
||||
(void) nfsmsleep(&lp->nfslock_lock, mutex,
|
||||
PZERO - 1, "nfsv4lck", NULL);
|
||||
msleep(&lp->nfslock_lock, mutex, PVFS, "nfsv4lck", hz);
|
||||
if (iwantlock && !(lp->nfslock_lock & NFSV4LOCK_LOCK) &&
|
||||
lp->nfslock_usecnt == 0) {
|
||||
lp->nfslock_lock &= ~NFSV4LOCK_LOCKWANTED;
|
||||
@ -2331,7 +2330,7 @@ nfsv4_relref(struct nfsv4lock *lp)
|
||||
* return without getting a refcnt for that case.
|
||||
*/
|
||||
void
|
||||
nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void *mutex,
|
||||
nfsv4_getref(struct nfsv4lock *lp, int *isleptp, struct mtx *mutex,
|
||||
struct mount *mp)
|
||||
{
|
||||
|
||||
@ -2347,8 +2346,7 @@ nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void *mutex,
|
||||
lp->nfslock_lock |= NFSV4LOCK_WANTED;
|
||||
if (isleptp)
|
||||
*isleptp = 1;
|
||||
(void) nfsmsleep(&lp->nfslock_lock, mutex,
|
||||
PZERO - 1, "nfsv4gr", NULL);
|
||||
msleep(&lp->nfslock_lock, mutex, PVFS, "nfsv4gr", hz);
|
||||
}
|
||||
if (mp != NULL && NFSCL_FORCEDISM(mp))
|
||||
return;
|
||||
|
@ -335,10 +335,10 @@ int nfsv4_loadattr(struct nfsrv_descript *, vnode_t,
|
||||
struct nfsv3_pathconf *, struct statfs *, struct nfsstatfs *,
|
||||
struct nfsfsinfo *, NFSACL_T *,
|
||||
int, int *, u_int32_t *, u_int32_t *, NFSPROC_T *, struct ucred *);
|
||||
int nfsv4_lock(struct nfsv4lock *, int, int *, void *, struct mount *);
|
||||
int nfsv4_lock(struct nfsv4lock *, int, int *, struct mtx *, struct mount *);
|
||||
void nfsv4_unlock(struct nfsv4lock *, int);
|
||||
void nfsv4_relref(struct nfsv4lock *);
|
||||
void nfsv4_getref(struct nfsv4lock *, int *, void *, struct mount *);
|
||||
void nfsv4_getref(struct nfsv4lock *, int *, struct mtx *, struct mount *);
|
||||
int nfsv4_getref_nonblock(struct nfsv4lock *);
|
||||
int nfsv4_testlock(struct nfsv4lock *);
|
||||
int nfsrv_mtostr(struct nfsrv_descript *, char *, int);
|
||||
|
Loading…
Reference in New Issue
Block a user