From owner-svn-src-stable@freebsd.org Fri Aug 25 22:39:50 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D75FBDE2E57; Fri, 25 Aug 2017 22:39:50 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B2F7273459; Fri, 25 Aug 2017 22:39:50 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7PMdnuo012763; Fri, 25 Aug 2017 22:39:49 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7PMdnbS012755; Fri, 25 Aug 2017 22:39:49 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201708252239.v7PMdnbS012755@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 25 Aug 2017 22:39:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322907 - in stable/11/sys/fs: nfs nfsclient X-SVN-Group: stable-11 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in stable/11/sys/fs: nfs nfsclient X-SVN-Commit-Revision: 322907 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 22:39:51 -0000 Author: rmacklem Date: Fri Aug 25 22:39:49 2017 New Revision: 322907 URL: https://svnweb.freebsd.org/changeset/base/322907 Log: MFC: r321628 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". Modified: stable/11/sys/fs/nfs/nfs_commonkrpc.c stable/11/sys/fs/nfs/nfs_commonsubs.c stable/11/sys/fs/nfs/nfscl.h stable/11/sys/fs/nfsclient/nfs_clbio.c stable/11/sys/fs/nfsclient/nfs_clport.c stable/11/sys/fs/nfsclient/nfs_clstate.c stable/11/sys/fs/nfsclient/nfs_clvfsops.c stable/11/sys/fs/nfsclient/nfs_clvnops.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/fs/nfs/nfs_commonkrpc.c ============================================================================== --- stable/11/sys/fs/nfs/nfs_commonkrpc.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfs/nfs_commonkrpc.c Fri Aug 25 22:39:49 2017 (r322907) @@ -509,7 +509,7 @@ newnfs_request(struct nfsrv_descript *nd, struct nfsmo 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); } @@ -1229,7 +1229,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); Modified: stable/11/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- stable/11/sys/fs/nfs/nfs_commonsubs.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfs/nfs_commonsubs.c Fri Aug 25 22:39:49 2017 (r322907) @@ -1866,7 +1866,7 @@ nfsv4_lock(struct nfsv4lock *lp, int iwantlock, int *i 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); } @@ -1920,7 +1920,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 @@ -1935,7 +1935,7 @@ nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void * 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) @@ -1943,7 +1943,7 @@ nfsv4_getref(struct nfsv4lock *lp, int *isleptp, void (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++; @@ -4215,9 +4215,7 @@ nfsv4_sequencelookup(struct nfsmount *nmp, struct nfsc * 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); } Modified: stable/11/sys/fs/nfs/nfscl.h ============================================================================== --- stable/11/sys/fs/nfs/nfscl.h Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfs/nfscl.h Fri Aug 25 22:39:49 2017 (r322907) @@ -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. Modified: stable/11/sys/fs/nfsclient/nfs_clbio.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clbio.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clbio.c Fri Aug 25 22:39:49 2017 (r322907) @@ -1342,7 +1342,7 @@ ncl_vinvalbuf(struct vnode *vp, int flags, struct thre 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; Modified: stable/11/sys/fs/nfsclient/nfs_clport.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clport.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clport.c Fri Aug 25 22:39:49 2017 (r322907) @@ -313,7 +313,7 @@ nfscl_ngetreopen(struct mount *mntp, u_int8_t *fhp, in *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, in * 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); Modified: stable/11/sys/fs/nfsclient/nfs_clstate.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clstate.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clstate.c Fri Aug 25 22:39:49 2017 (r322907) @@ -803,7 +803,7 @@ nfscl_getcl(struct mount *mp, struct ucred *cred, NFSP * 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, NFSP } 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, NFSP 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_ 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, 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); } Modified: stable/11/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clvfsops.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clvfsops.c Fri Aug 25 22:39:49 2017 (r322907) @@ -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); } Modified: stable/11/sys/fs/nfsclient/nfs_clvnops.c ============================================================================== --- stable/11/sys/fs/nfsclient/nfs_clvnops.c Fri Aug 25 22:38:55 2017 (r322906) +++ stable/11/sys/fs/nfsclient/nfs_clvnops.c Fri Aug 25 22:39:49 2017 (r322907) @@ -665,7 +665,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.