Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[sfrench/cifs-2.6.git] / fs / xfs / xfs_log_priv.h
index 9bd3cdf11a87068db1b773b5afabb2ea0a5bc913..e008233ee2492dd4b7c96f76ccaafc372b32201e 100644 (file)
@@ -30,17 +30,16 @@ struct xfs_mount;
  */
 
 #define XLOG_MIN_ICLOGS                2
-#define XLOG_MED_ICLOGS                4
 #define XLOG_MAX_ICLOGS                8
 #define XLOG_HEADER_MAGIC_NUM  0xFEEDbabe      /* Invalid cycle number */
 #define XLOG_VERSION_1         1
 #define XLOG_VERSION_2         2               /* Large IClogs, Log sunit */
 #define XLOG_VERSION_OKBITS    (XLOG_VERSION_1 | XLOG_VERSION_2)
-#define XLOG_RECORD_BSIZE      (16*1024)       /* eventually 32k */
+#define XLOG_MIN_RECORD_BSIZE  (16*1024)       /* eventually 32k */
 #define XLOG_BIG_RECORD_BSIZE  (32*1024)       /* 32k buffers */
 #define XLOG_MAX_RECORD_BSIZE  (256*1024)
 #define XLOG_HEADER_CYCLE_SIZE (32*1024)       /* cycle data in header */
-#define XLOG_RECORD_BSHIFT     14              /* 16384 == 1 << 14 */
+#define XLOG_MIN_RECORD_BSHIFT 14              /* 16384 == 1 << 14 */
 #define XLOG_BIG_RECORD_BSHIFT 15              /* 32k == 1 << 15 */
 #define XLOG_MAX_RECORD_BSHIFT 18              /* 256k == 1 << 18 */
 #define XLOG_BTOLSUNIT(log, b)  (((b)+(log)->l_mp->m_sb.sb_logsunit-1) / \
@@ -56,32 +55,21 @@ struct xfs_mount;
        BTOBB(XLOG_MAX_ICLOGS << (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb) ? \
         XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
 
-/*
- *  set lsns
- */
 
-#define ASSIGN_ANY_LSN_HOST(lsn,cycle,block)  \
-    { \
-       (lsn) = ((xfs_lsn_t)(cycle)<<32)|(block); \
-    }
-#define ASSIGN_ANY_LSN_DISK(lsn,cycle,block)  \
-    { \
-       INT_SET(((uint *)&(lsn))[0], ARCH_CONVERT, (cycle)); \
-       INT_SET(((uint *)&(lsn))[1], ARCH_CONVERT, (block)); \
-    }
-#define ASSIGN_LSN(lsn,log) \
-    ASSIGN_ANY_LSN_DISK(lsn,(log)->l_curr_cycle,(log)->l_curr_block);
-
-#define XLOG_SET(f,b)          (((f) & (b)) == (b))
-
-#define GET_CYCLE(ptr, arch) \
-    (INT_GET(*(uint *)(ptr), arch) == XLOG_HEADER_MAGIC_NUM ? \
-        INT_GET(*((uint *)(ptr)+1), arch) : \
-        INT_GET(*(uint *)(ptr), arch) \
-    )
+static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block)
+{
+       return ((xfs_lsn_t)cycle << 32) | block;
+}
 
-#define BLK_AVG(blk1, blk2)    ((blk1+blk2) >> 1)
+static inline uint xlog_get_cycle(char *ptr)
+{
+       if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM)
+               return be32_to_cpu(*((__be32 *)ptr + 1));
+       else
+               return be32_to_cpu(*(__be32 *)ptr);
+}
 
+#define BLK_AVG(blk1, blk2)    ((blk1+blk2) >> 1)
 
 #ifdef __KERNEL__
 
@@ -97,19 +85,10 @@ struct xfs_mount;
  *
  * this has endian issues, of course.
  */
-
-#ifndef XFS_NATIVE_HOST
-#define GET_CLIENT_ID(i,arch) \
-    ((i) & 0xff)
-#else
-#define GET_CLIENT_ID(i,arch) \
-    ((i) >> 24)
-#endif
-
-#define GRANT_LOCK(log)                mutex_spinlock(&(log)->l_grant_lock)
-#define GRANT_UNLOCK(log, s)   mutex_spinunlock(&(log)->l_grant_lock, s)
-#define LOG_LOCK(log)          mutex_spinlock(&(log)->l_icloglock)
-#define LOG_UNLOCK(log, s)     mutex_spinunlock(&(log)->l_icloglock, s)
+static inline uint xlog_get_client_id(__be32 i)
+{
+       return be32_to_cpu(i) >> 24;
+}
 
 #define xlog_panic(args...)    cmn_err(CE_PANIC, ## args)
 #define xlog_exit(args...)     cmn_err(CE_PANIC, ## args)
@@ -250,22 +229,6 @@ typedef __uint32_t xlog_tid_t;
 
 /* Ticket reservation region accounting */ 
 #define XLOG_TIC_LEN_MAX       15
-#define XLOG_TIC_RESET_RES(t) ((t)->t_res_num = \
-                               (t)->t_res_arr_sum = (t)->t_res_num_ophdrs = 0)
-#define XLOG_TIC_ADD_OPHDR(t) ((t)->t_res_num_ophdrs++)
-#define XLOG_TIC_ADD_REGION(t, len, type)                              \
-       do {                                                            \
-               if ((t)->t_res_num == XLOG_TIC_LEN_MAX) {               \
-                       /* add to overflow and start again */           \
-                       (t)->t_res_o_flow += (t)->t_res_arr_sum;        \
-                       (t)->t_res_num = 0;                             \
-                       (t)->t_res_arr_sum = 0;                         \
-               }                                                       \
-               (t)->t_res_arr[(t)->t_res_num].r_len = (len);           \
-               (t)->t_res_arr[(t)->t_res_num].r_type = (type);         \
-               (t)->t_res_arr_sum += (len);                            \
-               (t)->t_res_num++;                                       \
-       } while (0)
 
 /*
  * Reservation region
@@ -302,11 +265,11 @@ typedef struct xlog_ticket {
 
 
 typedef struct xlog_op_header {
-       xlog_tid_t oh_tid;      /* transaction id of operation  :  4 b */
-       int        oh_len;      /* bytes in data region         :  4 b */
-       __uint8_t  oh_clientid; /* who sent me this             :  1 b */
-       __uint8_t  oh_flags;    /*                              :  1 b */
-       ushort     oh_res2;     /* 32 bit align                 :  2 b */
+       __be32     oh_tid;      /* transaction id of operation  :  4 b */
+       __be32     oh_len;      /* bytes in data region         :  4 b */
+       __u8       oh_clientid; /* who sent me this             :  1 b */
+       __u8       oh_flags;    /*                              :  1 b */
+       __u16      oh_res2;     /* 32 bit align                 :  2 b */
 } xlog_op_header_t;
 
 
@@ -324,25 +287,25 @@ typedef struct xlog_op_header {
 #endif
 
 typedef struct xlog_rec_header {
-       uint      h_magicno;    /* log record (LR) identifier           :  4 */
-       uint      h_cycle;      /* write cycle of log                   :  4 */
-       int       h_version;    /* LR version                           :  4 */
-       int       h_len;        /* len in bytes; should be 64-bit aligned: 4 */
-       xfs_lsn_t h_lsn;        /* lsn of this LR                       :  8 */
-       xfs_lsn_t h_tail_lsn;   /* lsn of 1st LR w/ buffers not committed: 8 */
-       uint      h_chksum;     /* may not be used; non-zero if used    :  4 */
-       int       h_prev_block; /* block number to previous LR          :  4 */
-       int       h_num_logops; /* number of log operations in this LR  :  4 */
-       uint      h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE];
+       __be32    h_magicno;    /* log record (LR) identifier           :  4 */
+       __be32    h_cycle;      /* write cycle of log                   :  4 */
+       __be32    h_version;    /* LR version                           :  4 */
+       __be32    h_len;        /* len in bytes; should be 64-bit aligned: 4 */
+       __be64    h_lsn;        /* lsn of this LR                       :  8 */
+       __be64    h_tail_lsn;   /* lsn of 1st LR w/ buffers not committed: 8 */
+       __be32    h_chksum;     /* may not be used; non-zero if used    :  4 */
+       __be32    h_prev_block; /* block number to previous LR          :  4 */
+       __be32    h_num_logops; /* number of log operations in this LR  :  4 */
+       __be32    h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE];
        /* new fields */
-       int       h_fmt;        /* format of log record                 :  4 */
-       uuid_t    h_fs_uuid;    /* uuid of FS                           : 16 */
-       int       h_size;       /* iclog size                           :  4 */
+       __be32    h_fmt;        /* format of log record                 :  4 */
+       uuid_t    h_fs_uuid;    /* uuid of FS                           : 16 */
+       __be32    h_size;       /* iclog size                           :  4 */
 } xlog_rec_header_t;
 
 typedef struct xlog_rec_ext_header {
-       uint      xh_cycle;     /* write cycle of log                   : 4 */
-       uint      xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /*    : 256 */
+       __be32    xh_cycle;     /* write cycle of log                   : 4 */
+       __be32    xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /*    : 256 */
 } xlog_rec_ext_header_t;
 
 #ifdef __KERNEL__
@@ -432,7 +395,7 @@ typedef struct log {
        xlog_ticket_t           *l_unmount_free;/* kmem_free these addresses */
        xlog_ticket_t           *l_tail;        /* free list of tickets */
        xlog_in_core_t          *l_iclog;       /* head log queue       */
-       lock_t                  l_icloglock;    /* grab to change iclog state */
+       spinlock_t              l_icloglock;    /* grab to change iclog state */
        xfs_lsn_t               l_tail_lsn;     /* lsn of 1st LR with unflushed
                                                 * buffers */
        xfs_lsn_t               l_last_sync_lsn;/* lsn of last LR on disk */
@@ -456,7 +419,7 @@ typedef struct log {
        char                    *l_iclog_bak[XLOG_MAX_ICLOGS];
 
        /* The following block of fields are changed while holding grant_lock */
-       lock_t                  l_grant_lock;
+       spinlock_t              l_grant_lock;
        xlog_ticket_t           *l_reserve_headq;
        xlog_ticket_t           *l_write_headq;
        int                     l_grant_reserve_cycle;