From owner-svn-src-all@FreeBSD.ORG Fri Oct 3 09:58:07 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9E1212A3; Fri, 3 Oct 2014 09:58:07 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 7E4A5348; Fri, 3 Oct 2014 09:58:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s939w7qp070194; Fri, 3 Oct 2014 09:58:07 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s939w6D8070190; Fri, 3 Oct 2014 09:58:06 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201410030958.s939w6D8070190@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Fri, 3 Oct 2014 09:58:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272470 - head/sys/fs/autofs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Oct 2014 09:58:07 -0000 Author: trasz Date: Fri Oct 3 09:58:05 2014 New Revision: 272470 URL: https://svnweb.freebsd.org/changeset/base/272470 Log: Make autofs(4) use shared lock for lookups, instead of exclusive one. MFC after: 1 month Sponsored by: The FreeBSD Foundation Modified: head/sys/fs/autofs/autofs.c head/sys/fs/autofs/autofs.h head/sys/fs/autofs/autofs_vfsops.c head/sys/fs/autofs/autofs_vnops.c Modified: head/sys/fs/autofs/autofs.c ============================================================================== --- head/sys/fs/autofs/autofs.c Fri Oct 3 08:46:49 2014 (r272469) +++ head/sys/fs/autofs/autofs.c Fri Oct 3 09:58:05 2014 (r272470) @@ -297,9 +297,9 @@ autofs_cached(struct autofs_node *anp, c * is necessary for wildcard indirect map keys to work. */ if (anp->an_parent == NULL && componentlen != 0) { - AUTOFS_LOCK(amp); + AUTOFS_SLOCK(amp); error = autofs_node_find(anp, component, componentlen, NULL); - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); if (error != 0) return (false); } Modified: head/sys/fs/autofs/autofs.h ============================================================================== --- head/sys/fs/autofs/autofs.h Fri Oct 3 08:46:49 2014 (r272469) +++ head/sys/fs/autofs/autofs.h Fri Oct 3 09:58:05 2014 (r272470) @@ -53,9 +53,12 @@ extern int autofs_mount_on_stat; __func__, ## __VA_ARGS__); \ } while (0) -#define AUTOFS_LOCK(X) sx_xlock(&X->am_lock) -#define AUTOFS_UNLOCK(X) sx_xunlock(&X->am_lock) -#define AUTOFS_ASSERT_LOCKED(X) sx_assert(&X->am_lock, SA_XLOCKED) +#define AUTOFS_SLOCK(X) sx_slock(&X->am_lock) +#define AUTOFS_XLOCK(X) sx_xlock(&X->am_lock) +#define AUTOFS_SUNLOCK(X) sx_sunlock(&X->am_lock) +#define AUTOFS_XUNLOCK(X) sx_xunlock(&X->am_lock) +#define AUTOFS_ASSERT_LOCKED(X) sx_assert(&X->am_lock, SA_LOCKED) +#define AUTOFS_ASSERT_XLOCKED(X) sx_assert(&X->am_lock, SA_XLOCKED) #define AUTOFS_ASSERT_UNLOCKED(X) sx_assert(&X->am_lock, SA_UNLOCKED) struct autofs_node { Modified: head/sys/fs/autofs/autofs_vfsops.c ============================================================================== --- head/sys/fs/autofs/autofs_vfsops.c Fri Oct 3 08:46:49 2014 (r272469) +++ head/sys/fs/autofs/autofs_vfsops.c Fri Oct 3 09:58:05 2014 (r272470) @@ -88,14 +88,14 @@ autofs_mount(struct mount *mp) vfs_getnewfsid(mp); - AUTOFS_LOCK(amp); + AUTOFS_XLOCK(amp); error = autofs_node_new(NULL, amp, ".", -1, &->am_root); if (error != 0) { - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); free(amp, M_AUTOFS); return (error); } - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); vfs_mountedfrom(mp, from); @@ -146,7 +146,7 @@ autofs_unmount(struct mount *mp, int mnt pause("autofs_umount", 1); } - AUTOFS_LOCK(amp); + AUTOFS_XLOCK(amp); /* * Not terribly efficient, but at least not recursive. @@ -160,7 +160,7 @@ autofs_unmount(struct mount *mp, int mnt autofs_node_delete(amp->am_root); mp->mnt_data = NULL; - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); sx_destroy(&->am_lock); Modified: head/sys/fs/autofs/autofs_vnops.c ============================================================================== --- head/sys/fs/autofs/autofs_vnops.c Fri Oct 3 08:46:49 2014 (r272469) +++ head/sys/fs/autofs/autofs_vnops.c Fri Oct 3 09:58:05 2014 (r272470) @@ -277,22 +277,22 @@ autofs_lookup(struct vop_lookup_args *ap } } - AUTOFS_LOCK(amp); + AUTOFS_SLOCK(amp); error = autofs_node_find(anp, cnp->cn_nameptr, cnp->cn_namelen, &child); if (error != 0) { if ((cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == CREATE) { - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); return (EJUSTRETURN); } - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); return (ENOENT); } /* * XXX: Dropping the node here is ok, because we never remove nodes. */ - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); error = autofs_node_vn(child, mp, vpp); if (error != 0) { @@ -325,14 +325,14 @@ autofs_mkdir(struct vop_mkdir_args *ap) if (autofs_ignore_thread(curthread) == false) return (EPERM); - AUTOFS_LOCK(amp); + AUTOFS_XLOCK(amp); error = autofs_node_new(anp, amp, ap->a_cnp->cn_nameptr, ap->a_cnp->cn_namelen, &child); if (error != 0) { - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); return (error); } - AUTOFS_UNLOCK(amp); + AUTOFS_XUNLOCK(amp); error = autofs_node_vn(child, vp->v_mount, ap->a_vpp); @@ -427,7 +427,7 @@ autofs_readdir(struct vop_readdir_args * } i = 2; /* Account for "." and "..". */ - AUTOFS_LOCK(amp); + AUTOFS_SLOCK(amp); TAILQ_FOREACH(child, &anp->an_children, an_next) { if (resid < AUTOFS_DELEN) { if (ap->a_eofflag != NULL) @@ -445,14 +445,14 @@ autofs_readdir(struct vop_readdir_args * error = autofs_readdir_one(uio, child->an_name, child->an_fileno); if (error != 0) { - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); return (error); } offset += AUTOFS_DELEN; resid -= AUTOFS_DELEN; } - AUTOFS_UNLOCK(amp); + AUTOFS_SUNLOCK(amp); return (0); } @@ -505,7 +505,7 @@ autofs_node_new(struct autofs_node *pare struct autofs_node *anp; if (parent != NULL) - AUTOFS_ASSERT_LOCKED(parent->an_mount); + AUTOFS_ASSERT_XLOCKED(parent->an_mount); anp = uma_zalloc(autofs_node_zone, M_WAITOK | M_ZERO); if (namelen >= 0) @@ -567,7 +567,7 @@ autofs_node_delete(struct autofs_node *a { struct autofs_node *parent; - AUTOFS_ASSERT_LOCKED(anp->an_mount); + AUTOFS_ASSERT_XLOCKED(anp->an_mount); KASSERT(TAILQ_EMPTY(&anp->an_children), ("have children")); callout_drain(&anp->an_callout);