FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 05-25-2012, 03:37 PM
Steven Whitehouse
 
Default libgfs2: Use flags for versions in metadata description

Hi,

Looks good to me,

Steve.

On Fri, 2012-05-25 at 16:05 +0100, Andrew Price wrote:
> Consolidate the .gfs1 and .gfs2 fields into one .versions field and add
> constants so we can test lgfs2_metadata versions more easily.
>
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
> gfs2/edit/hexedit.c | 8 +++---
> gfs2/libgfs2/libgfs2.h | 5 ++-
> gfs2/libgfs2/meta.c | 67 ++++++++++++++++++++----------------------------
> 3 files changed, 35 insertions(+), 45 deletions(-)
>
> diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
> index b4e6d15..2ff1125 100644
> --- a/gfs2/edit/hexedit.c
> +++ b/gfs2/edit/hexedit.c
> @@ -813,14 +813,13 @@ int display_block_type(int from_restore)
> return ret_type;
> }
>
> -static const struct lgfs2_metadata *find_mtype(uint32_t mtype, int gfs1)
> +static const struct lgfs2_metadata *find_mtype(uint32_t mtype, const unsigned versions)
> {
> const struct lgfs2_metadata *m = lgfs2_metadata;
> unsigned n = 0;
>
> do {
> - if (((gfs1 && m[n].gfs1) || (!gfs1 && m[n].gfs2))
> - && m[n].mh_type == mtype)
> + if ((m[n].versions & versions) && m[n].mh_type == mtype)
> return &m[n];
> n++;
> } while (n < lgfs2_metadata_size);
> @@ -936,7 +935,8 @@ static int hexdump(uint64_t startaddr, int len)
> }
> print_gfs2("] ");
> if (print_field >= 0) {
> - const struct lgfs2_metadata *m = find_mtype(block_type, sbd.gfs1);
> + const struct lgfs2_metadata *m = find_mtype(block_type,
> + sbd.gfs1 ? LGFS2_MD_GFS1 : LGFS2_MD_GFS2);
> if (m) {
> const struct lgfs2_metafield *f;
> unsigned n;
> diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
> index 8ed08dd..2fc47de 100644
> --- a/gfs2/libgfs2/libgfs2.h
> +++ b/gfs2/libgfs2/libgfs2.h
> @@ -142,8 +142,9 @@ struct lgfs2_metafield {
> };
>
> struct lgfs2_metadata {
> - const unsigned gfs1:1;
> - const unsigned gfs2:1;
> + const unsigned versions:2;
> +#define LGFS2_MD_GFS1 0x01
> +#define LGFS2_MD_GFS2 0x02
> const unsigned header:1;
> const uint32_t mh_type;
> const uint32_t mh_format;
> diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
> index 1f796c8..a677cdc 100644
> --- a/gfs2/libgfs2/meta.c
> +++ b/gfs2/libgfs2/meta.c
> @@ -478,7 +478,7 @@ RF(bt_pad)
>
> const struct lgfs2_metadata lgfs2_metadata[] = {
> [LGFS2_MT_GFS2_SB] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_SB,
> .mh_format = GFS2_FORMAT_SB,
> @@ -488,7 +488,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_sb),
> },
> [LGFS2_MT_GFS_SB] = {
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1,
> .header = 1,
> .mh_type = GFS2_METATYPE_SB,
> .mh_format = GFS_FORMAT_SB,
> @@ -498,15 +498,14 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs_sb),
> },
> [LGFS2_MT_RINDEX] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .name = "rindex",
> .fields = gfs2_rindex_fields,
> .nfields = ARRAY_SIZE(gfs2_rindex_fields),
> .size = sizeof(struct gfs2_rindex),
> },
> [LGFS2_MT_GFS2_RGRP] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_RG,
> .mh_format = GFS2_FORMAT_RG,
> @@ -516,7 +515,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_rgrp),
> },
> [LGFS2_MT_GFS_RGRP] = {
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1,
> .header = 1,
> .mh_type = GFS2_METATYPE_RG,
> .mh_format = GFS2_FORMAT_RG,
> @@ -526,8 +525,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs_rgrp),
> },
> [LGFS2_MT_RGRP_BITMAP] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_RB,
> .mh_format = GFS2_FORMAT_RB,
> @@ -537,7 +535,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_meta_header),
> },
> [LGFS2_MT_GFS2_DINODE] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_DI,
> .mh_format = GFS2_FORMAT_DI,
> @@ -547,7 +545,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_dinode),
> },
> [LGFS2_MT_GFS_DINODE] = {
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1,
> .header = 1,
> .mh_type = GFS2_METATYPE_DI,
> .mh_format = GFS2_FORMAT_DI,
> @@ -557,7 +555,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs_dinode),
> },
> [LGFS2_MT_GFS2_INDIRECT] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_IN,
> .mh_format = GFS2_FORMAT_IN,
> @@ -567,7 +565,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_meta_header),
> },
> [LGFS2_MT_GFS_INDIRECT] = {
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1,
> .header = 1,
> .mh_type = GFS2_METATYPE_IN,
> .mh_format = GFS2_FORMAT_IN,
> @@ -577,8 +575,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs_indirect),
> },
> [LGFS2_MT_DIR_LEAF] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_LF,
> .mh_format = GFS2_FORMAT_LF,
> @@ -588,8 +585,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_leaf),
> },
> [LGFS2_MT_JRNL_DATA] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_JD,
> .mh_format = GFS2_FORMAT_JD,
> @@ -599,7 +595,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_meta_header),
> },
> [LGFS2_MT_GFS2_LOG_HEADER] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_LH,
> .mh_format = GFS2_FORMAT_LH,
> @@ -609,7 +605,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_log_header),
> },
> [LGFS2_MT_GFS_LOG_HEADER] = {
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1,
> .header = 1,
> .mh_type = GFS2_METATYPE_LH,
> .mh_format = GFS2_FORMAT_LH,
> @@ -619,7 +615,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs_log_header),
> },
> [LGFS2_MT_GFS2_LOG_DESC] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_LD,
> .mh_format = GFS2_FORMAT_LD,
> @@ -629,7 +625,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_log_descriptor),
> },
> [LGFS2_MT_GFS_LOG_DESC] = {
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1,
> .header = 1,
> .mh_type = GFS2_METATYPE_LD,
> .mh_format = GFS2_FORMAT_LD,
> @@ -639,7 +635,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs_log_descriptor),
> },
> [LGFS2_MT_GFS2_LOG_BLOCK] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_LB,
> .mh_format = GFS2_FORMAT_LB,
> @@ -649,8 +645,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_meta_header),
> },
> [LGFS2_MT_EA_ATTR] = {
> - .gfs2 = 1,
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_EA,
> .mh_format = GFS2_FORMAT_EA,
> @@ -660,8 +655,7 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_meta_header),
> },
> [LGFS2_MT_EA_DATA] = {
> - .gfs2 = 1,
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .header = 1,
> .mh_type = GFS2_METATYPE_ED,
> .mh_format = GFS2_FORMAT_ED,
> @@ -671,65 +665,60 @@ const struct lgfs2_metadata lgfs2_metadata[] = {
> .size = sizeof(struct gfs2_meta_header),
> },
> [LGFS2_MT_GFS2_QUOTA_CHANGE] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .name = "gfs2_quota_change",
> .fields = gfs2_quota_change_fields,
> .nfields = ARRAY_SIZE(gfs2_quota_change_fields),
> .size = sizeof(struct gfs2_quota_change),
> },
> [LGFS2_MT_DIRENT] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .name = "gfs2_dirent",
> .fields = gfs2_dirent_fields,
> .nfields = ARRAY_SIZE(gfs2_dirent_fields),
> .size = sizeof(struct gfs2_dirent),
> },
> [LGFS2_MT_EA_HEADER] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .name = "gfs2_ea_header",
> .fields = gfs2_ea_header_fields,
> .nfields = ARRAY_SIZE(gfs2_ea_header_fields),
> .size = sizeof(struct gfs2_ea_header),
> },
> [LGFS2_MT_GFS2_INUM_RANGE] = {
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS2,
> .name = "gfs2_inum_range",
> .fields = gfs2_inum_range_fields,
> .nfields = ARRAY_SIZE(gfs2_inum_range_fields),
> .size = sizeof(struct gfs2_inum_range),
> },
> [LGFS2_MT_STATFS_CHANGE] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .name = "gfs2_statfs_change",
> .fields = gfs2_statfs_change_fields,
> .nfields = ARRAY_SIZE(gfs2_statfs_change_fields),
> .size = sizeof(struct gfs2_statfs_change),
> },
> [LGFS2_MT_GFS_JINDEX] = {
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1,
> .name = "gfs_jindex",
> .fields = gfs_jindex_fields,
> .nfields = ARRAY_SIZE(gfs_jindex_fields),
> .size = sizeof(struct gfs_jindex),
> },
> [LGFS2_MT_GFS_BLOCK_TAG] = {
> - .gfs1 = 1,
> + .versions = LGFS2_MD_GFS1,
> .name = "gfs_block_tag",
> .fields = gfs_block_tag_fields,
> .nfields = ARRAY_SIZE(gfs_block_tag_fields),
> .size = sizeof(struct gfs_block_tag),
> },
> [LGFS2_MT_DATA] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .name = "data",
> },
> [LGFS2_MT_FREE] = {
> - .gfs1 = 1,
> - .gfs2 = 1,
> + .versions = LGFS2_MD_GFS1 | LGFS2_MD_GFS2,
> .name = "free",
> },
> };
 

Thread Tools




All times are GMT. The time now is 09:26 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org