summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2008-03-04 12:50:11 +0000
committerrwatson <rwatson@FreeBSD.org>2008-03-04 12:50:11 +0000
commit48aef5a3f0488868236b4046cf4edbc2f92bfa4f (patch)
treed5f648025f79b92ab9ffa4af9b90880996bc44f6 /sys/ufs
parent96767d90908e8c37f547057a4ead0eae2959d8dc (diff)
downloadFreeBSD-src-48aef5a3f0488868236b4046cf4edbc2f92bfa4f.zip
FreeBSD-src-48aef5a3f0488868236b4046cf4edbc2f92bfa4f.tar.gz
Continue on-going campaign to replace lockmgr locks with sx locks where
the specific semantics of ockmgr aren't required: update UFS1 extended attributes to protect its data structures using an sx lock. While here, update comments on lock granularity. MFC after: 2 weeks
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ufs/extattr.h5
-rw-r--r--sys/ufs/ufs/ufs_extattr.c21
2 files changed, 14 insertions, 12 deletions
diff --git a/sys/ufs/ufs/extattr.h b/sys/ufs/ufs/extattr.h
index c1ceee5..5d26bf6 100644
--- a/sys/ufs/ufs/extattr.h
+++ b/sys/ufs/ufs/extattr.h
@@ -113,6 +113,8 @@ struct extattr {
#ifdef _KERNEL
+#include <sys/_sx.h>
+
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_EXTATTR);
#endif
@@ -127,10 +129,9 @@ struct ufs_extattr_list_entry {
struct vnode *uele_backing_vnode;
};
-struct lock;
struct ucred;
struct ufs_extattr_per_mount {
- struct lock uepm_lock;
+ struct sx uepm_lock;
struct ufs_extattr_list_head uepm_list;
struct ucred *uepm_ucred;
int uepm_flags;
diff --git a/sys/ufs/ufs/ufs_extattr.c b/sys/ufs/ufs/ufs_extattr.c
index 0c50351..dcfd7d9 100644
--- a/sys/ufs/ufs/ufs_extattr.c
+++ b/sys/ufs/ufs/ufs_extattr.c
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/dirent.h>
#include <sys/extattr.h>
+#include <sys/sx.h>
#include <sys/sysctl.h>
#include <vm/uma.h>
@@ -95,23 +96,23 @@ static int ufs_extattr_rm(struct vnode *vp, int attrnamespace,
/*
* Per-FS attribute lock protecting attribute operations.
- * XXX Right now there is a lot of lock contention due to having a single
- * lock per-FS; really, this should be far more fine-grained.
+ *
+ * XXXRW: Perhaps something more fine-grained would be appropriate, but at
+ * the end of the day we're going to contend on the vnode lock for the
+ * backing file anyway.
*/
static void
ufs_extattr_uepm_lock(struct ufsmount *ump, struct thread *td)
{
- /* Ideally, LK_CANRECURSE would not be used, here. */
- lockmgr(&ump->um_extattr.uepm_lock, LK_EXCLUSIVE | LK_RETRY |
- LK_CANRECURSE, 0);
+ sx_xlock(&ump->um_extattr.uepm_lock);
}
static void
ufs_extattr_uepm_unlock(struct ufsmount *ump, struct thread *td)
{
- lockmgr(&ump->um_extattr.uepm_lock, LK_RELEASE, 0);
+ sx_xunlock(&ump->um_extattr.uepm_lock);
}
/*-
@@ -143,6 +144,8 @@ ufs_extattr_find_attr(struct ufsmount *ump, int attrnamespace,
{
struct ufs_extattr_list_entry *search_attribute;
+ sx_assert(&ump->um_extattr.uepm_lock, SA_XLOCKED);
+
for (search_attribute = LIST_FIRST(&ump->um_extattr.uepm_list);
search_attribute != NULL;
search_attribute = LIST_NEXT(search_attribute, uele_entries)) {
@@ -165,10 +168,8 @@ ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm)
{
uepm->uepm_flags = 0;
-
LIST_INIT(&uepm->uepm_list);
- /* XXX is PVFS right, here? */
- lockinit(&uepm->uepm_lock, PVFS, "extattr", 0, 0);
+ sx_init(&uepm->uepm_lock, "ufs_extattr_sx");
uepm->uepm_flags |= UFS_EXTATTR_UEPM_INITIALIZED;
}
@@ -192,7 +193,7 @@ ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm)
* during unmount, and with vfs_busy().
*/
uepm->uepm_flags &= ~UFS_EXTATTR_UEPM_INITIALIZED;
- lockdestroy(&uepm->uepm_lock);
+ sx_destroy(&uepm->uepm_lock);
}
/*
OpenPOWER on IntegriCloud