]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
db: support sparse inode chunk inobt record and sb fields
authorBrian Foster <bfoster@redhat.com>
Thu, 30 Jul 2015 23:17:07 +0000 (09:17 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 30 Jul 2015 23:17:07 +0000 (09:17 +1000)
The sparse inode feature uses a different on-disk inobt record format.
Define the new record format in the xfs_db type infrastructure and use
this definition for fs' that support sparse inodes.

Also update the superblock type structure with the sb_spino_align field.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
db/btblock.c
db/btblock.h
db/field.c
db/field.h
db/init.c
db/sb.c
db/type.c
db/type.h

index 74d845bf0e79fbeba46e6bbb1d8fdeda95656577..37f96ba7d34de20c0f1feea241ff23b59983eac3 100644 (file)
@@ -392,6 +392,11 @@ const field_t      inobt_crc_hfld[] = {
        { NULL }
 };
 
+const field_t  inobt_spcrc_hfld[] = {
+       { "", FLDT_INOBT_SPCRC, 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 },
@@ -426,6 +431,26 @@ const field_t      inobt_crc_flds[] = {
          FLD_ARRAY|FLD_ABASE1|FLD_COUNT|FLD_OFFSET, TYP_INOBT },
        { NULL }
 };
+const field_t  inobt_spcrc_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_CRC, OI(OFF(u.s.bb_crc)), C1, 0, TYP_NONE },
+       { "recs", FLDT_INOBTSPREC, 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))
@@ -442,6 +467,17 @@ const field_t      inobt_rec_flds[] = {
        { "free", FLDT_INOFREE, OI(ROFF(ir_free)), C1, 0, TYP_NONE },
        { NULL }
 };
+/* sparse inode on-disk format */
+const field_t  inobt_sprec_flds[] = {
+       { "startino", FLDT_AGINO, OI(ROFF(ir_startino)), C1, 0, TYP_INODE },
+       { "holemask", FLDT_UINT16X, OI(ROFF(ir_u.sp.ir_holemask)), C1, 0,
+         TYP_NONE },
+       { "count", FLDT_UINT8D, OI(ROFF(ir_u.sp.ir_count)), C1, 0, TYP_NONE },
+       { "freecount", FLDT_INT8D, OI(ROFF(ir_u.sp.ir_freecount)), C1, 0,
+         TYP_NONE },
+       { "free", FLDT_INOFREE, OI(ROFF(ir_free)), C1, 0, TYP_NONE },
+       { NULL }
+};
 #undef ROFF
 
 
index daee060e32f5b3dcd9108fc907e3b51e020b6731..228eb367026346abe4943d5c448f77538cd32019 100644 (file)
@@ -33,9 +33,12 @@ 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_spcrc_flds[];
 extern const struct field      inobt_crc_hfld[];
+extern const struct field      inobt_spcrc_hfld[];
 extern const struct field      inobt_key_flds[];
 extern const struct field      inobt_rec_flds[];
+extern const struct field      inobt_sprec_flds[];
 
 extern const struct field      bnobt_flds[];
 extern const struct field      bnobt_hfld[];
index 816065e7471d8cf5d513fa629ddb663665a14d2e..52d9d9bd8947a22af57fba3f1df1814225c53f6d 100644 (file)
@@ -285,12 +285,16 @@ const ftattr_t    ftattrtab[] = {
          FTARG_SIZE, NULL, inobt_flds },
        { FLDT_INOBT_CRC, "inobt",  NULL, (char *)inobt_crc_flds, btblock_size,
          FTARG_SIZE, NULL, inobt_crc_flds },
+       { FLDT_INOBT_SPCRC, "inobt",  NULL, (char *)inobt_spcrc_flds,
+         btblock_size, FTARG_SIZE, NULL, inobt_spcrc_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)),
          0, fa_agblock, NULL },
        { FLDT_INOBTREC, "inobtrec", fp_sarray, (char *)inobt_rec_flds,
          SI(bitsz(xfs_inobt_rec_t)), 0, NULL, inobt_rec_flds },
+       { FLDT_INOBTSPREC, "inobtsprec", fp_sarray, (char *) inobt_sprec_flds,
+         SI(bitsz(xfs_inobt_rec_t)), 0, NULL, inobt_sprec_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,
index 6343c9ae5a529d4bba76ba90244654d150556e0a..25462406a6e0c6f0743ded62e72c758b151b91c8 100644 (file)
@@ -143,9 +143,11 @@ typedef enum fldt  {
        FLDT_INO,
        FLDT_INOBT,
        FLDT_INOBT_CRC,
+       FLDT_INOBT_SPCRC,
        FLDT_INOBTKEY,
        FLDT_INOBTPTR,
        FLDT_INOBTREC,
+       FLDT_INOBTSPREC,
        FLDT_INODE,
        FLDT_INODE_CRC,
        FLDT_INOFREE,
index e7f536a84fe3135027a01e802b2509388a94302b..f93ab1585cf24c8a99a755f44f54cc34385c5fcc 100644 (file)
--- a/db/init.c
+++ b/db/init.c
@@ -169,7 +169,9 @@ init(
                }
        }
 
-       if (xfs_sb_version_hascrc(&mp->m_sb))
+       if (xfs_sb_version_hassparseinodes(&mp->m_sb))
+               type_set_tab_spcrc();
+       else if (xfs_sb_version_hascrc(&mp->m_sb))
                type_set_tab_crc();
 
        push_cur();
diff --git a/db/sb.c b/db/sb.c
index 2be28d078fd4f466bbb8b255cd3ec797e83aeb3b..d8be938c3cd4be3d0e18acc4e03974945ee82b66 100644 (file)
--- a/db/sb.c
+++ b/db/sb.c
@@ -119,6 +119,7 @@ const field_t       sb_flds[] = {
        { "features_log_incompat", FLDT_UINT32X, OI(OFF(features_log_incompat)),
                C1, 0, TYP_NONE },
        { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE },
+       { "spino_align", FLDT_EXTLEN, OI(OFF(spino_align)), 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 }
index 0aa3137f5f891d1e15e6796eac2467eb79f6a798..8c84d660dd15a9747373dc1013d751d80f0c481d 100644 (file)
--- a/db/type.c
+++ b/db/type.c
@@ -110,6 +110,40 @@ static const typ_t __typtab_crc[] = {
        { TYP_NONE, NULL }
 };
 
+static const typ_t     __typtab_spcrc[] = {
+       { TYP_AGF, "agf", handle_struct, agf_hfld, &xfs_agf_buf_ops },
+       { TYP_AGFL, "agfl", handle_struct, agfl_crc_hfld, &xfs_agfl_buf_ops },
+       { TYP_AGI, "agi", handle_struct, agi_hfld, &xfs_agfl_buf_ops },
+       { TYP_ATTR, "attr3", handle_struct, attr3_hfld,
+               &xfs_attr3_db_buf_ops },
+       { TYP_BMAPBTA, "bmapbta", handle_struct, bmapbta_crc_hfld,
+               &xfs_bmbt_buf_ops },
+       { TYP_BMAPBTD, "bmapbtd", handle_struct, bmapbtd_crc_hfld,
+               &xfs_bmbt_buf_ops },
+       { TYP_BNOBT, "bnobt", handle_struct, bnobt_crc_hfld,
+               &xfs_allocbt_buf_ops },
+       { TYP_CNTBT, "cntbt", handle_struct, cntbt_crc_hfld,
+               &xfs_allocbt_buf_ops },
+       { TYP_DATA, "data", handle_block, NULL, NULL },
+       { TYP_DIR2, "dir3", handle_struct, dir3_hfld,
+               &xfs_dir3_db_buf_ops },
+       { TYP_DQBLK, "dqblk", handle_struct, dqblk_hfld,
+               &xfs_dquot_buf_ops },
+       { TYP_INOBT, "inobt", handle_struct, inobt_spcrc_hfld,
+               &xfs_inobt_buf_ops },
+       { TYP_INODATA, "inodata", NULL, NULL, NULL },
+       { TYP_INODE, "inode", handle_struct, inode_crc_hfld,
+               &xfs_inode_buf_ops },
+       { TYP_LOG, "log", NULL, NULL, NULL },
+       { TYP_RTBITMAP, "rtbitmap", NULL, NULL, NULL },
+       { TYP_RTSUMMARY, "rtsummary", NULL, NULL, NULL },
+       { TYP_SB, "sb", handle_struct, sb_hfld, &xfs_sb_buf_ops },
+       { TYP_SYMLINK, "symlink", handle_struct, symlink_crc_hfld,
+               &xfs_symlink_buf_ops },
+       { TYP_TEXT, "text", handle_text, NULL, NULL },
+       { TYP_NONE, NULL }
+};
+
 const typ_t    *typtab = __typtab;
 
 void
@@ -118,6 +152,12 @@ type_set_tab_crc(void)
        typtab = __typtab_crc;
 }
 
+void
+type_set_tab_spcrc(void)
+{
+       typtab = __typtab_spcrc;
+}
+
 static const typ_t *
 findtyp(
        char            *name)
index e8d8df718ac9de868d78ded13d5087d3fa8987c6..d9583e55328b0fa8cdadbd9d2e577a5780431928 100644 (file)
--- a/db/type.h
+++ b/db/type.h
@@ -48,6 +48,7 @@ extern const typ_t    *typtab, *cur_typ;
 
 extern void    type_init(void);
 extern void    type_set_tab_crc(void);
+extern void    type_set_tab_spcrc(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,