Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jul 2016 02:34:05 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r302421 - stable/10/sys/fs/nfsclient
Message-ID:  <201607080234.u682Y5cg051892@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Jul  8 02:34:04 2016
New Revision: 302421
URL: https://svnweb.freebsd.org/changeset/base/302421

Log:
  MFC r302196
  Since VOP_INACTIVE() is not guaranteed to be called, all cleanups
  executed by inactive methods, must be repeated on reclaim.
  
  MFC r302210:
  Clean other flags in ncl_inactive, only.

Modified:
  stable/10/sys/fs/nfsclient/nfs_clnode.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/nfsclient/nfs_clnode.c
==============================================================================
--- stable/10/sys/fs/nfsclient/nfs_clnode.c	Fri Jul  8 02:19:09 2016	(r302420)
+++ stable/10/sys/fs/nfsclient/nfs_clnode.c	Fri Jul  8 02:34:04 2016	(r302421)
@@ -200,15 +200,40 @@ nfs_freesillyrename(void *arg, __unused 
 	free(sp, M_NEWNFSREQ);
 }
 
-int
-ncl_inactive(struct vop_inactive_args *ap)
+static void
+ncl_releasesillyrename(struct vnode *vp, struct thread *td)
 {
 	struct nfsnode *np;
 	struct sillyrename *sp;
-	struct vnode *vp = ap->a_vp;
-	boolean_t retv;
 
+	ASSERT_VOP_ELOCKED(vp, "releasesillyrename");
 	np = VTONFS(vp);
+	mtx_assert(&np->n_mtx, MA_OWNED);
+	if (vp->v_type != VDIR) {
+		sp = np->n_sillyrename;
+		np->n_sillyrename = NULL;
+	} else
+		sp = NULL;
+	if (sp != NULL) {
+		mtx_unlock(&np->n_mtx);
+		(void) ncl_vinvalbuf(vp, 0, td, 1);
+		/*
+		 * Remove the silly file that was rename'd earlier
+		 */
+		ncl_removeit(sp, vp);
+		crfree(sp->s_cred);
+		TASK_INIT(&sp->s_task, 0, nfs_freesillyrename, sp);
+		taskqueue_enqueue(taskqueue_thread, &sp->s_task);
+		mtx_lock(&np->n_mtx);
+	}
+}
+
+int
+ncl_inactive(struct vop_inactive_args *ap)
+{
+	struct vnode *vp = ap->a_vp;
+	struct nfsnode *np;
+	boolean_t retv;
 
 	if (NFS_ISV4(vp) && vp->v_type == VREG) {
 		/*
@@ -230,24 +255,15 @@ ncl_inactive(struct vop_inactive_args *a
 		}
 	}
 
+	np = VTONFS(vp);
 	mtx_lock(&np->n_mtx);
-	if (vp->v_type != VDIR) {
-		sp = np->n_sillyrename;
-		np->n_sillyrename = NULL;
-	} else
-		sp = NULL;
-	if (sp) {
-		mtx_unlock(&np->n_mtx);
-		(void) ncl_vinvalbuf(vp, 0, ap->a_td, 1);
-		/*
-		 * Remove the silly file that was rename'd earlier
-		 */
-		ncl_removeit(sp, vp);
-		crfree(sp->s_cred);
-		TASK_INIT(&sp->s_task, 0, nfs_freesillyrename, sp);
-		taskqueue_enqueue(taskqueue_thread, &sp->s_task);
-		mtx_lock(&np->n_mtx);
-	}
+	ncl_releasesillyrename(vp, ap->a_td);
+
+	/*
+	 * NMODIFIED means that there might be dirty/stale buffers
+	 * associated with the NFS vnode.  None of the other flags are
+	 * meaningful after the vnode is unused.
+	 */
 	np->n_flag &= NMODIFIED;
 	mtx_unlock(&np->n_mtx);
 	return (0);
@@ -270,6 +286,10 @@ ncl_reclaim(struct vop_reclaim_args *ap)
 	if (nfs_reclaim_p != NULL)
 		nfs_reclaim_p(ap);
 
+	mtx_lock(&np->n_mtx);
+	ncl_releasesillyrename(vp, ap->a_td);
+	mtx_unlock(&np->n_mtx);
+
 	/*
 	 * Destroy the vm object and flush associated pages.
 	 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607080234.u682Y5cg051892>