summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-11-04 18:56:12 +0000
committerjhb <jhb@FreeBSD.org>2008-11-04 18:56:12 +0000
commit9f264a6a75c77b629a7483254b17b870d9d292a8 (patch)
tree6751e79ac4a09b667fe441abe42d8faa25a0465f /sys/ufs
parent5af731a4af426e3560bdee4d0f855b488a04013c (diff)
downloadFreeBSD-src-9f264a6a75c77b629a7483254b17b870d9d292a8.zip
FreeBSD-src-9f264a6a75c77b629a7483254b17b870d9d292a8.tar.gz
Quiet a WITNESS warning with the dirhash sx locks by setting the DUPOK
flag. Specifically, if two threads race to create a dirhash for a directory, then one might already have created a private dirhash structure (and locked it) when it realizes the directory now has a structure and tries to lock that one.
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/ufs/ufs_dirhash.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/ufs/ufs/ufs_dirhash.c b/sys/ufs/ufs/ufs_dirhash.c
index cabb09c..05bf840 100644
--- a/sys/ufs/ufs/ufs_dirhash.c
+++ b/sys/ufs/ufs/ufs_dirhash.c
@@ -181,7 +181,16 @@ ufsdirhash_create(struct inode *ip)
if (ndh == NULL)
return (NULL);
refcount_init(&ndh->dh_refcount, 1);
- sx_init(&ndh->dh_lock, "dirhash");
+
+ /*
+ * The DUPOK is to prevent warnings from the
+ * sx_slock() a few lines down which is safe
+ * since the duplicate lock in that case is
+ * the one for this dirhash we are creating
+ * now which has no external references until
+ * after this function returns.
+ */
+ sx_init_flags(&ndh->dh_lock, "dirhash", SX_DUPOK);
sx_xlock(&ndh->dh_lock);
}
/*
OpenPOWER on IntegriCloud