Use tab indent in rwlock.h

Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #473
This commit is contained in:
Chunwei Chen 2015-09-02 00:02:55 +08:00 committed by Brian Behlendorf
parent a00b3eb58f
commit 374303a3c9
1 changed files with 73 additions and 73 deletions

View File

@ -30,14 +30,14 @@
#include <linux/rwsem_compat.h> #include <linux/rwsem_compat.h>
typedef enum { typedef enum {
RW_DRIVER = 2, RW_DRIVER = 2,
RW_DEFAULT = 4 RW_DEFAULT = 4
} krw_type_t; } krw_type_t;
typedef enum { typedef enum {
RW_NONE = 0, RW_NONE = 0,
RW_WRITER = 1, RW_WRITER = 1,
RW_READER = 2 RW_READER = 2
} krw_t; } krw_t;
/* /*
@ -45,9 +45,9 @@ typedef enum {
* field, so we don't need our own. * field, so we don't need our own.
*/ */
typedef struct { typedef struct {
struct rw_semaphore rw_rwlock; struct rw_semaphore rw_rwlock;
#ifndef CONFIG_RWSEM_SPIN_ON_OWNER #ifndef CONFIG_RWSEM_SPIN_ON_OWNER
kthread_t *rw_owner; kthread_t *rw_owner;
#endif #endif
} krwlock_t; } krwlock_t;
@ -107,67 +107,67 @@ RW_LOCK_HELD(krwlock_t *rwp)
* will be correctly located in the users code which is important * will be correctly located in the users code which is important
* for the built in kernel lock analysis tools * for the built in kernel lock analysis tools
*/ */
#define rw_init(rwp, name, type, arg) \ #define rw_init(rwp, name, type, arg) \
({ \ ({ \
static struct lock_class_key __key; \ static struct lock_class_key __key; \
\ \
__init_rwsem(SEM(rwp), #rwp, &__key); \ __init_rwsem(SEM(rwp), #rwp, &__key); \
spl_rw_clear_owner(rwp); \ spl_rw_clear_owner(rwp); \
}) })
#define rw_destroy(rwp) \ #define rw_destroy(rwp) \
({ \ ({ \
VERIFY(!RW_LOCK_HELD(rwp)); \ VERIFY(!RW_LOCK_HELD(rwp)); \
}) })
#define rw_tryenter(rwp, rw) \ #define rw_tryenter(rwp, rw) \
({ \ ({ \
int _rc_ = 0; \ int _rc_ = 0; \
\ \
switch (rw) { \ switch (rw) { \
case RW_READER: \ case RW_READER: \
_rc_ = down_read_trylock(SEM(rwp)); \ _rc_ = down_read_trylock(SEM(rwp)); \
break; \ break; \
case RW_WRITER: \ case RW_WRITER: \
if ((_rc_ = down_write_trylock(SEM(rwp)))) \ if ((_rc_ = down_write_trylock(SEM(rwp)))) \
spl_rw_set_owner(rwp); \ spl_rw_set_owner(rwp); \
break; \ break; \
default: \ default: \
VERIFY(0); \ VERIFY(0); \
} \ } \
_rc_; \ _rc_; \
}) })
#define rw_enter(rwp, rw) \ #define rw_enter(rwp, rw) \
({ \ ({ \
switch (rw) { \ switch (rw) { \
case RW_READER: \ case RW_READER: \
down_read(SEM(rwp)); \ down_read(SEM(rwp)); \
break; \ break; \
case RW_WRITER: \ case RW_WRITER: \
down_write(SEM(rwp)); \ down_write(SEM(rwp)); \
spl_rw_set_owner(rwp); \ spl_rw_set_owner(rwp); \
break; \ break; \
default: \ default: \
VERIFY(0); \ VERIFY(0); \
} \ } \
}) })
#define rw_exit(rwp) \ #define rw_exit(rwp) \
({ \ ({ \
if (RW_WRITE_HELD(rwp)) { \ if (RW_WRITE_HELD(rwp)) { \
spl_rw_clear_owner(rwp); \ spl_rw_clear_owner(rwp); \
up_write(SEM(rwp)); \ up_write(SEM(rwp)); \
} else { \ } else { \
ASSERT(RW_READ_HELD(rwp)); \ ASSERT(RW_READ_HELD(rwp)); \
up_read(SEM(rwp)); \ up_read(SEM(rwp)); \
} \ } \
}) })
#define rw_downgrade(rwp) \ #define rw_downgrade(rwp) \
({ \ ({ \
spl_rw_clear_owner(rwp); \ spl_rw_clear_owner(rwp); \
downgrade_write(SEM(rwp)); \ downgrade_write(SEM(rwp)); \
}) })
#if defined(CONFIG_RWSEM_GENERIC_SPINLOCK) #if defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
@ -186,20 +186,20 @@ RW_LOCK_HELD(krwlock_t *rwp)
extern void __up_read_locked(struct rw_semaphore *); extern void __up_read_locked(struct rw_semaphore *);
extern int __down_write_trylock_locked(struct rw_semaphore *); extern int __down_write_trylock_locked(struct rw_semaphore *);
#define rw_tryupgrade(rwp) \ #define rw_tryupgrade(rwp) \
({ \ ({ \
unsigned long _flags_; \ unsigned long _flags_; \
int _rc_ = 0; \ int _rc_ = 0; \
\ \
spl_rwsem_lock_irqsave(&SEM(rwp)->wait_lock, _flags_); \ spl_rwsem_lock_irqsave(&SEM(rwp)->wait_lock, _flags_); \
if ((list_empty(&SEM(rwp)->wait_list)) && \ if ((list_empty(&SEM(rwp)->wait_list)) && \
(SEM(rwp)->activity == 1)) { \ (SEM(rwp)->activity == 1)) { \
__up_read_locked(SEM(rwp)); \ __up_read_locked(SEM(rwp)); \
VERIFY(_rc_ = __down_write_trylock_locked(SEM(rwp))); \ VERIFY(_rc_ = __down_write_trylock_locked(SEM(rwp))); \
(rwp)->rw_owner = current; \ (rwp)->rw_owner = current; \
} \ } \
spl_rwsem_unlock_irqrestore(&SEM(rwp)->wait_lock, _flags_); \ spl_rwsem_unlock_irqrestore(&SEM(rwp)->wait_lock, _flags_); \
_rc_; \ _rc_; \
}) })
#else #else
/* /*
@ -209,7 +209,7 @@ extern int __down_write_trylock_locked(struct rw_semaphore *);
* rwsem would be safe. For now that's not worth the trouble so in this * rwsem would be safe. For now that's not worth the trouble so in this
* case rw_tryupgrade() has just been disabled. * case rw_tryupgrade() has just been disabled.
*/ */
#define rw_tryupgrade(rwp) ({ 0; }) #define rw_tryupgrade(rwp) ({ 0; })
#endif #endif
int spl_rw_init(void); int spl_rw_init(void);