fc06c6d064
The on-disk format definitions for the log are spread randoms through a couple of header files. Consolidate it all in a single file that can be shared easily with userspace. This means that xfs_log.h and xfs_log_priv.h no longer need to be shared with userspace. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
179 lines
6.3 KiB
C
179 lines
6.3 KiB
C
/*
|
|
* Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
|
|
* All Rights Reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it would be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write the Free Software Foundation,
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
#ifndef __XFS_LOG_FORMAT_H__
|
|
#define __XFS_LOG_FORMAT_H__
|
|
|
|
typedef __uint32_t xlog_tid_t;
|
|
|
|
#define XLOG_MIN_ICLOGS 2
|
|
#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_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_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) / \
|
|
(log)->l_mp->m_sb.sb_logsunit)
|
|
#define XLOG_LSUNITTOB(log, su) ((su) * (log)->l_mp->m_sb.sb_logsunit)
|
|
|
|
#define XLOG_HEADER_SIZE 512
|
|
|
|
#define XLOG_REC_SHIFT(log) \
|
|
BTOBB(1 << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \
|
|
XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
|
|
#define XLOG_TOTAL_REC_SHIFT(log) \
|
|
BTOBB(XLOG_MAX_ICLOGS << (xfs_sb_version_haslogv2(&log->l_mp->m_sb) ? \
|
|
XLOG_MAX_RECORD_BSHIFT : XLOG_BIG_RECORD_BSHIFT))
|
|
|
|
/* get lsn fields */
|
|
#define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
|
|
#define BLOCK_LSN(lsn) ((uint)(lsn))
|
|
|
|
/* this is used in a spot where we might otherwise double-endian-flip */
|
|
#define CYCLE_LSN_DISK(lsn) (((__be32 *)&(lsn))[0])
|
|
|
|
static inline xfs_lsn_t xlog_assign_lsn(uint cycle, uint block)
|
|
{
|
|
return ((xfs_lsn_t)cycle << 32) | block;
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
/* Log Clients */
|
|
#define XFS_TRANSACTION 0x69
|
|
#define XFS_VOLUME 0x2
|
|
#define XFS_LOG 0xaa
|
|
|
|
#define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */
|
|
|
|
/* Region types for iovec's i_type */
|
|
#define XLOG_REG_TYPE_BFORMAT 1
|
|
#define XLOG_REG_TYPE_BCHUNK 2
|
|
#define XLOG_REG_TYPE_EFI_FORMAT 3
|
|
#define XLOG_REG_TYPE_EFD_FORMAT 4
|
|
#define XLOG_REG_TYPE_IFORMAT 5
|
|
#define XLOG_REG_TYPE_ICORE 6
|
|
#define XLOG_REG_TYPE_IEXT 7
|
|
#define XLOG_REG_TYPE_IBROOT 8
|
|
#define XLOG_REG_TYPE_ILOCAL 9
|
|
#define XLOG_REG_TYPE_IATTR_EXT 10
|
|
#define XLOG_REG_TYPE_IATTR_BROOT 11
|
|
#define XLOG_REG_TYPE_IATTR_LOCAL 12
|
|
#define XLOG_REG_TYPE_QFORMAT 13
|
|
#define XLOG_REG_TYPE_DQUOT 14
|
|
#define XLOG_REG_TYPE_QUOTAOFF 15
|
|
#define XLOG_REG_TYPE_LRHEADER 16
|
|
#define XLOG_REG_TYPE_UNMOUNT 17
|
|
#define XLOG_REG_TYPE_COMMIT 18
|
|
#define XLOG_REG_TYPE_TRANSHDR 19
|
|
#define XLOG_REG_TYPE_ICREATE 20
|
|
#define XLOG_REG_TYPE_MAX 20
|
|
|
|
/*
|
|
* Flags to log operation header
|
|
*
|
|
* The first write of a new transaction will be preceded with a start
|
|
* record, XLOG_START_TRANS. Once a transaction is committed, a commit
|
|
* record is written, XLOG_COMMIT_TRANS. If a single region can not fit into
|
|
* the remainder of the current active in-core log, it is split up into
|
|
* multiple regions. Each partial region will be marked with a
|
|
* XLOG_CONTINUE_TRANS until the last one, which gets marked with XLOG_END_TRANS.
|
|
*
|
|
*/
|
|
#define XLOG_START_TRANS 0x01 /* Start a new transaction */
|
|
#define XLOG_COMMIT_TRANS 0x02 /* Commit this transaction */
|
|
#define XLOG_CONTINUE_TRANS 0x04 /* Cont this trans into new region */
|
|
#define XLOG_WAS_CONT_TRANS 0x08 /* Cont this trans into new region */
|
|
#define XLOG_END_TRANS 0x10 /* End a continued transaction */
|
|
#define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */
|
|
|
|
|
|
typedef struct xlog_op_header {
|
|
__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;
|
|
|
|
|
|
/* valid values for h_fmt */
|
|
#define XLOG_FMT_UNKNOWN 0
|
|
#define XLOG_FMT_LINUX_LE 1
|
|
#define XLOG_FMT_LINUX_BE 2
|
|
#define XLOG_FMT_IRIX_BE 3
|
|
|
|
/* our fmt */
|
|
#ifdef XFS_NATIVE_HOST
|
|
#define XLOG_FMT XLOG_FMT_LINUX_BE
|
|
#else
|
|
#define XLOG_FMT XLOG_FMT_LINUX_LE
|
|
#endif
|
|
|
|
typedef struct xlog_rec_header {
|
|
__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 */
|
|
__le32 h_crc; /* crc of log record : 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 */
|
|
__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 {
|
|
__be32 xh_cycle; /* write cycle of log : 4 */
|
|
__be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */
|
|
} xlog_rec_ext_header_t;
|
|
|
|
/*
|
|
* Quite misnamed, because this union lays out the actual on-disk log buffer.
|
|
*/
|
|
typedef union xlog_in_core2 {
|
|
xlog_rec_header_t hic_header;
|
|
xlog_rec_ext_header_t hic_xheader;
|
|
char hic_sector[XLOG_HEADER_SIZE];
|
|
} xlog_in_core_2_t;
|
|
|
|
/* not an on-disk structure, but needed by log recovery in userspace */
|
|
typedef struct xfs_log_iovec {
|
|
void *i_addr; /* beginning address of region */
|
|
int i_len; /* length in bytes of region */
|
|
uint i_type; /* type of region */
|
|
} xfs_log_iovec_t;
|
|
|
|
#endif /* __XFS_LOG_FORMAT_H__ */
|