summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2014-11-07 15:44:03 +0000
committertrasz <trasz@FreeBSD.org>2014-11-07 15:44:03 +0000
commit603b73d3cc45737c0d3864cbc5d016ee07c2f3da (patch)
tree4ef07f0bb00c4206f300f7a472c5d17a7450c7aa /sys/fs
parentc03d95d34124cf0afe160b15ff8c0ba71f538d71 (diff)
downloadFreeBSD-src-603b73d3cc45737c0d3864cbc5d016ee07c2f3da.zip
FreeBSD-src-603b73d3cc45737c0d3864cbc5d016ee07c2f3da.tar.gz
MFC r272470:
Make autofs(4) use shared lock for lookups, instead of exclusive one. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/autofs/autofs.c4
-rw-r--r--sys/fs/autofs/autofs.h9
-rw-r--r--sys/fs/autofs/autofs_vfsops.c10
-rw-r--r--sys/fs/autofs/autofs_vnops.c24
4 files changed, 25 insertions, 22 deletions
diff --git a/sys/fs/autofs/autofs.c b/sys/fs/autofs/autofs.c
index 52461d3..f6838f9 100644
--- a/sys/fs/autofs/autofs.c
+++ b/sys/fs/autofs/autofs.c
@@ -297,9 +297,9 @@ autofs_cached(struct autofs_node *anp, const char *component, int componentlen)
* 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);
}
diff --git a/sys/fs/autofs/autofs.h b/sys/fs/autofs/autofs.h
index 89789fd..1298a46 100644
--- a/sys/fs/autofs/autofs.h
+++ b/sys/fs/autofs/autofs.h
@@ -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 {
diff --git a/sys/fs/autofs/autofs_vfsops.c b/sys/fs/autofs/autofs_vfsops.c
index fc2abc6..21a49d9 100644
--- a/sys/fs/autofs/autofs_vfsops.c
+++ b/sys/fs/autofs/autofs_vfsops.c
@@ -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, &amp->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 mntflags)
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 mntflags)
autofs_node_delete(amp->am_root);
mp->mnt_data = NULL;
- AUTOFS_UNLOCK(amp);
+ AUTOFS_XUNLOCK(amp);
sx_destroy(&amp->am_lock);
diff --git a/sys/fs/autofs/autofs_vnops.c b/sys/fs/autofs/autofs_vnops.c
index a37fca3..53490b3 100644
--- a/sys/fs/autofs/autofs_vnops.c
+++ b/sys/fs/autofs/autofs_vnops.c
@@ -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 *ap)
}
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 *ap)
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 *parent, struct autofs_mount *amp,
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 *anp)
{
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);
OpenPOWER on IntegriCloud