Re: [patch 9/9] mutex subsystem, XFS namespace collision fixes

From: Christoph Hellwig
Date: Thu Dec 22 2005 - 06:59:55 EST


> -#define mutex_init(lock, type, name) sema_init(lock, 1)
> -#define mutex_destroy(lock) sema_init(lock, -99)
> -#define mutex_lock(lock, num) down(lock)
> -#define mutex_trylock(lock) (down_trylock(lock) ? 0 : 1)
> -#define mutex_unlock(lock) up(lock)
> +#define xfs_mutex_init(lock, type, name) sema_init(lock, 1)
> +#define xfs_mutex_destroy(lock) sema_init(lock, -99)
> +#define xfs_mutex_lock(lock, num) down(lock)
> +#define xfs_mutex_trylock(lock) (down_trylock(lock) ? 0 : 1)
> +#define xfs_mutex_unlock(lock) up(lock)

Again, this should really be using the mutex primitives (obviously ;-)).

The patch should become (pseudo-patch):

-typedef struct semaphore mutex_t
-
-#define mutex_init(lock, type, name) sema_init(lock, 1)
-#define mutex_destroy(lock) sema_init(lock, -99)
-#define mutex_lock(lock, num) down(lock)
-#define mutex_trylock(lock) (down_trylock(lock) ? 0 : 1)
-#define mutex_unlock(lock) up(lock)
+#define mutex_init(lock, type, name) mutex_init(lock)
+#define mutex_destroy(lock) do { } while (0)

While we're at it, maybe we should a mutex_destroy aswell? it would
be non-mandatory and allow that a lock is gone for the debugging variant.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/