From 32f5faff694b30c7992181057e3028571f834d41 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 20 May 2010 14:20:34 -0700 Subject: Simplify rwlock implementation. Remove RW_COUNT() from the rwlock implementation. The idea was that it could be used as a generic wrapper for getting at the internal state of a rwlock. While a good idea it's proven problematic to keep it correct for multiple archs and internal implementation changes. In short it hasn't been worth the trouble. With that and simplicity in mind things have been updated to use the rwsem_is_locked() function instead of RW_COUNT for the RW_*_HELD() functions. As for rw_upgrade() it remains only implemented for the generic rwsem implemenation. It remains to be determined if its worth the effort of adding a custom implementation for each arch. --- module/splat/splat-rwlock.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'module') diff --git a/module/splat/splat-rwlock.c b/module/splat/splat-rwlock.c index 6b2ecbe82..dc560c2b9 100644 --- a/module/splat/splat-rwlock.c +++ b/module/splat/splat-rwlock.c @@ -571,7 +571,7 @@ static int splat_rwlock_test6(struct file *file, void *arg) { rw_priv_t *rwp; - int rc = -EINVAL; + int rc; rwp = (rw_priv_t *)kmalloc(sizeof(*rwp), GFP_KERNEL); if (rwp == NULL) @@ -584,15 +584,18 @@ splat_rwlock_test6(struct file *file, void *arg) splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, "rwlock should be read lock: %d\n", RW_READ_HELD(&rwp->rw_rwlock)); + rc = -ENOLCK; goto out; } - /* With one reader upgrade should never fail */ +#if defined(CONFIG_RWSEM_GENERIC_SPINLOCK) + /* With one reader upgrade should never fail. */ rc = rw_tryupgrade(&rwp->rw_rwlock); if (!rc) { splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, - "rwlock contended preventing upgrade: %ld\n", - (long int)RW_COUNT(&rwp->rw_rwlock)); + "rwlock failed upgrade from reader: %d\n", + RW_READ_HELD(&rwp->rw_rwlock)); + rc = -ENOLCK; goto out; } @@ -607,6 +610,11 @@ splat_rwlock_test6(struct file *file, void *arg) rc = 0; splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, "%s", "rwlock properly upgraded\n"); +#else + rc = 0; + splat_vprint(file, SPLAT_RWLOCK_TEST6_NAME, "%s", + "rw_tryupgrade() is disabled for this arch\n"); +#endif out: rw_exit(&rwp->rw_rwlock); rw_destroy(&rwp->rw_rwlock); -- cgit v1.2.3