diff options
Diffstat (limited to 'fs/xfs/support')
-rw-r--r-- | fs/xfs/support/debug.c | 60 | ||||
-rw-r--r-- | fs/xfs/support/debug.h | 25 | ||||
-rw-r--r-- | fs/xfs/support/uuid.c | 29 |
3 files changed, 54 insertions, 60 deletions
diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c index bb6dc91ea261..b08b3d9345b7 100644 --- a/fs/xfs/support/debug.c +++ b/fs/xfs/support/debug.c | |||
@@ -27,45 +27,12 @@ static DEFINE_SPINLOCK(xfs_err_lock); | |||
27 | /* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */ | 27 | /* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */ |
28 | #define XFS_MAX_ERR_LEVEL 7 | 28 | #define XFS_MAX_ERR_LEVEL 7 |
29 | #define XFS_ERR_MASK ((1 << 3) - 1) | 29 | #define XFS_ERR_MASK ((1 << 3) - 1) |
30 | static char *err_level[XFS_MAX_ERR_LEVEL+1] = | 30 | static const char * const err_level[XFS_MAX_ERR_LEVEL+1] = |
31 | {KERN_EMERG, KERN_ALERT, KERN_CRIT, | 31 | {KERN_EMERG, KERN_ALERT, KERN_CRIT, |
32 | KERN_ERR, KERN_WARNING, KERN_NOTICE, | 32 | KERN_ERR, KERN_WARNING, KERN_NOTICE, |
33 | KERN_INFO, KERN_DEBUG}; | 33 | KERN_INFO, KERN_DEBUG}; |
34 | 34 | ||
35 | void | 35 | void |
36 | assfail(char *a, char *f, int l) | ||
37 | { | ||
38 | printk("XFS assertion failed: %s, file: %s, line: %d\n", a, f, l); | ||
39 | BUG(); | ||
40 | } | ||
41 | |||
42 | #if ((defined(DEBUG) || defined(INDUCE_IO_ERRROR)) && !defined(NO_WANT_RANDOM)) | ||
43 | |||
44 | unsigned long | ||
45 | random(void) | ||
46 | { | ||
47 | static unsigned long RandomValue = 1; | ||
48 | /* cycles pseudo-randomly through all values between 1 and 2^31 - 2 */ | ||
49 | register long rv = RandomValue; | ||
50 | register long lo; | ||
51 | register long hi; | ||
52 | |||
53 | hi = rv / 127773; | ||
54 | lo = rv % 127773; | ||
55 | rv = 16807 * lo - 2836 * hi; | ||
56 | if( rv <= 0 ) rv += 2147483647; | ||
57 | return( RandomValue = rv ); | ||
58 | } | ||
59 | |||
60 | int | ||
61 | get_thread_id(void) | ||
62 | { | ||
63 | return current->pid; | ||
64 | } | ||
65 | |||
66 | #endif /* DEBUG || INDUCE_IO_ERRROR || !NO_WANT_RANDOM */ | ||
67 | |||
68 | void | ||
69 | cmn_err(register int level, char *fmt, ...) | 36 | cmn_err(register int level, char *fmt, ...) |
70 | { | 37 | { |
71 | char *fp = fmt; | 38 | char *fp = fmt; |
@@ -90,7 +57,6 @@ cmn_err(register int level, char *fmt, ...) | |||
90 | BUG(); | 57 | BUG(); |
91 | } | 58 | } |
92 | 59 | ||
93 | |||
94 | void | 60 | void |
95 | icmn_err(register int level, char *fmt, va_list ap) | 61 | icmn_err(register int level, char *fmt, va_list ap) |
96 | { | 62 | { |
@@ -109,3 +75,27 @@ icmn_err(register int level, char *fmt, va_list ap) | |||
109 | if (level == CE_PANIC) | 75 | if (level == CE_PANIC) |
110 | BUG(); | 76 | BUG(); |
111 | } | 77 | } |
78 | |||
79 | void | ||
80 | assfail(char *expr, char *file, int line) | ||
81 | { | ||
82 | printk("Assertion failed: %s, file: %s, line: %d\n", expr, file, line); | ||
83 | BUG(); | ||
84 | } | ||
85 | |||
86 | #if ((defined(DEBUG) || defined(INDUCE_IO_ERRROR)) && !defined(NO_WANT_RANDOM)) | ||
87 | unsigned long random(void) | ||
88 | { | ||
89 | static unsigned long RandomValue = 1; | ||
90 | /* cycles pseudo-randomly through all values between 1 and 2^31 - 2 */ | ||
91 | register long rv = RandomValue; | ||
92 | register long lo; | ||
93 | register long hi; | ||
94 | |||
95 | hi = rv / 127773; | ||
96 | lo = rv % 127773; | ||
97 | rv = 16807 * lo - 2836 * hi; | ||
98 | if (rv <= 0) rv += 2147483647; | ||
99 | return RandomValue = rv; | ||
100 | } | ||
101 | #endif /* DEBUG || INDUCE_IO_ERRROR || !NO_WANT_RANDOM */ | ||
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h index aff558664c32..e3bf58112e7e 100644 --- a/fs/xfs/support/debug.h +++ b/fs/xfs/support/debug.h | |||
@@ -31,24 +31,23 @@ extern void icmn_err(int, char *, va_list) | |||
31 | __attribute__ ((format (printf, 2, 0))); | 31 | __attribute__ ((format (printf, 2, 0))); |
32 | extern void cmn_err(int, char *, ...) | 32 | extern void cmn_err(int, char *, ...) |
33 | __attribute__ ((format (printf, 2, 3))); | 33 | __attribute__ ((format (printf, 2, 3))); |
34 | extern void assfail(char *expr, char *f, int l); | ||
34 | 35 | ||
35 | #ifndef STATIC | 36 | #define prdev(fmt,targ,args...) \ |
36 | # define STATIC static | 37 | printk("Device %s - " fmt "\n", XFS_BUFTARG_NAME(targ), ## args) |
37 | #endif | ||
38 | 38 | ||
39 | #ifdef DEBUG | 39 | #define ASSERT_ALWAYS(expr) \ |
40 | # define ASSERT(EX) ((EX) ? ((void)0) : assfail(#EX, __FILE__, __LINE__)) | 40 | (unlikely((expr) != 0) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) |
41 | #else | ||
42 | # define ASSERT(x) ((void)0) | ||
43 | #endif | ||
44 | 41 | ||
45 | extern void assfail(char *, char *, int); | 42 | #ifndef DEBUG |
46 | #ifdef DEBUG | 43 | # define ASSERT(expr) ((void)0) |
44 | #else | ||
45 | # define ASSERT(expr) ASSERT_ALWAYS(expr) | ||
47 | extern unsigned long random(void); | 46 | extern unsigned long random(void); |
48 | extern int get_thread_id(void); | ||
49 | #endif | 47 | #endif |
50 | 48 | ||
51 | #define ASSERT_ALWAYS(EX) ((EX)?((void)0):assfail(#EX, __FILE__, __LINE__)) | 49 | #ifndef STATIC |
52 | #define debug_stop_all_cpus(param) /* param is "cpumask_t *" */ | 50 | # define STATIC static |
51 | #endif | ||
53 | 52 | ||
54 | #endif /* __XFS_SUPPORT_DEBUG_H__ */ | 53 | #endif /* __XFS_SUPPORT_DEBUG_H__ */ |
diff --git a/fs/xfs/support/uuid.c b/fs/xfs/support/uuid.c index 70ce40914c8a..a3d565a67734 100644 --- a/fs/xfs/support/uuid.c +++ b/fs/xfs/support/uuid.c | |||
@@ -24,9 +24,19 @@ static uuid_t *uuid_table; | |||
24 | void | 24 | void |
25 | uuid_init(void) | 25 | uuid_init(void) |
26 | { | 26 | { |
27 | mutex_init(&uuid_monitor, MUTEX_DEFAULT, "uuid_monitor"); | 27 | mutex_init(&uuid_monitor); |
28 | } | 28 | } |
29 | 29 | ||
30 | |||
31 | /* IRIX interpretation of an uuid_t */ | ||
32 | typedef struct { | ||
33 | __be32 uu_timelow; | ||
34 | __be16 uu_timemid; | ||
35 | __be16 uu_timehi; | ||
36 | __be16 uu_clockseq; | ||
37 | __be16 uu_node[3]; | ||
38 | } xfs_uu_t; | ||
39 | |||
30 | /* | 40 | /* |
31 | * uuid_getnodeuniq - obtain the node unique fields of a UUID. | 41 | * uuid_getnodeuniq - obtain the node unique fields of a UUID. |
32 | * | 42 | * |
@@ -36,16 +46,11 @@ uuid_init(void) | |||
36 | void | 46 | void |
37 | uuid_getnodeuniq(uuid_t *uuid, int fsid [2]) | 47 | uuid_getnodeuniq(uuid_t *uuid, int fsid [2]) |
38 | { | 48 | { |
39 | char *uu = (char *)uuid; | 49 | xfs_uu_t *uup = (xfs_uu_t *)uuid; |
40 | |||
41 | /* on IRIX, this function assumes big-endian fields within | ||
42 | * the uuid, so we use INT_GET to get the same result on | ||
43 | * little-endian systems | ||
44 | */ | ||
45 | 50 | ||
46 | fsid[0] = (INT_GET(*(u_int16_t*)(uu+8), ARCH_CONVERT) << 16) + | 51 | fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) | |
47 | INT_GET(*(u_int16_t*)(uu+4), ARCH_CONVERT); | 52 | be16_to_cpu(uup->uu_timemid); |
48 | fsid[1] = INT_GET(*(u_int32_t*)(uu ), ARCH_CONVERT); | 53 | fsid[1] = be16_to_cpu(uup->uu_timelow); |
49 | } | 54 | } |
50 | 55 | ||
51 | void | 56 | void |
@@ -94,7 +99,7 @@ uuid_table_insert(uuid_t *uuid) | |||
94 | { | 99 | { |
95 | int i, hole; | 100 | int i, hole; |
96 | 101 | ||
97 | mutex_lock(&uuid_monitor, PVFS); | 102 | mutex_lock(&uuid_monitor); |
98 | for (i = 0, hole = -1; i < uuid_table_size; i++) { | 103 | for (i = 0, hole = -1; i < uuid_table_size; i++) { |
99 | if (uuid_is_nil(&uuid_table[i])) { | 104 | if (uuid_is_nil(&uuid_table[i])) { |
100 | hole = i; | 105 | hole = i; |
@@ -122,7 +127,7 @@ uuid_table_remove(uuid_t *uuid) | |||
122 | { | 127 | { |
123 | int i; | 128 | int i; |
124 | 129 | ||
125 | mutex_lock(&uuid_monitor, PVFS); | 130 | mutex_lock(&uuid_monitor); |
126 | for (i = 0; i < uuid_table_size; i++) { | 131 | for (i = 0; i < uuid_table_size; i++) { |
127 | if (uuid_is_nil(&uuid_table[i])) | 132 | if (uuid_is_nil(&uuid_table[i])) |
128 | continue; | 133 | continue; |