#include "e2fsck.h"
#include "problem.h"
-#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
-
static void check_block_bitmaps(e2fsck_t ctx);
static void check_inode_bitmaps(e2fsck_t ctx);
static void check_inode_end(e2fsck_t ctx);
ext2fs_free_block_bitmap(ctx->block_metadata_map);
ctx->block_metadata_map = 0;
+ if (ctx->flags & E2F_FLAG_EXPAND_EISIZE) {
+ int min_extra_isize;
+
+ if (!ctx->expand_eisize_map)
+ goto set_min_extra_isize;
+
+ for (pctx.ino = 1; pctx.ino < ctx->fs->super->s_inodes_count;
+ pctx.ino++) {
+ if (ext2fs_test_inode_bitmap2(ctx->expand_eisize_map,
+ pctx.ino)) {
+ fix_problem(ctx, PR_5_EXPAND_EISIZE, &pctx);
+ ext2fs_expand_extra_isize(ctx->fs, pctx.ino, 0,
+ ctx->want_extra_isize,
+ NULL, NULL);
+ }
+ }
+ ext2fs_free_inode_bitmap(ctx->expand_eisize_map);
+
+set_min_extra_isize:
+ if (ctx->fs->super->s_min_extra_isize)
+ min_extra_isize = ctx->fs->super->s_min_extra_isize;
+ else
+ min_extra_isize = ctx->want_extra_isize;
+ if (ctx->min_extra_isize >= min_extra_isize &&
+ !ctx->fs_unexpanded_inodes) {
+ ctx->fs->super->s_min_extra_isize =ctx->min_extra_isize;
+ ctx->fs->super->s_feature_ro_compat |=
+ EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE;
+ } else {
+ ctx->fs->super->s_min_extra_isize = 0;
+ ctx->fs->super->s_feature_ro_compat &=
+ ~EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE;
+ }
+ ext2fs_mark_super_dirty(ctx->fs);
+ }
+
print_resource_track(ctx, _("Pass 5"), &rtrack, ctx->fs->io);
}
ext2_ino_t ino_itr;
errcode_t retval;
- if (!EXT2_HAS_RO_COMPAT_FEATURE(ctx->fs->super,
- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
+ if (!ext2fs_has_feature_metadata_csum(ctx->fs->super))
return;
/* If bitmap is dirty from being fixed, checksum will be corrected */
blk64_t blk_itr;
errcode_t retval;
- if (!EXT2_HAS_RO_COMPAT_FEATURE(ctx->fs->super,
- EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
+ if (!ext2fs_has_feature_metadata_csum(ctx->fs->super))
return;
/* If bitmap is dirty from being fixed, checksum will be corrected */
pctx->ino = pctx->ino2 = 0;
}
-/* Just to be more succint */
+/* Just to be more succinct */
#define B2C(x) EXT2FS_B2C(fs, (x))
#define EQ_CLSTR(x, y) (B2C(x) == B2C(y))
#define LE_CLSTR(x, y) (B2C(x) <= B2C(y))
* to do a discard operation.
*/
if (!first_block_in_bg ||
- (group == (int)fs->group_desc_count - 1) ||
+ (group == fs->group_desc_count - 1) ||
(ctx->options & E2F_OPT_DISCARD))
goto no_optimize;
ext2_filsys fs = ctx->fs;
ext2_ino_t end, save_inodes_count, i;
struct problem_context pctx;
+ int asked = 0;
clear_problem_context(&pctx);
- end = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
+ end = (__u64)EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
pctx.errcode = ext2fs_fudge_inode_bitmap_end(fs->inode_map, end,
&save_inodes_count);
if (pctx.errcode) {
return;
}
if (save_inodes_count == end)
- return;
+ goto check_intra_bg_tail;
/* protect loop from wrap-around if end is maxed */
for (i = save_inodes_count + 1; i <= end && i > save_inodes_count; i++) {
- if (!ext2fs_test_inode_bitmap(fs->inode_map, i)) {
+ if (!ext2fs_test_inode_bitmap2(fs->inode_map, i)) {
+ asked = 1;
if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx)) {
for (; i <= end; i++)
- ext2fs_mark_inode_bitmap(fs->inode_map,
+ ext2fs_mark_inode_bitmap2(fs->inode_map,
i);
ext2fs_mark_ib_dirty(fs);
} else
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
return;
}
+ /*
+ * If the number of inodes per block group != blocksize, we
+ * can also have a potential problem with the tail bits in
+ * each individual inode bitmap block. If there is a problem,
+ * it would have been noticed when the bitmap was loaded. And
+ * fixing this is easy; all we need to do force the bitmap to
+ * be written back to disk.
+ */
+check_intra_bg_tail:
+ if (!asked && fs->flags & EXT2_FLAG_IBITMAP_TAIL_PROBLEM) {
+ if (fix_problem(ctx, PR_5_INODE_BMAP_PADDING, &pctx))
+ ext2fs_mark_ib_dirty(fs);
+ else
+ ext2fs_unmark_valid(fs);
+ }
}
static void check_block_end(e2fsck_t ctx)
ext2_filsys fs = ctx->fs;
blk64_t end, save_blocks_count, i;
struct problem_context pctx;
+ int asked = 0;
clear_problem_context(&pctx);
return;
}
if (save_blocks_count == end)
- return;
+ goto check_intra_bg_tail;
/* Protect loop from wrap-around if end is maxed */
for (i = save_blocks_count + 1; i <= end && i > save_blocks_count; i++) {
if (!ext2fs_test_block_bitmap2(fs->block_map,
EXT2FS_C2B(fs, i))) {
+ asked = 1;
if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx)) {
for (; i <= end; i++)
ext2fs_mark_block_bitmap2(fs->block_map,
ctx->flags |= E2F_FLAG_ABORT; /* fatal */
return;
}
+ /*
+ * If the number of blocks per block group != blocksize, we
+ * can also have a potential problem with the tail bits in
+ * each individual block bitmap block. If there is a problem,
+ * it would have been noticed when the bitmap was loaded. And
+ * fixing this is easy; all we need to do force the bitmap to
+ * be written back to disk.
+ */
+check_intra_bg_tail:
+ if (!asked && fs->flags & EXT2_FLAG_BBITMAP_TAIL_PROBLEM) {
+ if (fix_problem(ctx, PR_5_BLOCK_BMAP_PADDING, &pctx))
+ ext2fs_mark_bb_dirty(fs);
+ else
+ ext2fs_unmark_valid(fs);
+ }
}
-
-
-