Whamcloud - gitweb
git://git.whamcloud.com
/
tools
/
e2fsprogs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
libext2fs: fix endian handling of ext3_extent_header in inline_data
[tools/e2fsprogs.git]
/
e2fsck
/
super.c
diff --git
a/e2fsck/super.c
b/e2fsck/super.c
index
b0cc440
..
1e7e749
100644
(file)
--- a/
e2fsck/super.c
+++ b/
e2fsck/super.c
@@
-30,9
+30,9
@@
static void check_super_value(e2fsck_t ctx, const char *descr,
{
struct problem_context pctx;
- if ((
(flags & MIN_CHECK) && (value < min_val)
) ||
- (
(flags & MAX_CHECK) && (value > max_val)
) ||
- (
(flags & LOG2_CHECK) && (value & (value - 1) != 0)
)) {
+ if ((
flags & MIN_CHECK && value < min_val
) ||
+ (
flags & MAX_CHECK && value > max_val
) ||
+ (
flags & LOG2_CHECK && (value & (value - 1)) != 0
)) {
clear_problem_context(&pctx);
pctx.num = value;
pctx.str = descr;
@@
-201,9
+201,9
@@
static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
ext2fs_iblk_sub_blocks(fs, inode, pb.truncated_blocks);
if (ext2fs_file_acl_block(fs, inode)) {
- retval = ext2fs_adjust_ea_refcount
2
(fs,
-
ext2fs_file_acl_block(fs, inode),
-
block_buf, -1, &count
);
+ retval = ext2fs_adjust_ea_refcount
3
(fs,
+ ext2fs_file_acl_block(fs, inode),
+
block_buf, -1, &count, ino
);
if (retval == EXT2_ET_BAD_EA_BLOCK_NUM) {
retval = 0;
count = 1;
@@
-421,7
+421,7
@@
void check_resize_inode(e2fsck_t ctx)
for (j = 1; j < fs->group_desc_count; j++) {
if (!ext2fs_bg_has_super(fs, j))
continue;
- expect = pblk +
(j * fs->super->s_blocks_per_group
);
+ expect = pblk +
EXT2_GROUPS_TO_BLOCKS(fs->super, j
);
if (ind_buf[ind_off] != expect)
goto resize_inode_invalid;
ind_off++;
@@
-570,7
+570,9
@@
void check_super_block(e2fsck_t ctx)
return;
}
- should_be = sb->s_inodes_per_group * fs->group_desc_count;
+ should_be = (blk64_t)sb->s_inodes_per_group * fs->group_desc_count;
+ if (should_be > UINT_MAX)
+ should_be = UINT_MAX;
if (sb->s_inodes_count != should_be) {
pctx.ino = sb->s_inodes_count;
pctx.ino2 = should_be;
@@
-580,6
+582,19
@@
void check_super_block(e2fsck_t ctx)
}
}
+ /* Are metadata_csum and uninit_bg both set? */
+ if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
+ EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM) &&
+ fix_problem(ctx, PR_0_META_AND_GDT_CSUM_SET, &pctx)) {
+ fs->super->s_feature_ro_compat &=
+ ~EXT4_FEATURE_RO_COMPAT_GDT_CSUM;
+ ext2fs_mark_super_dirty(fs);
+ for (i = 0; i < fs->group_desc_count; i++)
+ ext2fs_group_desc_csum_set(fs, i);
+ }
+
/* Is 64bit set and extents unset? */
if (EXT2_HAS_INCOMPAT_FEATURE(fs->super,
EXT4_FEATURE_INCOMPAT_64BIT) &&
@@
-591,14
+606,25
@@
void check_super_block(e2fsck_t ctx)
ext2fs_mark_super_dirty(fs);
}
+ if ((fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
+ (fs->super->s_first_meta_bg > fs->desc_blocks)) {
+ pctx.group = fs->desc_blocks;
+ pctx.num = fs->super->s_first_meta_bg;
+ if (fix_problem(ctx, PR_0_FIRST_META_BG_TOO_BIG, &pctx)) {
+ fs->super->s_feature_incompat &=
+ ~EXT2_FEATURE_INCOMPAT_META_BG;
+ fs->super->s_first_meta_bg = 0;
+ ext2fs_mark_super_dirty(fs);
+ }
+ }
+
/*
* Verify the group descriptors....
*/
first_block = sb->s_first_data_block;
last_block = ext2fs_blocks_count(sb)-1;
- csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
- EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
+ csum_flag = ext2fs_has_group_desc_csum(fs);
for (i = 0; i < fs->group_desc_count; i++) {
pctx.group = i;
@@
-722,10
+748,14
@@
void check_super_block(e2fsck_t ctx)
#ifndef EXT2_SKIP_UUID
/*
* If the UUID field isn't assigned, assign it.
+ * Skip if checksums are enabled and the filesystem is mounted,
+ * if the id changes under the kernel remounting rw may fail.
*/
- if (!(ctx->options & E2F_OPT_READONLY) && uuid_is_null(sb->s_uuid)) {
+ if (!(ctx->options & E2F_OPT_READONLY) && uuid_is_null(sb->s_uuid) &&
+ (!csum_flag || !(ctx->mount_flags & EXT2_MF_MOUNTED))) {
if (fix_problem(ctx, PR_0_ADD_UUID, &pctx)) {
uuid_generate(sb->s_uuid);
+ ext2fs_init_csum_seed(fs);
fs->flags |= EXT2_FLAG_DIRTY;
fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
}