diff options
Diffstat (limited to 'fs/xfs/xfs_log_priv.h')
-rw-r--r-- | fs/xfs/xfs_log_priv.h | 96 |
1 files changed, 38 insertions, 58 deletions
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 752f964b3699..e008233ee249 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
@@ -55,32 +55,21 @@ struct xfs_mount; | |||
55 | BTOBB(XLOG_MAX_ICLOGS << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \ | 55 | BTOBB(XLOG_MAX_ICLOGS << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \ |
56 | XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) | 56 | XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT)) |
57 | 57 | ||
58 | /* | ||
59 | * set lsns | ||
60 | */ | ||
61 | 58 | ||
62 | #define ASSIGN_ANY_LSN_HOST(lsn,cycle,block) \ | 59 | static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block) |
63 | { \ | 60 | { |
64 | (lsn) = ((xfs_lsn_t)(cycle)<<32)|(block); \ | 61 | return ((xfs_lsn_t)cycle << 32) | block; |
65 | } | 62 | } |
66 | #define ASSIGN_ANY_LSN_DISK(lsn,cycle,block) \ | ||
67 | { \ | ||
68 | INT_SET(((uint *)&(lsn))[0], ARCH_CONVERT, (cycle)); \ | ||
69 | INT_SET(((uint *)&(lsn))[1], ARCH_CONVERT, (block)); \ | ||
70 | } | ||
71 | #define ASSIGN_LSN(lsn,log) \ | ||
72 | ASSIGN_ANY_LSN_DISK(lsn,(log)->l_curr_cycle,(log)->l_curr_block); | ||
73 | |||
74 | #define XLOG_SET(f,b) (((f) & (b)) == (b)) | ||
75 | |||
76 | #define GET_CYCLE(ptr, arch) \ | ||
77 | (INT_GET(*(uint *)(ptr), arch) == XLOG_HEADER_MAGIC_NUM ? \ | ||
78 | INT_GET(*((uint *)(ptr)+1), arch) : \ | ||
79 | INT_GET(*(uint *)(ptr), arch) \ | ||
80 | ) | ||
81 | 63 | ||
82 | #define BLK_AVG(blk1, blk2) ((blk1+blk2) >> 1) | 64 | static inline uint xlog_get_cycle(char *ptr) |
65 | { | ||
66 | if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM) | ||
67 | return be32_to_cpu(*((__be32 *)ptr + 1)); | ||
68 | else | ||
69 | return be32_to_cpu(*(__be32 *)ptr); | ||
70 | } | ||
83 | 71 | ||
72 | #define BLK_AVG(blk1, blk2) ((blk1+blk2) >> 1) | ||
84 | 73 | ||
85 | #ifdef __KERNEL__ | 74 | #ifdef __KERNEL__ |
86 | 75 | ||
@@ -96,19 +85,10 @@ struct xfs_mount; | |||
96 | * | 85 | * |
97 | * this has endian issues, of course. | 86 | * this has endian issues, of course. |
98 | */ | 87 | */ |
99 | 88 | static inline uint xlog_get_client_id(__be32 i) | |
100 | #ifndef XFS_NATIVE_HOST | 89 | { |
101 | #define GET_CLIENT_ID(i,arch) \ | 90 | return be32_to_cpu(i) >> 24; |
102 | ((i) & 0xff) | 91 | } |
103 | #else | ||
104 | #define GET_CLIENT_ID(i,arch) \ | ||
105 | ((i) >> 24) | ||
106 | #endif | ||
107 | |||
108 | #define GRANT_LOCK(log) mutex_spinlock(&(log)->l_grant_lock) | ||
109 | #define GRANT_UNLOCK(log, s) mutex_spinunlock(&(log)->l_grant_lock, s) | ||
110 | #define LOG_LOCK(log) mutex_spinlock(&(log)->l_icloglock) | ||
111 | #define LOG_UNLOCK(log, s) mutex_spinunlock(&(log)->l_icloglock, s) | ||
112 | 92 | ||
113 | #define xlog_panic(args...) cmn_err(CE_PANIC, ## args) | 93 | #define xlog_panic(args...) cmn_err(CE_PANIC, ## args) |
114 | #define xlog_exit(args...) cmn_err(CE_PANIC, ## args) | 94 | #define xlog_exit(args...) cmn_err(CE_PANIC, ## args) |
@@ -285,11 +265,11 @@ typedef struct xlog_ticket { | |||
285 | 265 | ||
286 | 266 | ||
287 | typedef struct xlog_op_header { | 267 | typedef struct xlog_op_header { |
288 | xlog_tid_t oh_tid; /* transaction id of operation : 4 b */ | 268 | __be32 oh_tid; /* transaction id of operation : 4 b */ |
289 | int oh_len; /* bytes in data region : 4 b */ | 269 | __be32 oh_len; /* bytes in data region : 4 b */ |
290 | __uint8_t oh_clientid; /* who sent me this : 1 b */ | 270 | __u8 oh_clientid; /* who sent me this : 1 b */ |
291 | __uint8_t oh_flags; /* : 1 b */ | 271 | __u8 oh_flags; /* : 1 b */ |
292 | ushort oh_res2; /* 32 bit align : 2 b */ | 272 | __u16 oh_res2; /* 32 bit align : 2 b */ |
293 | } xlog_op_header_t; | 273 | } xlog_op_header_t; |
294 | 274 | ||
295 | 275 | ||
@@ -307,25 +287,25 @@ typedef struct xlog_op_header { | |||
307 | #endif | 287 | #endif |
308 | 288 | ||
309 | typedef struct xlog_rec_header { | 289 | typedef struct xlog_rec_header { |
310 | uint h_magicno; /* log record (LR) identifier : 4 */ | 290 | __be32 h_magicno; /* log record (LR) identifier : 4 */ |
311 | uint h_cycle; /* write cycle of log : 4 */ | 291 | __be32 h_cycle; /* write cycle of log : 4 */ |
312 | int h_version; /* LR version : 4 */ | 292 | __be32 h_version; /* LR version : 4 */ |
313 | int h_len; /* len in bytes; should be 64-bit aligned: 4 */ | 293 | __be32 h_len; /* len in bytes; should be 64-bit aligned: 4 */ |
314 | xfs_lsn_t h_lsn; /* lsn of this LR : 8 */ | 294 | __be64 h_lsn; /* lsn of this LR : 8 */ |
315 | xfs_lsn_t h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */ | 295 | __be64 h_tail_lsn; /* lsn of 1st LR w/ buffers not committed: 8 */ |
316 | uint h_chksum; /* may not be used; non-zero if used : 4 */ | 296 | __be32 h_chksum; /* may not be used; non-zero if used : 4 */ |
317 | int h_prev_block; /* block number to previous LR : 4 */ | 297 | __be32 h_prev_block; /* block number to previous LR : 4 */ |
318 | int h_num_logops; /* number of log operations in this LR : 4 */ | 298 | __be32 h_num_logops; /* number of log operations in this LR : 4 */ |
319 | uint h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; | 299 | __be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; |
320 | /* new fields */ | 300 | /* new fields */ |
321 | int h_fmt; /* format of log record : 4 */ | 301 | __be32 h_fmt; /* format of log record : 4 */ |
322 | uuid_t h_fs_uuid; /* uuid of FS : 16 */ | 302 | uuid_t h_fs_uuid; /* uuid of FS : 16 */ |
323 | int h_size; /* iclog size : 4 */ | 303 | __be32 h_size; /* iclog size : 4 */ |
324 | } xlog_rec_header_t; | 304 | } xlog_rec_header_t; |
325 | 305 | ||
326 | typedef struct xlog_rec_ext_header { | 306 | typedef struct xlog_rec_ext_header { |
327 | uint xh_cycle; /* write cycle of log : 4 */ | 307 | __be32 xh_cycle; /* write cycle of log : 4 */ |
328 | uint xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */ | 308 | __be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */ |
329 | } xlog_rec_ext_header_t; | 309 | } xlog_rec_ext_header_t; |
330 | 310 | ||
331 | #ifdef __KERNEL__ | 311 | #ifdef __KERNEL__ |
@@ -415,7 +395,7 @@ typedef struct log { | |||
415 | xlog_ticket_t *l_unmount_free;/* kmem_free these addresses */ | 395 | xlog_ticket_t *l_unmount_free;/* kmem_free these addresses */ |
416 | xlog_ticket_t *l_tail; /* free list of tickets */ | 396 | xlog_ticket_t *l_tail; /* free list of tickets */ |
417 | xlog_in_core_t *l_iclog; /* head log queue */ | 397 | xlog_in_core_t *l_iclog; /* head log queue */ |
418 | lock_t l_icloglock; /* grab to change iclog state */ | 398 | spinlock_t l_icloglock; /* grab to change iclog state */ |
419 | xfs_lsn_t l_tail_lsn; /* lsn of 1st LR with unflushed | 399 | xfs_lsn_t l_tail_lsn; /* lsn of 1st LR with unflushed |
420 | * buffers */ | 400 | * buffers */ |
421 | xfs_lsn_t l_last_sync_lsn;/* lsn of last LR on disk */ | 401 | xfs_lsn_t l_last_sync_lsn;/* lsn of last LR on disk */ |
@@ -439,7 +419,7 @@ typedef struct log { | |||
439 | char *l_iclog_bak[XLOG_MAX_ICLOGS]; | 419 | char *l_iclog_bak[XLOG_MAX_ICLOGS]; |
440 | 420 | ||
441 | /* The following block of fields are changed while holding grant_lock */ | 421 | /* The following block of fields are changed while holding grant_lock */ |
442 | lock_t l_grant_lock; | 422 | spinlock_t l_grant_lock; |
443 | xlog_ticket_t *l_reserve_headq; | 423 | xlog_ticket_t *l_reserve_headq; |
444 | xlog_ticket_t *l_write_headq; | 424 | xlog_ticket_t *l_write_headq; |
445 | int l_grant_reserve_cycle; | 425 | int l_grant_reserve_cycle; |