Whamcloud - gitweb
Use accessor functions fields for bg_flags in the block group descriptors
authorTheodore Ts'o <tytso@mit.edu>
Tue, 8 Sep 2009 01:15:12 +0000 (21:15 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 8 Sep 2009 01:15:12 +0000 (21:15 -0400)
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 files changed:
debugfs/debugfs.c
e2fsck/pass2.c
e2fsck/pass5.c
e2fsck/super.c
lib/ext2fs/alloc.c
lib/ext2fs/alloc_sb.c
lib/ext2fs/alloc_stats.c
lib/ext2fs/alloc_tables.c
lib/ext2fs/initialize.c
lib/ext2fs/inode.c
lib/ext2fs/openfs.c
lib/ext2fs/rw_bitmaps.c
misc/dumpe2fs.c
misc/mke2fs.c
resize/resize2fs.c

index 93227e3..24aa664 100644 (file)
@@ -290,10 +290,10 @@ static void print_features(struct ext2_super_block * s, FILE *f)
        fputs("\n", f);
 }
 
-static void print_bg_opts(struct ext2_group_desc *gdp, int mask,
+static void print_bg_opts(ext2_filsys fs, dgrp_t group, int mask,
                          const char *str, int *first, FILE *f)
 {
-       if (gdp->bg_flags & mask) {
+       if (ext2fs_bg_flag_test(fs, group, mask)) {
                if (*first) {
                        fputs("           [", f);
                        *first = 0;
@@ -362,9 +362,9 @@ void do_show_super_stats(int argc, char *argv[])
                                gdp->bg_itable_unused,
                                gdp->bg_itable_unused != 1 ? "inodes":"inode");
                first = 1;
-               print_bg_opts(gdp, EXT2_BG_INODE_UNINIT, "Inode not init",
+               print_bg_opts(current_fs, i, EXT2_BG_INODE_UNINIT, "Inode not init",
                              &first, out);
-               print_bg_opts(gdp, EXT2_BG_BLOCK_UNINIT, "Block not init",
+               print_bg_opts(current_fs, i, EXT2_BG_BLOCK_UNINIT, "Block not init",
                              &first, out);
                if (gdt_csum) {
                        fprintf(out, "%sChecksum 0x%04x",
index 7073844..b7ce352 100644 (file)
@@ -987,12 +987,12 @@ out_htree:
                 * we could call a function in pass1.c that checks the
                 * newly visible inodes.
                 */
-               if (fs->group_desc[group].bg_flags & EXT2_BG_INODE_UNINIT) {
+               if (ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)) {
                        pctx.num = dirent->inode;
                        if (fix_problem(ctx, PR_2_INOREF_BG_INO_UNINIT,
                                        &cd->pctx)){
-                               fs->group_desc[group].bg_flags &=
-                                       ~EXT2_BG_INODE_UNINIT;
+                               ext2fs_bg_flag_clear(fs, group,
+                                                     EXT2_BG_INODE_UNINIT);
                                ext2fs_mark_super_dirty(fs);
                                ctx->flags |= E2F_FLAG_RESTART_LATER;
                        } else {
index 232bee0..a2a00b1 100644 (file)
@@ -162,7 +162,7 @@ redo_counts:
        save_problem = 0;
        pctx.blk = pctx.blk2 = NO_BLK;
        if (csum_flag &&
-           (fs->group_desc[group].bg_flags & EXT2_BG_BLOCK_UNINIT))
+           (ext2fs_bg_flag_test(fs, group, EXT2_BG_BLOCK_UNINIT)))
                skip_group++;
        for (i = fs->super->s_first_data_block;
             i < fs->super->s_blocks_count;
@@ -260,8 +260,8 @@ redo_counts:
                                pctx2.blk = i;
                                pctx2.group = group;
                                if (fix_problem(ctx, PR_5_BLOCK_UNINIT,&pctx2)){
-                                       fs->group_desc[group].bg_flags &=
-                                               ~EXT2_BG_BLOCK_UNINIT;
+                                       ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT)
+                                               ;
                                        skip_group = 0;
                                }
                        }
@@ -301,8 +301,8 @@ redo_counts:
                                        goto errout;
                        if (csum_flag &&
                            (i != fs->super->s_blocks_count-1) &&
-                           (fs->group_desc[group].bg_flags &
-                            EXT2_BG_BLOCK_UNINIT))
+                           ext2fs_bg_flag_test(fs, group, 
+                                               EXT2_BG_BLOCK_UNINIT))
                                skip_group++;
                }
        }
@@ -425,7 +425,7 @@ redo_counts:
        save_problem = 0;
        pctx.ino = pctx.ino2 = 0;
        if (csum_flag &&
-           (fs->group_desc[group].bg_flags & EXT2_BG_INODE_UNINIT))
+           (ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)))
                skip_group++;
 
        /* Protect loop from wrap-around if inodes_count is maxed */
@@ -482,8 +482,8 @@ redo_counts:
                                pctx2.blk = i;
                                pctx2.group = group;
                                if (fix_problem(ctx, PR_5_INODE_UNINIT,&pctx2)){
-                                       fs->group_desc[group].bg_flags &=
-                                               ~EXT2_BG_INODE_UNINIT;
+                                       ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT)
+                                               ;
                                        skip_group = 0;
                                }
                        }
@@ -529,8 +529,8 @@ do_counts:
                                        goto errout;
                        if (csum_flag &&
                            (i != fs->super->s_inodes_count) &&
-                           (fs->group_desc[group].bg_flags &
-                            EXT2_BG_INODE_UNINIT))
+                           (ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)
+                            ))
                                skip_group++;
                }
        }
index 72d3268..2d5d661 100644 (file)
@@ -636,8 +636,8 @@ void check_super_block(e2fsck_t ctx)
                should_be = 0;
                if (!ext2fs_group_desc_csum_verify(fs, i)) {
                        if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) {
-                               gd->bg_flags &= ~(EXT2_BG_BLOCK_UNINIT |
-                                                 EXT2_BG_INODE_UNINIT);
+                               ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
+                               ext2fs_bg_flag_clear (fs, i, EXT2_BG_INODE_UNINIT);
                                gd->bg_itable_unused = 0;
                                should_be = 1;
                        }
@@ -645,11 +645,12 @@ void check_super_block(e2fsck_t ctx)
                }
 
                if (!csum_flag &&
-                   (gd->bg_flags &(EXT2_BG_BLOCK_UNINIT|EXT2_BG_INODE_UNINIT)||
+                   (ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT) ||
+                    ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT) ||
                     gd->bg_itable_unused != 0)){
                        if (fix_problem(ctx, PR_0_GDT_UNINIT, &pctx)) {
-                               gd->bg_flags &= ~(EXT2_BG_BLOCK_UNINIT |
-                                                 EXT2_BG_INODE_UNINIT);
+                               ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
+                               ext2fs_bg_flag_clear (fs, i, EXT2_BG_INODE_UNINIT);
                                gd->bg_itable_unused = 0;
                                should_be = 1;
                        }
@@ -657,18 +658,18 @@ void check_super_block(e2fsck_t ctx)
                }
 
                if (i == fs->group_desc_count - 1 &&
-                   gd->bg_flags & EXT2_BG_BLOCK_UNINIT) {
+                   ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT)) {
                        if (fix_problem(ctx, PR_0_BB_UNINIT_LAST, &pctx)) {
-                               gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+                               ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
                                should_be = 1;
                        }
                        ext2fs_unmark_valid(fs);
                }
 
-               if (gd->bg_flags & EXT2_BG_BLOCK_UNINIT &&
-                   !(gd->bg_flags & EXT2_BG_INODE_UNINIT)) {
+               if (ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT) &&
+                   !ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT)) {
                        if (fix_problem(ctx, PR_0_BB_UNINIT_IB_INIT, &pctx)) {
-                               gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+                               ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
                                should_be = 1;
                        }
                        ext2fs_unmark_valid(fs);
index 2dbae87..2c38bc9 100644 (file)
@@ -38,7 +38,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
 
        if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                         EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) ||
-           !(fs->group_desc[group].bg_flags & EXT2_BG_BLOCK_UNINIT))
+           !(ext2fs_bg_flag_test(fs, group, EXT2_BG_BLOCK_UNINIT)))
                return;
 
        blk = (group * fs->super->s_blocks_per_group) +
@@ -68,7 +68,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
                else
                        ext2fs_fast_unmark_block_bitmap2(map, blk);
        }
-       fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+       ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
        ext2fs_group_desc_csum_set(fs, group);
 }
 
@@ -82,14 +82,14 @@ static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map,
 
        if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                         EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) ||
-           !(fs->group_desc[group].bg_flags & EXT2_BG_INODE_UNINIT))
+           !(ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)))
                return;
 
        ino = (group * fs->super->s_inodes_per_group) + 1;
        for (i=0; i < fs->super->s_inodes_per_group; i++, ino++)
                ext2fs_fast_unmark_inode_bitmap2(map, ino);
 
-       fs->group_desc[group].bg_flags &= ~EXT2_BG_INODE_UNINIT;
+       ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT);
        check_block_uninit(fs, fs->block_map, group);
 }
 
index d9080b6..8bb8827 100644 (file)
@@ -62,7 +62,7 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
 
        if (old_desc_blk) {
                if (fs->super->s_reserved_gdt_blocks && fs->block_map == bmap)
-                       fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+                       ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
                for (j=0; j < old_desc_blocks; j++)
                        if (old_desc_blk + j < fs->super->s_blocks_count)
                                ext2fs_mark_block_bitmap2(bmap,
index 5048787..9180b5c 100644 (file)
@@ -37,7 +37,7 @@ void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino,
 
        /* We don't strictly need to be clearing the uninit flag if inuse < 0
         * (i.e. freeing inodes) but it also means something is bad. */
-       fs->group_desc[group].bg_flags &= ~EXT2_BG_INODE_UNINIT;
+       ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT);
        if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                       EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
                ext2_ino_t first_unused_inode = fs->super->s_inodes_per_group -
@@ -77,7 +77,7 @@ void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
        else
                ext2fs_unmark_block_bitmap2(fs->block_map, blk);
        fs->group_desc[group].bg_free_blocks_count -= inuse;
-       fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+       ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
        ext2fs_group_desc_csum_set(fs, group);
 
        ext2fs_free_blocks_count_add(fs->super, -inuse);
index c7d50d0..a72cac6 100644 (file)
@@ -142,7 +142,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
                        dgrp_t gr = ext2fs_group_of_blk(fs, new_blk);
                        fs->group_desc[gr].bg_free_blocks_count--;
                        fs->super->s_free_blocks_count--;
-                       fs->group_desc[gr].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+                       ext2fs_bg_flag_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
                        ext2fs_group_desc_csum_set(fs, gr);
                }
        }
@@ -170,7 +170,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
                        dgrp_t gr = ext2fs_group_of_blk(fs, new_blk);
                        fs->group_desc[gr].bg_free_blocks_count--;
                        fs->super->s_free_blocks_count--;
-                       fs->group_desc[gr].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+                       ext2fs_bg_flag_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
                        ext2fs_group_desc_csum_set(fs, gr);
                }
        }
@@ -204,7 +204,8 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
                                dgrp_t gr = ext2fs_group_of_blk(fs, blk);
                                fs->group_desc[gr].bg_free_blocks_count--;
                                fs->super->s_free_blocks_count--;
-                               fs->group_desc[gr].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
+                               ext2fs_bg_flag_clear(fs, gr,
+                                                    EXT2_BG_BLOCK_UNINIT);
                                ext2fs_group_desc_csum_set(fs, gr);
                        }
                }
index 21fc293..73c4fec 100644 (file)
@@ -401,9 +401,9 @@ ipg_retry:
                 */
                if (csum_flag) {
                        if (i != fs->group_desc_count - 1)
-                               fs->group_desc[i].bg_flags |=
-                                       EXT2_BG_BLOCK_UNINIT;
-                       fs->group_desc[i].bg_flags |= EXT2_BG_INODE_UNINIT;
+                               ext2fs_bg_flag_set(fs, i, EXT2_BG_BLOCK_UNINIT)
+                                       ;
+                       ext2fs_bg_flag_set(fs, i, EXT2_BG_INODE_UNINIT);
                        numblocks = super->s_inodes_per_group;
                        if (i == 0)
                                numblocks -= super->s_first_ino;
index 365d8c8..e439b1c 100644 (file)
@@ -435,8 +435,8 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
         * they can be done for block group #0.
         */
        if ((scan->scan_flags & EXT2_SF_DO_LAZY) &&
-           (scan->fs->group_desc[scan->current_group].bg_flags &
-            EXT2_BG_INODE_UNINIT))
+           (ext2fs_bg_flag_test(scan->fs, scan->current_group, EXT2_BG_INODE_UNINIT)
+            ))
                goto force_new_group;
        if (scan->inodes_left == 0)
                goto force_new_group;
index 3c0563a..2d78290 100644 (file)
@@ -348,11 +348,12 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
        if (superblock > 1 && EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                        EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
                struct ext2_group_desc *gd;
-               for (i = 0, gd = fs->group_desc; i < fs->group_desc_count;
-                    i++, gd++) {
-                       gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
-                       gd->bg_flags &= ~EXT2_BG_INODE_UNINIT;
-                       gd->bg_itable_unused = 0;
+               dgrp_t group;
+
+               for (group = 0; group < fs->group_desc_count; group++) {
+                       ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+                       ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT);
+                       fs->group_desc[group].bg_itable_unused = 0;
                }
                ext2fs_mark_super_dirty(fs);
        }
index 0792c5b..08d3a5e 100644 (file)
@@ -70,8 +70,8 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                if (!do_block)
                        goto skip_block_bitmap;
 
-               if (csum_flag && fs->group_desc[i].bg_flags &
-                   EXT2_BG_BLOCK_UNINIT)
+               if (csum_flag && ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT)
+                   )
                        goto skip_this_block_bitmap;
 
                retval = ext2fs_get_block_bitmap_range2(fs->block_map,
@@ -102,8 +102,8 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                if (!do_inode)
                        continue;
 
-               if (csum_flag && fs->group_desc[i].bg_flags &
-                   EXT2_BG_INODE_UNINIT)
+               if (csum_flag && ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT)
+                   )
                        goto skip_this_inode_bitmap;
 
                retval = ext2fs_get_inode_bitmap_range2(fs->inode_map,
@@ -236,8 +236,8 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
        for (i = 0; i < fs->group_desc_count; i++) {
                if (block_bitmap) {
                        blk = fs->group_desc[i].bg_block_bitmap;
-                       if (csum_flag && fs->group_desc[i].bg_flags &
-                           EXT2_BG_BLOCK_UNINIT &&
+                       if (csum_flag &&
+                           ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT) &&
                            ext2fs_group_desc_csum_verify(fs, i))
                                blk = 0;
                        if (blk) {
@@ -258,8 +258,8 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
                }
                if (inode_bitmap) {
                        blk = fs->group_desc[i].bg_inode_bitmap;
-                       if (csum_flag && fs->group_desc[i].bg_flags &
-                           EXT2_BG_INODE_UNINIT &&
+                       if (csum_flag &&
+                           ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT) &&
                            ext2fs_group_desc_csum_verify(fs, i))
                                blk = 0;
                        if (blk) {
index 37b75a1..62eb1c7 100644 (file)
@@ -113,7 +113,7 @@ static void print_bg_opts(ext2_filsys fs, dgrp_t i)
        int first = 1, bg_flags = 0;
 
        if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM)
-               bg_flags = fs->group_desc[i].bg_flags;
+               bg_flags = ext2fs_bg_flags(fs, i);
 
        print_bg_opt(bg_flags, EXT2_BG_INODE_UNINIT, "INODE_UNINIT",
                     &first);
index 0ce6017..ff02d39 100644 (file)
@@ -376,7 +376,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag)
                               EXT2_BLOCK_SIZE(fs->super));
                } else {
                        /* The kernel doesn't need to zero the itable blocks */
-                       fs->group_desc[i].bg_flags |= EXT2_BG_INODE_ZEROED;
+                       ext2fs_bg_flag_set(fs, i, EXT2_BG_INODE_ZEROED);
                        ext2fs_group_desc_csum_set(fs, i);
                }
                retval = ext2fs_zero_blocks(fs, blk, num, &blk, &num);
index 2e97177..dc35001 100644 (file)
@@ -112,8 +112,8 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags,
 
        fix_uninit_block_bitmaps(rfs->new_fs);
        /* Clear the block bitmap uninit flag for the last block group */
-       rfs->new_fs->group_desc[rfs->new_fs->group_desc_count-1].bg_flags &=
-               ~EXT2_BG_BLOCK_UNINIT;
+       ext2fs_bg_flag_clear(rfs->new_fs, rfs->new_fs->group_desc_count - 1,
+                            EXT2_BG_BLOCK_UNINIT);
 
        *new_size = rfs->new_fs->super->s_blocks_count;
 
@@ -199,7 +199,7 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs)
                return;
 
        for (g=0; g < fs->group_desc_count; g++) {
-               if (!(fs->group_desc[g].bg_flags & EXT2_BG_BLOCK_UNINIT))
+               if (!(ext2fs_bg_flag_test(fs, g, EXT2_BG_BLOCK_UNINIT)))
                        continue;
 
                blk = (g * fs->super->s_blocks_per_group) +
@@ -495,10 +495,10 @@ retry:
                       sizeof(struct ext2_group_desc));
                adjblocks = 0;
 
-               fs->group_desc[i].bg_flags = 0;
+               ext2fs_bg_flags_clear(fs, i, 0);
                if (csum_flag)
-                       fs->group_desc[i].bg_flags |= EXT2_BG_INODE_UNINIT |
-                               EXT2_BG_INODE_ZEROED;
+                       ext2fs_bg_flag_set(fs, i, EXT2_BG_INODE_UNINIT | EXT2_BG_INODE_ZEROED)
+                               ;
                if (i == fs->group_desc_count-1) {
                        numblocks = (fs->super->s_blocks_count -
                                     fs->super->s_first_data_block) %
@@ -508,8 +508,8 @@ retry:
                } else {
                        numblocks = fs->super->s_blocks_per_group;
                        if (csum_flag)
-                               fs->group_desc[i].bg_flags |=
-                                       EXT2_BG_BLOCK_UNINIT;
+                               ext2fs_bg_flag_set(fs, i, EXT2_BG_BLOCK_UNINIT)
+                                       ;
                }
 
                has_super = ext2fs_bg_has_super(fs, i);
@@ -751,7 +751,7 @@ static void mark_fs_metablock(ext2_resize_t rfs,
                rfs->needed_blocks++;
        } else if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                              EXT4_FEATURE_RO_COMPAT_GDT_CSUM) &&
-                  (fs->group_desc[group].bg_flags & EXT2_BG_BLOCK_UNINIT)) {
+                  (ext2fs_bg_flag_test(fs, group, EXT2_BG_BLOCK_UNINIT))) {
                /*
                 * If the block bitmap is uninitialized, which means
                 * nothing other than standard metadata in use.
@@ -812,7 +812,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs)
                g = ext2fs_group_of_blk(fs, blk);
                if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                               EXT4_FEATURE_RO_COMPAT_GDT_CSUM) &&
-                   (old_fs->group_desc[g].bg_flags & EXT2_BG_BLOCK_UNINIT)) {
+                   ext2fs_bg_flag_test(old_fs, g, EXT2_BG_BLOCK_UNINIT)) {
                        /*
                         * The block bitmap is uninitialized, so skip
                         * to the next block group.
@@ -1787,7 +1787,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
        /*
         * First calculate the block statistics
         */
-       uninit = fs->group_desc[group].bg_flags & EXT2_BG_BLOCK_UNINIT;
+       uninit = ext2fs_bg_flag_test(fs, group, EXT2_BG_BLOCK_UNINIT);
        ext2fs_super_and_bgd_loc(fs, group, &super_blk, &old_desc_blk,
                                 &new_desc_blk, 0);
        if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
@@ -1821,8 +1821,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
                        group++;
                        count = 0;
                        group_free = 0;
-                       uninit = (fs->group_desc[group].bg_flags &
-                                 EXT2_BG_BLOCK_UNINIT);
+                       uninit = (ext2fs_bg_flag_test(fs, group, EXT2_BG_BLOCK_UNINIT)
+                                 );
                        ext2fs_super_and_bgd_loc(fs, group, &super_blk,
                                                 &old_desc_blk,
                                                 &new_desc_blk, 0);
@@ -1845,7 +1845,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
        group = 0;
 
        /* Protect loop from wrap-around if s_inodes_count maxed */
-       uninit = fs->group_desc[group].bg_flags & EXT2_BG_INODE_UNINIT;
+       uninit = ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT);
        for (ino = 1; ino <= fs->super->s_inodes_count && ino > 0; ino++) {
                if (uninit ||
                    !ext2fs_fast_test_inode_bitmap2(fs->inode_map, ino)) {
@@ -1861,8 +1861,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
                        group++;
                        count = 0;
                        group_free = 0;
-                       uninit = (fs->group_desc[group].bg_flags &
-                                 EXT2_BG_INODE_UNINIT);
+                       uninit = (ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)
+                                 );
                }
        }
        fs->super->s_free_inodes_count = total_free;