Commit 732c8cd5 authored by Theodore Ts'o's avatar Theodore Ts'o
Browse files

Use accessor functions fields for bg_flags in the block group descriptors

Signed-off-by: default avatarValerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 24a117ab
...@@ -290,10 +290,10 @@ static void print_features(struct ext2_super_block * s, FILE *f) ...@@ -290,10 +290,10 @@ static void print_features(struct ext2_super_block * s, FILE *f)
fputs("\n", 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) const char *str, int *first, FILE *f)
{ {
if (gdp->bg_flags & mask) { if (ext2fs_bg_flag_test(fs, group, mask)) {
if (*first) { if (*first) {
fputs(" [", f); fputs(" [", f);
*first = 0; *first = 0;
...@@ -362,9 +362,9 @@ void do_show_super_stats(int argc, char *argv[]) ...@@ -362,9 +362,9 @@ void do_show_super_stats(int argc, char *argv[])
gdp->bg_itable_unused, gdp->bg_itable_unused,
gdp->bg_itable_unused != 1 ? "inodes":"inode"); gdp->bg_itable_unused != 1 ? "inodes":"inode");
first = 1; 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); &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); &first, out);
if (gdt_csum) { if (gdt_csum) {
fprintf(out, "%sChecksum 0x%04x", fprintf(out, "%sChecksum 0x%04x",
......
...@@ -987,12 +987,12 @@ out_htree: ...@@ -987,12 +987,12 @@ out_htree:
* we could call a function in pass1.c that checks the * we could call a function in pass1.c that checks the
* newly visible inodes. * 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; pctx.num = dirent->inode;
if (fix_problem(ctx, PR_2_INOREF_BG_INO_UNINIT, if (fix_problem(ctx, PR_2_INOREF_BG_INO_UNINIT,
&cd->pctx)){ &cd->pctx)){
fs->group_desc[group].bg_flags &= ext2fs_bg_flag_clear(fs, group,
~EXT2_BG_INODE_UNINIT; EXT2_BG_INODE_UNINIT);
ext2fs_mark_super_dirty(fs); ext2fs_mark_super_dirty(fs);
ctx->flags |= E2F_FLAG_RESTART_LATER; ctx->flags |= E2F_FLAG_RESTART_LATER;
} else { } else {
......
...@@ -162,7 +162,7 @@ redo_counts: ...@@ -162,7 +162,7 @@ redo_counts:
save_problem = 0; save_problem = 0;
pctx.blk = pctx.blk2 = NO_BLK; pctx.blk = pctx.blk2 = NO_BLK;
if (csum_flag && 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++; skip_group++;
for (i = fs->super->s_first_data_block; for (i = fs->super->s_first_data_block;
i < fs->super->s_blocks_count; i < fs->super->s_blocks_count;
...@@ -260,8 +260,8 @@ redo_counts: ...@@ -260,8 +260,8 @@ redo_counts:
pctx2.blk = i; pctx2.blk = i;
pctx2.group = group; pctx2.group = group;
if (fix_problem(ctx, PR_5_BLOCK_UNINIT,&pctx2)){ if (fix_problem(ctx, PR_5_BLOCK_UNINIT,&pctx2)){
fs->group_desc[group].bg_flags &= ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT)
~EXT2_BG_BLOCK_UNINIT; ;
skip_group = 0; skip_group = 0;
} }
} }
...@@ -301,8 +301,8 @@ redo_counts: ...@@ -301,8 +301,8 @@ redo_counts:
goto errout; goto errout;
if (csum_flag && if (csum_flag &&
(i != fs->super->s_blocks_count-1) && (i != fs->super->s_blocks_count-1) &&
(fs->group_desc[group].bg_flags & ext2fs_bg_flag_test(fs, group,
EXT2_BG_BLOCK_UNINIT)) EXT2_BG_BLOCK_UNINIT))
skip_group++; skip_group++;
} }
} }
...@@ -425,7 +425,7 @@ redo_counts: ...@@ -425,7 +425,7 @@ redo_counts:
save_problem = 0; save_problem = 0;
pctx.ino = pctx.ino2 = 0; pctx.ino = pctx.ino2 = 0;
if (csum_flag && 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++; skip_group++;
/* Protect loop from wrap-around if inodes_count is maxed */ /* Protect loop from wrap-around if inodes_count is maxed */
...@@ -482,8 +482,8 @@ redo_counts: ...@@ -482,8 +482,8 @@ redo_counts:
pctx2.blk = i; pctx2.blk = i;
pctx2.group = group; pctx2.group = group;
if (fix_problem(ctx, PR_5_INODE_UNINIT,&pctx2)){ if (fix_problem(ctx, PR_5_INODE_UNINIT,&pctx2)){
fs->group_desc[group].bg_flags &= ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT)
~EXT2_BG_INODE_UNINIT; ;
skip_group = 0; skip_group = 0;
} }
} }
...@@ -529,8 +529,8 @@ do_counts: ...@@ -529,8 +529,8 @@ do_counts:
goto errout; goto errout;
if (csum_flag && if (csum_flag &&
(i != fs->super->s_inodes_count) && (i != fs->super->s_inodes_count) &&
(fs->group_desc[group].bg_flags & (ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)
EXT2_BG_INODE_UNINIT)) ))
skip_group++; skip_group++;
} }
} }
......
...@@ -636,8 +636,8 @@ void check_super_block(e2fsck_t ctx) ...@@ -636,8 +636,8 @@ void check_super_block(e2fsck_t ctx)
should_be = 0; should_be = 0;
if (!ext2fs_group_desc_csum_verify(fs, i)) { if (!ext2fs_group_desc_csum_verify(fs, i)) {
if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) { if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) {
gd->bg_flags &= ~(EXT2_BG_BLOCK_UNINIT | ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
EXT2_BG_INODE_UNINIT); ext2fs_bg_flag_clear (fs, i, EXT2_BG_INODE_UNINIT);
gd->bg_itable_unused = 0; gd->bg_itable_unused = 0;
should_be = 1; should_be = 1;
} }
...@@ -645,11 +645,12 @@ void check_super_block(e2fsck_t ctx) ...@@ -645,11 +645,12 @@ void check_super_block(e2fsck_t ctx)
} }
if (!csum_flag && 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)){ gd->bg_itable_unused != 0)){
if (fix_problem(ctx, PR_0_GDT_UNINIT, &pctx)) { if (fix_problem(ctx, PR_0_GDT_UNINIT, &pctx)) {
gd->bg_flags &= ~(EXT2_BG_BLOCK_UNINIT | ext2fs_bg_flag_clear (fs, i, EXT2_BG_BLOCK_UNINIT);
EXT2_BG_INODE_UNINIT); ext2fs_bg_flag_clear (fs, i, EXT2_BG_INODE_UNINIT);
gd->bg_itable_unused = 0; gd->bg_itable_unused = 0;
should_be = 1; should_be = 1;
} }
...@@ -657,18 +658,18 @@ void check_super_block(e2fsck_t ctx) ...@@ -657,18 +658,18 @@ void check_super_block(e2fsck_t ctx)
} }
if (i == fs->group_desc_count - 1 && 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)) { 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; should_be = 1;
} }
ext2fs_unmark_valid(fs); ext2fs_unmark_valid(fs);
} }
if (gd->bg_flags & EXT2_BG_BLOCK_UNINIT && if (ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT) &&
!(gd->bg_flags & EXT2_BG_INODE_UNINIT)) { !ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT)) {
if (fix_problem(ctx, PR_0_BB_UNINIT_IB_INIT, &pctx)) { 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; should_be = 1;
} }
ext2fs_unmark_valid(fs); ext2fs_unmark_valid(fs);
......
...@@ -38,7 +38,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map, ...@@ -38,7 +38,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super, if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) || 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; return;
blk = (group * fs->super->s_blocks_per_group) + blk = (group * fs->super->s_blocks_per_group) +
...@@ -68,7 +68,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map, ...@@ -68,7 +68,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
else else
ext2fs_fast_unmark_block_bitmap2(map, blk); 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); ext2fs_group_desc_csum_set(fs, group);
} }
...@@ -82,14 +82,14 @@ static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map, ...@@ -82,14 +82,14 @@ static void check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map,
if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super, if (!(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) || 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; return;
ino = (group * fs->super->s_inodes_per_group) + 1; ino = (group * fs->super->s_inodes_per_group) + 1;
for (i=0; i < fs->super->s_inodes_per_group; i++, ino++) for (i=0; i < fs->super->s_inodes_per_group; i++, ino++)
ext2fs_fast_unmark_inode_bitmap2(map, 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); check_block_uninit(fs, fs->block_map, group);
} }
......
...@@ -62,7 +62,7 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs, ...@@ -62,7 +62,7 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
if (old_desc_blk) { if (old_desc_blk) {
if (fs->super->s_reserved_gdt_blocks && fs->block_map == bmap) 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++) for (j=0; j < old_desc_blocks; j++)
if (old_desc_blk + j < fs->super->s_blocks_count) if (old_desc_blk + j < fs->super->s_blocks_count)
ext2fs_mark_block_bitmap2(bmap, ext2fs_mark_block_bitmap2(bmap,
......
...@@ -37,7 +37,7 @@ void ext2fs_inode_alloc_stats2(ext2_filsys fs, ext2_ino_t ino, ...@@ -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 /* 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. */ * (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, if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) { EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
ext2_ino_t first_unused_inode = fs->super->s_inodes_per_group - 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) ...@@ -77,7 +77,7 @@ void ext2fs_block_alloc_stats2(ext2_filsys fs, blk64_t blk, int inuse)
else else
ext2fs_unmark_block_bitmap2(fs->block_map, blk); ext2fs_unmark_block_bitmap2(fs->block_map, blk);
fs->group_desc[group].bg_free_blocks_count -= inuse; 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_group_desc_csum_set(fs, group);
ext2fs_free_blocks_count_add(fs->super, -inuse); ext2fs_free_blocks_count_add(fs->super, -inuse);
......
...@@ -142,7 +142,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, ...@@ -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); dgrp_t gr = ext2fs_group_of_blk(fs, new_blk);
fs->group_desc[gr].bg_free_blocks_count--; fs->group_desc[gr].bg_free_blocks_count--;
fs->super->s_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); ext2fs_group_desc_csum_set(fs, gr);
} }
} }
...@@ -170,7 +170,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, ...@@ -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); dgrp_t gr = ext2fs_group_of_blk(fs, new_blk);
fs->group_desc[gr].bg_free_blocks_count--; fs->group_desc[gr].bg_free_blocks_count--;
fs->super->s_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); ext2fs_group_desc_csum_set(fs, gr);
} }
} }
...@@ -204,7 +204,8 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, ...@@ -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); dgrp_t gr = ext2fs_group_of_blk(fs, blk);
fs->group_desc[gr].bg_free_blocks_count--; fs->group_desc[gr].bg_free_blocks_count--;
fs->super->s_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); ext2fs_group_desc_csum_set(fs, gr);
} }
} }
......
...@@ -401,9 +401,9 @@ ipg_retry: ...@@ -401,9 +401,9 @@ ipg_retry:
*/ */
if (csum_flag) { if (csum_flag) {
if (i != fs->group_desc_count - 1) if (i != fs->group_desc_count - 1)
fs->group_desc[i].bg_flags |= ext2fs_bg_flag_set(fs, i, EXT2_BG_BLOCK_UNINIT)
EXT2_BG_BLOCK_UNINIT; ;
fs->group_desc[i].bg_flags |= EXT2_BG_INODE_UNINIT; ext2fs_bg_flag_set(fs, i, EXT2_BG_INODE_UNINIT);
numblocks = super->s_inodes_per_group; numblocks = super->s_inodes_per_group;
if (i == 0) if (i == 0)
numblocks -= super->s_first_ino; numblocks -= super->s_first_ino;
......
...@@ -435,8 +435,8 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, ...@@ -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. * they can be done for block group #0.
*/ */
if ((scan->scan_flags & EXT2_SF_DO_LAZY) && if ((scan->scan_flags & EXT2_SF_DO_LAZY) &&
(scan->fs->group_desc[scan->current_group].bg_flags & (ext2fs_bg_flag_test(scan->fs, scan->current_group, EXT2_BG_INODE_UNINIT)
EXT2_BG_INODE_UNINIT)) ))
goto force_new_group; goto force_new_group;
if (scan->inodes_left == 0) if (scan->inodes_left == 0)
goto force_new_group; goto force_new_group;
......
...@@ -348,11 +348,12 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, ...@@ -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, if (superblock > 1 && EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) { EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
struct ext2_group_desc *gd; struct ext2_group_desc *gd;
for (i = 0, gd = fs->group_desc; i < fs->group_desc_count; dgrp_t group;
i++, gd++) {
gd->bg_flags &= ~EXT2_BG_BLOCK_UNINIT; for (group = 0; group < fs->group_desc_count; group++) {
gd->bg_flags &= ~EXT2_BG_INODE_UNINIT; ext2fs_bg_flag_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
gd->bg_itable_unused = 0; ext2fs_bg_flag_clear(fs, group, EXT2_BG_INODE_UNINIT);
fs->group_desc[group].bg_itable_unused = 0;
} }
ext2fs_mark_super_dirty(fs); ext2fs_mark_super_dirty(fs);
} }
......
...@@ -70,8 +70,8 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) ...@@ -70,8 +70,8 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
if (!do_block) if (!do_block)
goto skip_block_bitmap; goto skip_block_bitmap;
if (csum_flag && fs->group_desc[i].bg_flags & if (csum_flag && ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT)
EXT2_BG_BLOCK_UNINIT) )
goto skip_this_block_bitmap; goto skip_this_block_bitmap;
retval = ext2fs_get_block_bitmap_range2(fs->block_map, 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) ...@@ -102,8 +102,8 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
if (!do_inode) if (!do_inode)
continue; continue;
if (csum_flag && fs->group_desc[i].bg_flags & if (csum_flag && ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT)
EXT2_BG_INODE_UNINIT) )
goto skip_this_inode_bitmap; goto skip_this_inode_bitmap;
retval = ext2fs_get_inode_bitmap_range2(fs->inode_map, 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) ...@@ -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++) { for (i = 0; i < fs->group_desc_count; i++) {
if (block_bitmap) { if (block_bitmap) {
blk = fs->group_desc[i].bg_block_bitmap; blk = fs->group_desc[i].bg_block_bitmap;
if (csum_flag && fs->group_desc[i].bg_flags & if (csum_flag &&
EXT2_BG_BLOCK_UNINIT && ext2fs_bg_flag_test(fs, i, EXT2_BG_BLOCK_UNINIT) &&
ext2fs_group_desc_csum_verify(fs, i)) ext2fs_group_desc_csum_verify(fs, i))
blk = 0; blk = 0;
if (blk) { if (blk) {
...@@ -258,8 +258,8 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) ...@@ -258,8 +258,8 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
} }
if (inode_bitmap) { if (inode_bitmap) {
blk = fs->group_desc[i].bg_inode_bitmap; blk = fs->group_desc[i].bg_inode_bitmap;
if (csum_flag && fs->group_desc[i].bg_flags & if (csum_flag &&
EXT2_BG_INODE_UNINIT && ext2fs_bg_flag_test(fs, i, EXT2_BG_INODE_UNINIT) &&
ext2fs_group_desc_csum_verify(fs, i)) ext2fs_group_desc_csum_verify(fs, i))
blk = 0; blk = 0;
if (blk) { if (blk) {
......
...@@ -113,7 +113,7 @@ static void print_bg_opts(ext2_filsys fs, dgrp_t i) ...@@ -113,7 +113,7 @@ static void print_bg_opts(ext2_filsys fs, dgrp_t i)
int first = 1, bg_flags = 0; int first = 1, bg_flags = 0;
if (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) 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", print_bg_opt(bg_flags, EXT2_BG_INODE_UNINIT, "INODE_UNINIT",
&first); &first);
......
...@@ -376,7 +376,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag) ...@@ -376,7 +376,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag)
EXT2_BLOCK_SIZE(fs->super)); EXT2_BLOCK_SIZE(fs->super));
} else { } else {
/* The kernel doesn't need to zero the itable blocks */ /* 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); ext2fs_group_desc_csum_set(fs, i);
} }
retval = ext2fs_zero_blocks(fs, blk, num, &blk, &num); retval = ext2fs_zero_blocks(fs, blk, num, &blk, &num);
......
...@@ -112,8 +112,8 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags, ...@@ -112,8 +112,8 @@ errcode_t resize_fs(ext2_filsys fs, blk_t *new_size, int flags,
fix_uninit_block_bitmaps(rfs->new_fs); fix_uninit_block_bitmaps(rfs->new_fs);
/* Clear the block bitmap uninit flag for the last block group */ /* 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 &= ext2fs_bg_flag_clear(rfs->new_fs, rfs->new_fs->group_desc_count - 1,
~EXT2_BG_BLOCK_UNINIT; EXT2_BG_BLOCK_UNINIT);
*new_size = rfs->new_fs->super->s_blocks_count; *new_size = rfs->new_fs->super->s_blocks_count;
...@@ -199,7 +199,7 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs) ...@@ -199,7 +199,7 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs)
return; return;
for (g=0; g < fs->group_desc_count; g++) { 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; continue;
blk = (g * fs->super->s_blocks_per_group) + blk = (g * fs->super->s_blocks_per_group) +
...@@ -495,10 +495,10 @@ retry: ...@@ -495,10 +495,10 @@ retry:
sizeof(struct ext2_group_desc)); sizeof(struct ext2_group_desc));
adjblocks = 0; adjblocks = 0;
fs->group_desc[i].bg_flags = 0; ext2fs_bg_flags_clear(fs, i, 0);
if (csum_flag) if (csum_flag)
fs->group_desc[i].bg_flags |= EXT2_BG_INODE_UNINIT | ext2fs_bg_flag_set(fs, i, EXT2_BG_INODE_UNINIT | EXT2_BG_INODE_ZEROED)
EXT2_BG_INODE_ZEROED; ;
if (i == fs->group_desc_count-1) { if (i == fs->group_desc_count-1) {
numblocks = (fs->super->s_blocks_count - numblocks = (fs->super->s_blocks_count -
fs->super->s_first_data_block) % fs->super->s_first_data_block) %
...@@ -508,8 +508,8 @@ retry: ...@@ -508,8 +508,8 @@ retry:
} else { } else {
numblocks = fs->super->s_blocks_per_group; numblocks = fs->super->s_blocks_per_group;
if (csum_flag) if (csum_flag)
fs->group_desc[i].bg_flags |= ext2fs_bg_flag_set(fs, i, EXT2_BG_BLOCK_UNINIT)
EXT2_BG_BLOCK_UNINIT; ;
} }
has_super = ext2fs_bg_has_super(fs, i); has_super = ext2fs_bg_has_super(fs, i);
...@@ -751,7 +751,7 @@ static void mark_fs_metablock(ext2_resize_t rfs, ...@@ -751,7 +751,7 @@ static void mark_fs_metablock(ext2_resize_t rfs,
rfs->needed_blocks++; rfs->needed_blocks++;
} else if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, } else if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM) && 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 * If the block bitmap is uninitialized, which means
* nothing other than standard metadata in use. * nothing other than standard metadata in use.
...@@ -812,7 +812,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs) ...@@ -812,7 +812,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs)
g = ext2fs_group_of_blk(fs, blk); g = ext2fs_group_of_blk(fs, blk);
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM) && 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 * The block bitmap is uninitialized, so skip
* to the next block group. * to the next block group.
...@@ -1787,7 +1787,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs) ...@@ -1787,7 +1787,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
/* /*
* First calculate the block statistics * 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, ext2fs_super_and_bgd_loc(fs, group, &super_blk, &old_desc_blk,
&new_desc_blk, 0); &new_desc_blk, 0);
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) 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) ...@@ -1821,8 +1821,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
group++; group++;
count = 0; count = 0;
group_free = 0; group_free = 0;
uninit = (fs->group_desc[group].bg_flags & uninit = (ext2fs_bg_flag_test(fs, group, EXT2_BG_BLOCK_UNINIT)
EXT2_BG_BLOCK_UNINIT); );
ext2fs_super_and_bgd_loc(fs, group, &super_blk, ext2fs_super_and_bgd_loc(fs, group, &super_blk,
&old_desc_blk, &old_desc_blk,
&new_desc_blk, 0); &new_desc_blk, 0);
...@@ -1845,7 +1845,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs) ...@@ -1845,7 +1845,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
group = 0; group = 0;
/* Protect loop from wrap-around if s_inodes_count maxed */ /* 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++) { for (ino = 1; ino <= fs->super->s_inodes_count && ino > 0; ino++) {
if (uninit || if (uninit ||
!ext2fs_fast_test_inode_bitmap2(fs->inode_map, ino)) { !ext2fs_fast_test_inode_bitmap2(fs->inode_map, ino)) {
...@@ -1861,8 +1861,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs) ...@@ -1861,8 +1861,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
group++; group++;
count = 0; count = 0;
group_free = 0; group_free = 0;
uninit = (fs->group_desc[group].bg_flags & uninit = (ext2fs_bg_flag_test(fs, group, EXT2_BG_INODE_UNINIT)
EXT2_BG_INODE_UNINIT); );
} }
} }
fs->super->s_free_inodes_count = total_free; fs->super->s_free_inodes_count = total_free;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment