xfs
[Top] [All Lists]

[PATCH 12/12] xfsprogs: add crc format support to db

To: xfs@xxxxxxxxxxx
Subject: [PATCH 12/12] xfsprogs: add crc format support to db
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 22 Jan 2013 00:53:11 +1100
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1358776391-22140-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1358776391-22140-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 db/agf.c                 |    3 +
 db/agfl.c                |   16 +++++
 db/agfl.h                |    2 +
 db/agi.c                 |    3 +
 db/btblock.c             |  145 ++++++++++++++++++++++++++++++++++++++++++++++
 db/btblock.h             |   10 ++++
 db/field.c               |   16 +++++
 db/field.h               |    8 +++
 db/freesp.c              |   11 +++-
 db/init.c                |    4 ++
 db/inode.c               |   27 +++++++++
 db/inode.h               |    3 +
 db/sb.c                  |   26 +++++++++
 db/type.c                |   35 ++++++++++-
 db/type.h                |    3 +-
 include/xfs_inode.h      |    4 +-
 logprint/log_misc.c      |    2 +-
 logprint/log_print_all.c |    4 +-
 repair/phase6.c          |    9 +--
 19 files changed, 315 insertions(+), 16 deletions(-)

diff --git a/db/agf.c b/db/agf.c
index 668637a..389cb43 100644
--- a/db/agf.c
+++ b/db/agf.c
@@ -69,6 +69,9 @@ const field_t agf_flds[] = {
        { "freeblks", FLDT_EXTLEN, OI(OFF(freeblks)), C1, 0, TYP_NONE },
        { "longest", FLDT_EXTLEN, OI(OFF(longest)), C1, 0, TYP_NONE },
        { "btreeblks", FLDT_UINT32D, OI(OFF(btreeblks)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
+       { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE },
        { NULL }
 };
 
diff --git a/db/agfl.c b/db/agfl.c
index 72dca23..93f1096 100644
--- a/db/agfl.c
+++ b/db/agfl.c
@@ -41,6 +41,11 @@ const field_t        agfl_hfld[] = { {
        { NULL }
 };
 
+const field_t  agfl_crc_hfld[] = { {
+       "", FLDT_AGFL_CRC, OI(0), C1, 0, TYP_NONE, },
+       { NULL }
+};
+
 #define        OFF(f)  bitize(offsetof(xfs_agfl_t, agfl_ ## f))
 const field_t  agfl_flds[] = {
        { "bno", FLDT_AGBLOCKNZ, OI(OFF(bno)), agfl_bno_size,
@@ -48,6 +53,17 @@ const field_t        agfl_flds[] = {
        { NULL }
 };
 
+const field_t  agfl_crc_flds[] = {
+       { "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE },
+       { "seqno", FLDT_AGNUMBER, OI(OFF(seqno)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
+       { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE },
+       { "bno", FLDT_AGBLOCKNZ, OI(OFF(bno)), agfl_bno_size,
+         FLD_ARRAY|FLD_COUNT, TYP_DATA },
+       { NULL }
+};
+
 static int
 agfl_bno_size(
        void    *obj,
diff --git a/db/agfl.h b/db/agfl.h
index 7b7631b..177ad41 100644
--- a/db/agfl.h
+++ b/db/agfl.h
@@ -18,6 +18,8 @@
 
 extern const struct field      agfl_flds[];
 extern const struct field      agfl_hfld[];
+extern const struct field      agfl_crc_flds[];
+extern const struct field      agfl_crc_hfld[];
 
 extern void    agfl_init(void);
 extern int     agfl_size(void *obj, int startoff, int idx);
diff --git a/db/agi.c b/db/agi.c
index 02d5d30..6b2e889 100644
--- a/db/agi.c
+++ b/db/agi.c
@@ -54,6 +54,9 @@ const field_t agi_flds[] = {
        { "dirino", FLDT_AGINO, OI(OFF(dirino)), C1, 0, TYP_INODE },
        { "unlinked", FLDT_AGINONN, OI(OFF(unlinked)),
          CI(XFS_AGI_UNLINKED_BUCKETS), FLD_ARRAY, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
+       { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE },
        { NULL }
 };
 
diff --git a/db/btblock.c b/db/btblock.c
index 2c199b2..37b9903 100644
--- a/db/btblock.c
+++ b/db/btblock.c
@@ -60,6 +60,31 @@ struct xfs_db_btree {
                sizeof(xfs_inobt_rec_t),
                sizeof(__be32),
        },
+       [/*0x424d415*/8] = { /* BMAP_CRC */
+               XFS_BTREE_LBLOCK_CRC_LEN,
+               sizeof(xfs_bmbt_key_t),
+               sizeof(xfs_bmbt_rec_t),
+               sizeof(__be64),
+       },
+       [/*0x4142544*/0xa] = { /* ABTB_CRC */
+               XFS_BTREE_SBLOCK_CRC_LEN,
+               sizeof(xfs_alloc_key_t),
+               sizeof(xfs_alloc_rec_t),
+               sizeof(__be32),
+       },
+       [/*0x414254*/0xb] = { /* ABTC_CRC */
+               XFS_BTREE_SBLOCK_CRC_LEN,
+               sizeof(xfs_alloc_key_t),
+               sizeof(xfs_alloc_rec_t),
+               sizeof(__be32),
+       },
+       [/*0x4941425*/0xc] = { /* IABT_CRC */
+               XFS_BTREE_SBLOCK_CRC_LEN,
+               sizeof(xfs_inobt_key_t),
+               sizeof(xfs_inobt_rec_t),
+               sizeof(__be32),
+       },
+
 };
 
 /*
@@ -208,6 +233,15 @@ const field_t      bmapbtd_hfld[] = {
        { NULL }
 };
 
+const field_t  bmapbta_crc_hfld[] = {
+       { "", FLDT_BMAPBTA_CRC, OI(0), C1, 0, TYP_NONE },
+       { NULL }
+};
+const field_t  bmapbtd_crc_hfld[] = {
+       { "", FLDT_BMAPBTD_CRC, OI(0), C1, 0, TYP_NONE },
+       { NULL }
+};
+
 #define        OFF(f)  bitize(offsetof(struct xfs_btree_block, bb_ ## f))
 const field_t  bmapbta_flds[] = {
        { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
@@ -237,6 +271,45 @@ const field_t      bmapbtd_flds[] = {
          FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_BMAPBTD },
        { NULL }
 };
+/* crc enabled versions */
+const field_t  bmapbta_crc_flds[] = {
+       { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
+       { "level", FLDT_UINT16D, OI(OFF(level)), C1, 0, TYP_NONE },
+       { "numrecs", FLDT_UINT16D, OI(OFF(numrecs)), C1, 0, TYP_NONE },
+       { "leftsib", FLDT_DFSBNO, OI(OFF(u.l.bb_leftsib)), C1, 0, TYP_BMAPBTA },
+       { "rightsib", FLDT_DFSBNO, OI(OFF(u.l.bb_rightsib)), C1, 0, TYP_BMAPBTA 
},
+       { "bno", FLDT_DFSBNO, OI(OFF(u.l.bb_blkno)), C1, 0, TYP_BMAPBTD },
+       { "lsn", FLDT_UINT64X, OI(OFF(u.l.bb_lsn)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(u.l.bb_uuid)), C1, 0, TYP_NONE },
+       { "owner", FLDT_INO, OI(OFF(u.l.bb_owner)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(u.l.bb_crc)), C1, 0, TYP_NONE },
+       { "recs", FLDT_BMAPBTAREC, btblock_rec_offset, btblock_rec_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "keys", FLDT_BMAPBTAKEY, btblock_key_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "ptrs", FLDT_BMAPBTAPTR, btblock_ptr_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_BMAPBTA },
+       { NULL }
+};
+const field_t  bmapbtd_crc_flds[] = {
+       { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
+       { "level", FLDT_UINT16D, OI(OFF(level)), C1, 0, TYP_NONE },
+       { "numrecs", FLDT_UINT16D, OI(OFF(numrecs)), C1, 0, TYP_NONE },
+       { "leftsib", FLDT_DFSBNO, OI(OFF(u.l.bb_leftsib)), C1, 0, TYP_BMAPBTD },
+       { "rightsib", FLDT_DFSBNO, OI(OFF(u.l.bb_rightsib)), C1, 0, TYP_BMAPBTD 
},
+       { "bno", FLDT_DFSBNO, OI(OFF(u.l.bb_blkno)), C1, 0, TYP_BMAPBTD },
+       { "lsn", FLDT_UINT64X, OI(OFF(u.l.bb_lsn)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(u.l.bb_uuid)), C1, 0, TYP_NONE },
+       { "owner", FLDT_INO, OI(OFF(u.l.bb_owner)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(u.l.bb_crc)), C1, 0, TYP_NONE },
+       { "recs", FLDT_BMAPBTDREC, btblock_rec_offset, btblock_rec_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "keys", FLDT_BMAPBTDKEY, btblock_key_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "ptrs", FLDT_BMAPBTDPTR, btblock_ptr_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_BMAPBTD },
+       { NULL }
+};
 #undef OFF
 
 #define        KOFF(f) bitize(offsetof(xfs_bmbt_key_t, br_ ## f))
@@ -289,6 +362,11 @@ const field_t      inobt_hfld[] = {
        { NULL }
 };
 
+const field_t  inobt_crc_hfld[] = {
+       { "", FLDT_INOBT_CRC, OI(0), C1, 0, TYP_NONE },
+       { NULL }
+};
+
 #define        OFF(f)  bitize(offsetof(struct xfs_btree_block, bb_ ## f))
 const field_t  inobt_flds[] = {
        { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
@@ -304,6 +382,25 @@ const field_t      inobt_flds[] = {
          FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_INOBT },
        { NULL }
 };
+const field_t  inobt_crc_flds[] = {
+       { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
+       { "level", FLDT_UINT16D, OI(OFF(level)), C1, 0, TYP_NONE },
+       { "numrecs", FLDT_UINT16D, OI(OFF(numrecs)), C1, 0, TYP_NONE },
+       { "leftsib", FLDT_AGBLOCK, OI(OFF(u.s.bb_leftsib)), C1, 0, TYP_INOBT },
+       { "rightsib", FLDT_AGBLOCK, OI(OFF(u.s.bb_rightsib)), C1, 0, TYP_INOBT 
},
+       { "bno", FLDT_DFSBNO, OI(OFF(u.s.bb_blkno)), C1, 0, TYP_INOBT },
+       { "lsn", FLDT_UINT64X, OI(OFF(u.s.bb_lsn)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(u.s.bb_uuid)), C1, 0, TYP_NONE },
+       { "owner", FLDT_AGNUMBER, OI(OFF(u.s.bb_owner)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(u.s.bb_crc)), C1, 0, TYP_NONE },
+       { "recs", FLDT_INOBTREC, btblock_rec_offset, btblock_rec_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "keys", FLDT_INOBTKEY, btblock_key_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "ptrs", FLDT_INOBTPTR, btblock_ptr_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_INOBT },
+       { NULL }
+};
 #undef OFF
 
 #define        KOFF(f) bitize(offsetof(xfs_inobt_key_t, ir_ ## f))
@@ -331,6 +428,11 @@ const field_t      bnobt_hfld[] = {
        { NULL }
 };
 
+const field_t  bnobt_crc_hfld[] = {
+       { "", FLDT_BNOBT_CRC, OI(0), C1, 0, TYP_NONE },
+       { NULL }
+};
+
 #define        OFF(f)  bitize(offsetof(struct xfs_btree_block, bb_ ## f))
 const field_t  bnobt_flds[] = {
        { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
@@ -346,6 +448,25 @@ const field_t      bnobt_flds[] = {
          FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_BNOBT },
        { NULL }
 };
+const field_t  bnobt_crc_flds[] = {
+       { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
+       { "level", FLDT_UINT16D, OI(OFF(level)), C1, 0, TYP_NONE },
+       { "numrecs", FLDT_UINT16D, OI(OFF(numrecs)), C1, 0, TYP_NONE },
+       { "leftsib", FLDT_AGBLOCK, OI(OFF(u.s.bb_leftsib)), C1, 0, TYP_BNOBT },
+       { "rightsib", FLDT_AGBLOCK, OI(OFF(u.s.bb_rightsib)), C1, 0, TYP_BNOBT 
},
+       { "bno", FLDT_DFSBNO, OI(OFF(u.s.bb_blkno)), C1, 0, TYP_BNOBT },
+       { "lsn", FLDT_UINT64X, OI(OFF(u.s.bb_lsn)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(u.s.bb_uuid)), C1, 0, TYP_NONE },
+       { "owner", FLDT_AGNUMBER, OI(OFF(u.s.bb_owner)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(u.s.bb_crc)), C1, 0, TYP_NONE },
+       { "recs", FLDT_BNOBTREC, btblock_rec_offset, btblock_rec_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "keys", FLDT_BNOBTKEY, btblock_key_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "ptrs", FLDT_BNOBTPTR, btblock_ptr_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_BNOBT },
+       { NULL }
+};
 #undef OFF
 
 #define        KOFF(f) bitize(offsetof(xfs_alloc_key_t, ar_ ## f))
@@ -369,6 +490,11 @@ const field_t      cntbt_hfld[] = {
        { NULL }
 };
 
+const field_t  cntbt_crc_hfld[] = {
+       { "", FLDT_CNTBT_CRC, OI(0), C1, 0, TYP_NONE },
+       { NULL }
+};
+
 #define        OFF(f)  bitize(offsetof(struct xfs_btree_block, bb_ ## f))
 const field_t  cntbt_flds[] = {
        { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
@@ -384,6 +510,25 @@ const field_t      cntbt_flds[] = {
          FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_CNTBT },
        { NULL }
 };
+const field_t  cntbt_crc_flds[] = {
+       { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
+       { "level", FLDT_UINT16D, OI(OFF(level)), C1, 0, TYP_NONE },
+       { "numrecs", FLDT_UINT16D, OI(OFF(numrecs)), C1, 0, TYP_NONE },
+       { "leftsib", FLDT_AGBLOCK, OI(OFF(u.s.bb_leftsib)), C1, 0, TYP_CNTBT },
+       { "rightsib", FLDT_AGBLOCK, OI(OFF(u.s.bb_rightsib)), C1, 0, TYP_CNTBT 
},
+       { "bno", FLDT_DFSBNO, OI(OFF(u.s.bb_blkno)), C1, 0, TYP_CNTBT },
+       { "lsn", FLDT_UINT64X, OI(OFF(u.s.bb_lsn)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(u.s.bb_uuid)), C1, 0, TYP_NONE },
+       { "owner", FLDT_AGNUMBER, OI(OFF(u.s.bb_owner)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(u.s.bb_crc)), C1, 0, TYP_NONE },
+       { "recs", FLDT_CNTBTREC, btblock_rec_offset, btblock_rec_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "keys", FLDT_CNTBTKEY, btblock_key_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { "ptrs", FLDT_CNTBTPTR, btblock_ptr_offset, btblock_key_count,
+         FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_CNTBT },
+       { NULL }
+};
 #undef OFF
 
 #define        KOFF(f) bitize(offsetof(xfs_alloc_key_t, ar_ ## f))
diff --git a/db/btblock.h b/db/btblock.h
index 0631e66..daee060 100644
--- a/db/btblock.h
+++ b/db/btblock.h
@@ -18,26 +18,36 @@
 
 extern const struct field      bmapbta_flds[];
 extern const struct field      bmapbta_hfld[];
+extern const struct field      bmapbta_crc_flds[];
+extern const struct field      bmapbta_crc_hfld[];
 extern const struct field      bmapbta_key_flds[];
 extern const struct field      bmapbta_rec_flds[];
 
 extern const struct field      bmapbtd_flds[];
 extern const struct field      bmapbtd_hfld[];
+extern const struct field      bmapbtd_crc_flds[];
+extern const struct field      bmapbtd_crc_hfld[];
 extern const struct field      bmapbtd_key_flds[];
 extern const struct field      bmapbtd_rec_flds[];
 
 extern const struct field      inobt_flds[];
 extern const struct field      inobt_hfld[];
+extern const struct field      inobt_crc_flds[];
+extern const struct field      inobt_crc_hfld[];
 extern const struct field      inobt_key_flds[];
 extern const struct field      inobt_rec_flds[];
 
 extern const struct field      bnobt_flds[];
 extern const struct field      bnobt_hfld[];
+extern const struct field      bnobt_crc_flds[];
+extern const struct field      bnobt_crc_hfld[];
 extern const struct field      bnobt_key_flds[];
 extern const struct field      bnobt_rec_flds[];
 
 extern const struct field      cntbt_flds[];
 extern const struct field      cntbt_hfld[];
+extern const struct field      cntbt_crc_flds[];
+extern const struct field      cntbt_crc_hfld[];
 extern const struct field      cntbt_key_flds[];
 extern const struct field      cntbt_rec_flds[];
 
diff --git a/db/field.c b/db/field.c
index 6903898..032b74e 100644
--- a/db/field.c
+++ b/db/field.c
@@ -48,6 +48,8 @@ const ftattr_t        ftattrtab[] = {
          agf_flds },
        { FLDT_AGFL, "agfl", NULL, (char *)agfl_flds, agfl_size, FTARG_SIZE,
          NULL, agfl_flds },
+       { FLDT_AGFL_CRC, "agfl", NULL, (char *)agfl_crc_flds, agfl_size,
+         FTARG_SIZE, NULL, agfl_crc_flds },
        { FLDT_AGI, "agi", NULL, (char *)agi_flds, agi_size, FTARG_SIZE, NULL,
          agi_flds },
        { FLDT_AGINO, "agino", fp_num, "%u", SI(bitsz(xfs_agino_t)),
@@ -86,6 +88,8 @@ const ftattr_t        ftattrtab[] = {
          attrshort_size, FTARG_SIZE, NULL, attr_shortform_flds },
        { FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size,
          FTARG_SIZE, NULL, bmapbta_flds },
+       { FLDT_BMAPBTA_CRC, "bmapbta", NULL, (char *)bmapbta_crc_flds,
+         btblock_size, FTARG_SIZE, NULL, bmapbta_crc_flds },
        { FLDT_BMAPBTAKEY, "bmapbtakey", fp_sarray, (char *)bmapbta_key_flds,
          SI(bitsz(xfs_bmbt_key_t)), 0, NULL, bmapbta_key_flds },
        { FLDT_BMAPBTAPTR, "bmapbtaptr", fp_num, "%llu",
@@ -94,6 +98,8 @@ const ftattr_t        ftattrtab[] = {
          SI(bitsz(xfs_bmbt_rec_t)), 0, NULL, bmapbta_rec_flds },
        { FLDT_BMAPBTD, "bmapbtd", NULL, (char *)bmapbtd_flds, btblock_size,
          FTARG_SIZE, NULL, bmapbtd_flds },
+       { FLDT_BMAPBTD_CRC, "bmapbtd", NULL, (char *)bmapbtd_crc_flds,
+         btblock_size, FTARG_SIZE, NULL, bmapbtd_crc_flds },
        { FLDT_BMAPBTDKEY, "bmapbtdkey", fp_sarray, (char *)bmapbtd_key_flds,
          SI(bitsz(xfs_bmbt_key_t)), 0, NULL, bmapbtd_key_flds },
        { FLDT_BMAPBTDPTR, "bmapbtdptr", fp_num, "%llu",
@@ -114,6 +120,8 @@ const ftattr_t      ftattrtab[] = {
          SI(bitsz(xfs_bmdr_ptr_t)), 0, fa_dfsbno, NULL },
        { FLDT_BNOBT, "bnobt", NULL, (char *)bnobt_flds, btblock_size, 
FTARG_SIZE,
          NULL, bnobt_flds },
+       { FLDT_BNOBT_CRC, "bnobt", NULL, (char *)bnobt_crc_flds, btblock_size,
+         FTARG_SIZE, NULL, bnobt_crc_flds },
        { FLDT_BNOBTKEY, "bnobtkey", fp_sarray, (char *)bnobt_key_flds,
          SI(bitsz(xfs_alloc_key_t)), 0, NULL, bnobt_key_flds },
        { FLDT_BNOBTPTR, "bnobtptr", fp_num, "%u", SI(bitsz(xfs_alloc_ptr_t)),
@@ -135,6 +143,8 @@ const ftattr_t      ftattrtab[] = {
        { FLDT_CHARS, "chars", fp_num, "%c", SI(bitsz(char)), 0, NULL, NULL },
        { FLDT_CNTBT, "cntbt", NULL, (char *)cntbt_flds, btblock_size, 
FTARG_SIZE,
          NULL, cntbt_flds },
+       { FLDT_CNTBT_CRC, "cntbt", NULL, (char *)cntbt_crc_flds, btblock_size,
+         FTARG_SIZE, NULL, cntbt_crc_flds },
        { FLDT_CNTBTKEY, "cntbtkey", fp_sarray, (char *)cntbt_key_flds,
          SI(bitsz(xfs_alloc_key_t)), 0, NULL, cntbt_key_flds },
        { FLDT_CNTBTPTR, "cntbtptr", fp_num, "%u", SI(bitsz(xfs_alloc_ptr_t)),
@@ -156,6 +166,8 @@ const ftattr_t      ftattrtab[] = {
          SI(bitsz(__int8_t)), 0, NULL, NULL },
        { FLDT_DINODE_U, "dinode_u", NULL, (char *)inode_u_flds, inode_u_size,
          FTARG_SIZE|FTARG_OKEMPTY, NULL, inode_u_flds },
+       { FLDT_DINODE_V3, "dinode_v3", NULL, (char *)inode_v3_flds,
+         SI(bitsz(xfs_dinode_t)), 0, NULL, inode_v3_flds },
        { FLDT_DIR, "dir", NULL, (char *)dir_flds, dir_size, FTARG_SIZE, NULL,
          dir_flds },
        { FLDT_DIR2, "dir2", NULL, (char *)dir2_flds, dir2_size, FTARG_SIZE,
@@ -246,6 +258,8 @@ const ftattr_t      ftattrtab[] = {
          fa_ino, NULL },
        { FLDT_INOBT, "inobt",  NULL, (char *)inobt_flds, btblock_size,
          FTARG_SIZE, NULL, inobt_flds },
+       { FLDT_INOBT_CRC, "inobt",  NULL, (char *)inobt_crc_flds, btblock_size,
+         FTARG_SIZE, NULL, inobt_crc_flds },
        { FLDT_INOBTKEY, "inobtkey", fp_sarray, (char *)inobt_key_flds,
          SI(bitsz(xfs_inobt_key_t)), 0, NULL, inobt_key_flds },
        { FLDT_INOBTPTR, "inobtptr", fp_num, "%u", SI(bitsz(xfs_inobt_ptr_t)),
@@ -254,6 +268,8 @@ const ftattr_t      ftattrtab[] = {
          SI(bitsz(xfs_inobt_rec_t)), 0, NULL, inobt_rec_flds },
        { FLDT_INODE, "inode", NULL, (char *)inode_flds, inode_size, FTARG_SIZE,
          NULL, inode_flds },
+       { FLDT_INODE_CRC, "inode", NULL, (char *)inode_crc_flds, inode_size,
+         FTARG_SIZE, NULL, inode_crc_flds },
        { FLDT_INOFREE, "inofree", fp_num, "%#llx", SI(bitsz(xfs_inofree_t)), 0,
          NULL, NULL },
        { FLDT_INT16D, "int16d", fp_num, "%d", SI(bitsz(__int16_t)),
diff --git a/db/field.h b/db/field.h
index 6962d69..f503c42 100644
--- a/db/field.h
+++ b/db/field.h
@@ -22,6 +22,7 @@ typedef enum fldt     {
        FLDT_AGBLOCKNZ,
        FLDT_AGF,
        FLDT_AGFL,
+       FLDT_AGFL_CRC,
        FLDT_AGI,
        FLDT_AGINO,
        FLDT_AGINONN,
@@ -39,10 +40,12 @@ typedef enum fldt   {
        FLDT_ATTRBLOCK,
        FLDT_ATTRSHORT,
        FLDT_BMAPBTA,
+       FLDT_BMAPBTA_CRC,
        FLDT_BMAPBTAKEY,
        FLDT_BMAPBTAPTR,
        FLDT_BMAPBTAREC,
        FLDT_BMAPBTD,
+       FLDT_BMAPBTD_CRC,
        FLDT_BMAPBTDKEY,
        FLDT_BMAPBTDPTR,
        FLDT_BMAPBTDREC,
@@ -53,6 +56,7 @@ typedef enum fldt     {
        FLDT_BMROOTDKEY,
        FLDT_BMROOTDPTR,
        FLDT_BNOBT,
+       FLDT_BNOBT_CRC,
        FLDT_BNOBTKEY,
        FLDT_BNOBTPTR,
        FLDT_BNOBTREC,
@@ -64,6 +68,7 @@ typedef enum fldt     {
        FLDT_CHARNS,
        FLDT_CHARS,
        FLDT_CNTBT,
+       FLDT_CNTBT_CRC,
        FLDT_CNTBTKEY,
        FLDT_CNTBTPTR,
        FLDT_CNTBTREC,
@@ -75,6 +80,7 @@ typedef enum fldt     {
        FLDT_DINODE_CORE,
        FLDT_DINODE_FMT,
        FLDT_DINODE_U,
+       FLDT_DINODE_V3,
        FLDT_DIR,
        FLDT_DIR2,
        FLDT_DIR2_BLOCK_TAIL,
@@ -116,10 +122,12 @@ typedef enum fldt {
        FLDT_FSIZE,
        FLDT_INO,
        FLDT_INOBT,
+       FLDT_INOBT_CRC,
        FLDT_INOBTKEY,
        FLDT_INOBTPTR,
        FLDT_INOBTREC,
        FLDT_INODE,
+       FLDT_INODE_CRC,
        FLDT_INOFREE,
        FLDT_INT16D,
        FLDT_INT32D,
diff --git a/db/freesp.c b/db/freesp.c
index c4dabad..a39bfce 100644
--- a/db/freesp.c
+++ b/db/freesp.c
@@ -231,6 +231,7 @@ scan_freelist(
        xfs_agfl_t      *agfl;
        xfs_agblock_t   bno;
        int             i;
+       __be32          *agfl_bno;
 
        if (be32_to_cpu(agf->agf_flcount) == 0)
                return;
@@ -238,9 +239,11 @@ scan_freelist(
        set_cur(&typtab[TYP_AGFL], XFS_AG_DADDR(mp, seqno, XFS_AGFL_DADDR(mp)),
                                XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL);
        agfl = iocur_top->data;
+       agfl_bno = xfs_sb_version_hascrc(&mp->m_sb) ? &agfl->agfl_bno[0]
+                                                  : iocur_top->data;
        i = be32_to_cpu(agf->agf_flfirst);
        for (;;) {
-               bno = be32_to_cpu(agfl->agfl_bno[i]);
+               bno = be32_to_cpu(agfl_bno[i]);
                addtohist(seqno, bno, 1);
                if (i == be32_to_cpu(agf->agf_fllast))
                        break;
@@ -286,7 +289,8 @@ scanfunc_bno(
        xfs_alloc_ptr_t         *pp;
        xfs_alloc_rec_t         *rp;
 
-       if (be32_to_cpu(block->bb_magic) != XFS_ABTB_MAGIC)
+       if (!(be32_to_cpu(block->bb_magic) == XFS_ABTB_MAGIC ||
+             be32_to_cpu(block->bb_magic) == XFS_ABTB_CRC_MAGIC))
                return;
 
        if (level == 0) {
@@ -313,7 +317,8 @@ scanfunc_cnt(
        xfs_alloc_ptr_t         *pp;
        xfs_alloc_rec_t         *rp;
 
-       if (be32_to_cpu(block->bb_magic) != XFS_ABTC_MAGIC)
+       if (!(be32_to_cpu(block->bb_magic) == XFS_ABTC_MAGIC ||
+             be32_to_cpu(block->bb_magic) == XFS_ABTC_CRC_MAGIC))
                return;
 
        if (level == 0) {
diff --git a/db/init.c b/db/init.c
index 2a31cb8..141b484 100644
--- a/db/init.c
+++ b/db/init.c
@@ -26,6 +26,7 @@
 #include "sig.h"
 #include "output.h"
 #include "malloc.h"
+#include "type.h"
 
 static char    **cmdline;
 static int     ncmdline;
@@ -145,6 +146,9 @@ init(
        }
        blkbb = 1 << mp->m_blkbb_log;
 
+       if (xfs_sb_version_hascrc(&mp->m_sb))
+               type_set_tab_crc();
+
        push_cur();
        init_commands();
        init_sig();
diff --git a/db/inode.c b/db/inode.c
index 036717f..6596e4f 100644
--- a/db/inode.c
+++ b/db/inode.c
@@ -58,6 +58,10 @@ const field_t        inode_hfld[] = {
        { "", FLDT_INODE, OI(0), C1, 0, TYP_NONE },
        { NULL }
 };
+const field_t  inode_crc_hfld[] = {
+       { "", FLDT_INODE_CRC, OI(0), C1, 0, TYP_NONE },
+       { NULL }
+};
 
 /* XXX: fix this up! */
 #define        OFF(f)  bitize(offsetof(xfs_dinode_t, di_ ## f))
@@ -70,6 +74,17 @@ const field_t        inode_flds[] = {
          FLD_COUNT|FLD_OFFSET, TYP_NONE },
        { NULL }
 };
+const field_t  inode_crc_flds[] = {
+       { "core", FLDT_DINODE_CORE, OI(OFF(magic)), C1, 0, TYP_NONE },
+       { "next_unlinked", FLDT_AGINO, OI(OFF(next_unlinked)), C1, 0,
+         TYP_INODE },
+       { "v3", FLDT_DINODE_V3, OI(OFF(magic)), C1, 0, TYP_NONE },
+       { "u", FLDT_DINODE_U, inode_u_offset, C1, FLD_OFFSET, TYP_NONE },
+       { "a", FLDT_DINODE_A, inode_a_offset, inode_a_count,
+         FLD_COUNT|FLD_OFFSET, TYP_NONE },
+       { NULL }
+};
+
 
 #define        COFF(f) bitize(offsetof(xfs_dinode_t, di_ ## f))
 const field_t  inode_core_flds[] = {
@@ -152,6 +167,18 @@ const field_t      inode_core_flds[] = {
        { NULL }
 };
 
+const field_t  inode_v3_flds[] = {
+       { "crc", FLDT_UINT32X, OI(COFF(crc)), C1, 0, TYP_NONE },
+       { "change_count", FLDT_UINT64D, OI(COFF(changecount)), C1, 0, TYP_NONE 
},
+       { "lsn", FLDT_UINT64X, OI(COFF(lsn)), C1, 0, TYP_NONE },
+       { "flags2", FLDT_UINT64X, OI(COFF(flags2)), C1, 0, TYP_NONE },
+       { "crtime", FLDT_TIMESTAMP, OI(COFF(crtime)), C1, 0, TYP_NONE },
+       { "inumber", FLDT_INO, OI(COFF(ino)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(COFF(uuid)), C1, 0, TYP_NONE },
+       { NULL }
+};
+
+
 #define        TOFF(f) bitize(offsetof(xfs_timestamp_t, t_ ## f))
 const field_t  timestamp_flds[] = {
        { "sec", FLDT_TIME, OI(TOFF(sec)), C1, 0, TYP_NONE },
diff --git a/db/inode.h b/db/inode.h
index 6c1ac5c..1624f1d 100644
--- a/db/inode.h
+++ b/db/inode.h
@@ -18,8 +18,11 @@
 
 extern const struct field      inode_a_flds[];
 extern const struct field      inode_core_flds[];
+extern const struct field      inode_v3_flds[];
 extern const struct field      inode_flds[];
+extern const struct field      inode_crc_flds[];
 extern const struct field      inode_hfld[];
+extern const struct field      inode_crc_hfld[];
 extern const struct field      inode_u_flds[];
 extern const struct field      timestamp_flds[];
 
diff --git a/db/sb.c b/db/sb.c
index af86722..2cb8fa6 100644
--- a/db/sb.c
+++ b/db/sb.c
@@ -109,6 +109,14 @@ const field_t      sb_flds[] = {
        { "logsunit", FLDT_UINT32D, OI(OFF(logsunit)), C1, 0, TYP_NONE },
        { "features2", FLDT_UINT32X, OI(OFF(features2)), C1, 0, TYP_NONE },
        { "bad_features2", FLDT_UINT32X, OI(OFF(bad_features2)), C1, 0, 
TYP_NONE },
+
+       { "features_compat", FLDT_UINT32X, OI(OFF(features_compat)), C1, 0, 
TYP_NONE },
+       { "features_ro_compat", FLDT_UINT32X, OI(OFF(features_ro_compat)), C1, 
0, TYP_NONE },
+       { "features_incompat", FLDT_UINT32X, OI(OFF(features_incompat)), C1, 0, 
TYP_NONE },
+
+       { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE },
+       { "pquotino", FLDT_INO, OI(OFF(pquotino)), C1, 0, TYP_INODE },
+       { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
        { NULL }
 };
 
@@ -595,6 +603,8 @@ version_string(
                strcpy(s, "V3");
        else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4)
                strcpy(s, "V4");
+       else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
+               strcpy(s, "V5");
 
        if (xfs_sb_version_hasattr(sbp))
                strcat(s, ",ATTR");
@@ -626,6 +636,8 @@ version_string(
                strcat(s, ",LAZYSBCOUNT");
        if (xfs_sb_version_hasprojid32bit(sbp))
                strcat(s, ",PROJID32BIT");
+       if (xfs_sb_version_hascrc(sbp))
+               strcat(s, ",CRC");
        return s;
 }
 
@@ -666,6 +678,10 @@ version_f(
                                        version = mp->m_sb.sb_versionnum |
                                                  XFS_SB_VERSION_EXTFLGBIT;
                                break;
+                       case XFS_SB_VERSION_5:
+                               dbprintf(
+               _("unwritten extents always enabled for v5 superblocks.\n"));
+                               break;
                        }
                } else if (!strcasecmp(argv[1], "log2")) {
                        switch (XFS_SB_VERSION_NUM(&mp->m_sb)) {
@@ -686,8 +702,18 @@ version_f(
                                        version = mp->m_sb.sb_versionnum |
                                                  XFS_SB_VERSION_LOGV2BIT;
                                break;
+                       case XFS_SB_VERSION_5:
+                               dbprintf(
+               _("Version 2 logs always enabled for v5 superblocks.\n"));
+                               break;
                        }
+               } else if (XFS_SB_VERSION_NUM(&mp->m_sb) == XFS_SB_VERSION_5) {
+                       dbprintf(
+               _("%s: Cannot change %s on v5 superblocks.\n"),
+                               progname, argv[1]);
+                       return 0;
                } else if (!strcasecmp(argv[1], "attr1")) {
+
                        if (xfs_sb_version_hasattr2(&mp->m_sb)) {
                                if (!(mp->m_sb.sb_features2 &=
                                                ~XFS_SB_VERSION2_ATTR2BIT))
diff --git a/db/type.c b/db/type.c
index e5fd9eb..ad67543 100644
--- a/db/type.c
+++ b/db/type.c
@@ -50,7 +50,7 @@ static const cmdinfo_t        type_cmd =
        { "type", NULL, type_f, 0, 1, 1, N_("[newtype]"),
          N_("set/show current data type"), NULL };
 
-const typ_t    typtab[] = {
+static const typ_t     __typtab[] = {
        { TYP_AGF, "agf", handle_struct, agf_hfld },
        { TYP_AGFL, "agfl", handle_struct, agfl_hfld },
        { TYP_AGI, "agi", handle_struct, agi_hfld },
@@ -75,6 +75,39 @@ const typ_t  typtab[] = {
        { TYP_NONE, NULL }
 };
 
+static const typ_t     __typtab_crc[] = {
+       { TYP_AGF, "agf", handle_struct, agf_hfld },
+       { TYP_AGFL, "agfl", handle_struct, agfl_crc_hfld },
+       { TYP_AGI, "agi", handle_struct, agi_hfld },
+       { TYP_ATTR, "attr", handle_struct, attr_hfld },
+       { TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_crc_hfld },
+       { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld },
+       { TYP_BNOBT, "bnobt", handle_struct, bnobt_crc_hfld },
+       { TYP_CNTBT, "cntbt", handle_struct, cntbt_crc_hfld },
+       { TYP_DATA, "data", handle_block, NULL },
+       { TYP_DIR, "dir", handle_struct, dir_hfld },
+       { TYP_DIR2, "dir2", handle_struct, dir2_hfld },
+       { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld },
+       { TYP_INOBT, "inobt", handle_struct, inobt_crc_hfld },
+       { TYP_INODATA, "inodata", NULL, NULL },
+       { TYP_INODE, "inode", handle_struct, inode_crc_hfld },
+       { TYP_LOG, "log", NULL, NULL },
+       { TYP_RTBITMAP, "rtbitmap", NULL, NULL },
+       { TYP_RTSUMMARY, "rtsummary", NULL, NULL },
+       { TYP_SB, "sb", handle_struct, sb_hfld },
+       { TYP_SYMLINK, "symlink", handle_string, NULL },
+       { TYP_TEXT, "text", handle_text, NULL },
+       { TYP_NONE, NULL }
+};
+
+const typ_t    *typtab = __typtab;
+
+void
+type_set_tab_crc(void)
+{
+       typtab = __typtab_crc;
+}
+
 static const typ_t *
 findtyp(
        char            *name)
diff --git a/db/type.h b/db/type.h
index 8dd7925..ae92581 100644
--- a/db/type.h
+++ b/db/type.h
@@ -43,9 +43,10 @@ typedef struct typ
        pfunc_t                 pfunc;
        const struct field      *fields;
 } typ_t;
-extern const typ_t     typtab[], *cur_typ;
+extern const typ_t     *typtab, *cur_typ;
 
 extern void    type_init(void);
+extern void    type_set_tab_crc(void);
 extern void    handle_block(int action, const struct field *fields, int argc,
                             char **argv);
 extern void    handle_string(int action, const struct field *fields, int argc,
diff --git a/include/xfs_inode.h b/include/xfs_inode.h
index 9a4363f..00a29b7 100644
--- a/include/xfs_inode.h
+++ b/include/xfs_inode.h
@@ -169,9 +169,9 @@ typedef struct xfs_icdinode {
        /* structure must be padded to 64 bit alignment */
 } xfs_icdinode_t;
 
-static inline uint xfs_icdinode_size(struct xfs_icdinode *dicp)
+static inline uint xfs_icdinode_size(int version)
 {
-       if (dicp->di_version == 3)
+       if (version == 3)
                return sizeof(struct xfs_icdinode);
        return offsetof(struct xfs_icdinode, di_next_unlinked);
 }
diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index 26a8efb..90f3436 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -650,7 +650,7 @@ xlog_print_trans_inode(xfs_caddr_t *ptr, int len, int *i, 
int num_ops)
     mode = dino.di_mode & S_IFMT;
     size = (int)dino.di_size;
     xlog_print_trans_inode_core(&dino);
-    *ptr += xfs_icdinode_size(&dino);
+    *ptr += xfs_icdinode_size(dino.di_version);
 
     if (*i == num_ops-1 && f->ilf_size == 3)  {
        return 1;
diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c
index 5b2d942..26027e3 100644
--- a/logprint/log_print_all.c
+++ b/logprint/log_print_all.c
@@ -276,8 +276,8 @@ xlog_recover_print_inode(
               f->ilf_dsize);
 
        /* core inode comes 2nd */
-       ASSERT(item->ri_buf[1].i_len == xfs_icdinode_size((xfs_icdinode_t *)
-                                                       
item->ri_buf[1].i_addr));
+       ASSERT(item->ri_buf[1].i_len == xfs_icdinode_size(1) ||
+               item->ri_buf[1].i_len == xfs_icdinode_size(3));
        xlog_recover_print_inode_core((xfs_icdinode_t *)
                                      item->ri_buf[1].i_addr);
 
diff --git a/repair/phase6.c b/repair/phase6.c
index b9e0cc3..0ef96cc 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -448,8 +448,7 @@ mk_rbmino(xfs_mount_t *mp)
        }
 
        vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
-       ip->i_d.di_version = vers;
-       memset(&ip->i_d, 0, xfs_icdinode_size(&ip->i_d));
+       memset(&ip->i_d, 0, xfs_icdinode_size(vers));
 
        ip->i_d.di_magic = XFS_DINODE_MAGIC;
        ip->i_d.di_mode = S_IFREG;
@@ -698,8 +697,7 @@ mk_rsumino(xfs_mount_t *mp)
        }
 
        vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
-       ip->i_d.di_version = vers;
-       memset(&ip->i_d, 0, xfs_icdinode_size(&ip->i_d));
+       memset(&ip->i_d, 0, xfs_icdinode_size(vers));
 
        ip->i_d.di_magic = XFS_DINODE_MAGIC;
        ip->i_d.di_mode = S_IFREG;
@@ -815,8 +813,7 @@ mk_root_dir(xfs_mount_t *mp)
         * take care of the core -- initialization from xfs_ialloc()
         */
        vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
-       ip->i_d.di_version = vers;
-       memset(&ip->i_d, 0, xfs_icdinode_size(&ip->i_d));
+       memset(&ip->i_d, 0, xfs_icdinode_size(vers));
 
        ip->i_d.di_magic = XFS_DINODE_MAGIC;
        ip->i_d.di_mode = (__uint16_t) mode|S_IFDIR;
-- 
1.7.10

<Prev in Thread] Current Thread [Next in Thread>