暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

XFS文件系统结构学习笔记-xlog 结构

XFS文件系统的XLOG,类似ORACLE的REDO LOG。记录XFS元数据变化的事务日志。XFS在删除文件后,会清理掉INODE中的部分重要信息,如删除文件,会清掉父级DIR INODE中的的记录,基中重要的如文件名、INODE NUMBER,在研究XFS文件误删恢复中,解析XFS XLOG起到很重要的作为。这里通过对XFS XLOG的学习,整理了一个整体的结构。

image.png

几个重要的数据结构

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;              : 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];  ---32*1024/512  ==64   offset 44
    /* 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;
/* 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


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;


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;

typedef struct xfs_trans_header {
	uint		th_magic;		/* magic number */
	uint		th_type;		/* transaction type */
	__int32_t	th_tid;			/* transaction id (unused) */
	uint		th_num_items;		/* num items logged by trans */
} xfs_trans_header_t;
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论