Merge branch 'maint' into next

Conflicts:
	lib/ext2fs/initialize.c
This commit is contained in:
Theodore Ts'o 2011-02-27 19:47:44 -05:00
commit 829d999488
14 changed files with 89 additions and 64 deletions

View File

@ -74,9 +74,9 @@ static struct field_set_info super_fields[] = {
{ "free_inodes_count", &set_sb.s_free_inodes_count, 4, parse_uint },
{ "first_data_block", &set_sb.s_first_data_block, 4, parse_uint },
{ "log_block_size", &set_sb.s_log_block_size, 4, parse_uint },
{ "log_frag_size", &set_sb.s_log_frag_size, 4, parse_int },
{ "log_cluster_size", &set_sb.s_log_cluster_size, 4, parse_int },
{ "blocks_per_group", &set_sb.s_blocks_per_group, 4, parse_uint },
{ "frags_per_group", &set_sb.s_frags_per_group, 4, parse_uint },
{ "clusters_per_group", &set_sb.s_clusters_per_group, 4, parse_uint },
{ "inodes_per_group", &set_sb.s_inodes_per_group, 4, parse_uint },
{ "mtime", &set_sb.s_mtime, 4, parse_time },
{ "wtime", &set_sb.s_wtime, 4, parse_time },
@ -141,6 +141,8 @@ static struct field_set_info super_fields[] = {
parse_uint },
{ "snapshot_list", &set_sb.s_snapshot_list, 4, parse_uint },
{ "mount_opts", &set_sb.s_mount_opts, 64, parse_string },
{ "usr_quota_inum", &set_sb.s_usr_quota_inum, 4, parse_uint },
{ "grp_quota_inum", &set_sb.s_grp_quota_inum, 4, parse_uint },
{ 0, 0, 0, 0 }
};

View File

@ -151,8 +151,8 @@ static const char *special_inode_name[] =
N_("<The NULL inode>"), /* 0 */
N_("<The bad blocks inode>"), /* 1 */
"/", /* 2 */
N_("<The ACL index inode>"), /* 3 */
N_("<The ACL data inode>"), /* 4 */
N_("<The user quota inode>"), /* 3 */
N_("<The group quota inode>"), /* 4 */
N_("<The boot loader inode>"), /* 5 */
N_("<The undelete directory inode>"), /* 6 */
N_("<The group descriptor inode>"), /* 7 */

View File

@ -502,9 +502,12 @@ void check_super_block(e2fsck_t ctx)
check_super_value(ctx, "log_block_size", sb->s_log_block_size,
MIN_CHECK | MAX_CHECK, 0,
EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE);
check_super_value(ctx, "log_frag_size", sb->s_log_frag_size,
MIN_CHECK | MAX_CHECK, 0, sb->s_log_block_size);
check_super_value(ctx, "frags_per_group", sb->s_frags_per_group,
check_super_value(ctx, "log_cluster_size",
sb->s_log_cluster_size,
MIN_CHECK | MAX_CHECK, sb->s_log_block_size,
(EXT2_MAX_CLUSTER_LOG_SIZE -
EXT2_MIN_CLUSTER_LOG_SIZE));
check_super_value(ctx, "clusters_per_group", sb->s_clusters_per_group,
MIN_CHECK | MAX_CHECK, sb->s_blocks_per_group,
bpg_max);
check_super_value(ctx, "blocks_per_group", sb->s_blocks_per_group,
@ -542,24 +545,14 @@ void check_super_block(e2fsck_t ctx)
}
}
if (sb->s_log_block_size != (__u32) sb->s_log_frag_size) {
if (sb->s_log_block_size != (__u32) sb->s_log_cluster_size) {
pctx.blk = EXT2_BLOCK_SIZE(sb);
pctx.blk2 = EXT2_FRAG_SIZE(sb);
pctx.blk2 = EXT2_CLUSTER_SIZE(sb);
fix_problem(ctx, PR_0_NO_FRAGMENTS, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
return;
}
should_be = sb->s_frags_per_group >>
(sb->s_log_block_size - sb->s_log_frag_size);
if (sb->s_blocks_per_group != should_be) {
pctx.blk = sb->s_blocks_per_group;
pctx.blk2 = should_be;
fix_problem(ctx, PR_0_BLOCKS_PER_GROUP, &pctx);
ctx->flags |= E2F_FLAG_ABORT;
return;
}
should_be = (sb->s_log_block_size == 0) ? 1 : 0;
if (sb->s_first_data_block != should_be) {
pctx.blk = sb->s_first_data_block;

View File

@ -222,11 +222,11 @@ void type_ext2_inode___show (char *command_line)
case EXT2_ROOT_INO:
wprintw (show_win,"Root inode - ");
break;
case EXT2_ACL_IDX_INO:
wprintw (show_win,"ACL index inode - ");
case EXT4_USR_QUOTA_INO:
wprintw (show_win,"User quota inode - ");
break;
case EXT2_ACL_DATA_INO:
wprintw (show_win,"ACL data inode - ");
case EXT4_GRP_QUOTA_INO:
wprintw (show_win,"Group quota inode - ");
break;
case EXT2_BOOT_LOADER_INO:
wprintw (show_win,"Boot loader inode - ");

View File

@ -109,6 +109,7 @@ struct ext2_super_block {
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
/* for s_feature_incompat */
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002

View File

@ -55,6 +55,10 @@ static struct feature feature_list[] = {
"dir_nlink" },
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE,
"extra_isize" },
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_QUOTA,
"quota" },
{ E2P_FEATURE_RO_INCOMPAT, EXT4_FEATURE_RO_COMPAT_BIGALLOC,
"bigalloc"},
{ E2P_FEATURE_INCOMPAT, EXT2_FEATURE_INCOMPAT_COMPRESSION,
"compression" },

View File

@ -249,12 +249,22 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
fprintf(f, "Free inodes: %u\n", sb->s_free_inodes_count);
fprintf(f, "First block: %u\n", sb->s_first_data_block);
fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb));
fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb));
if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC)
fprintf(f, "Cluster size: %u\n",
EXT2_CLUSTER_SIZE(sb));
else
fprintf(f, "Fragment size: %u\n",
EXT2_CLUSTER_SIZE(sb));
if (sb->s_reserved_gdt_blocks)
fprintf(f, "Reserved GDT blocks: %u\n",
sb->s_reserved_gdt_blocks);
fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group);
fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group);
if (sb->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC)
fprintf(f, "Clusters per group: %u\n",
sb->s_clusters_per_group);
else
fprintf(f, "Fragments per group: %u\n",
sb->s_clusters_per_group);
fprintf(f, "Inodes per group: %u\n", sb->s_inodes_per_group);
fprintf(f, "Inode blocks per group: %u\n", inode_blocks_per_group);
if (sb->s_raid_stride)
@ -394,6 +404,12 @@ void list_super2(struct ext2_super_block * sb, FILE *f)
fprintf(f, "Last error block #: %llu\n",
sb->s_last_error_block);
}
if (sb->s_usr_quota_inum)
fprintf(f, "User quota inode: %u\n",
sb->s_usr_quota_inum);
if (sb->s_grp_quota_inum)
fprintf(f, "Group quota inode: %u\n",
sb->s_grp_quota_inum);
}
void list_super (struct ext2_super_block * s)

View File

@ -44,8 +44,8 @@
*/
#define EXT2_BAD_INO 1 /* Bad blocks inode */
#define EXT2_ROOT_INO 2 /* Root inode */
#define EXT2_ACL_IDX_INO 3 /* ACL inode */
#define EXT2_ACL_DATA_INO 4 /* ACL inode */
#define EXT4_USR_QUOTA_INO 3 /* User quota inode */
#define EXT4_GRP_QUOTA_INO 4 /* Group quota inode */
#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */
@ -98,18 +98,15 @@
#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32))
/*
* Macro-instructions used to manage fragments
* Macro-instructions used to manage allocation clusters
*/
#define EXT2_MIN_FRAG_SIZE EXT2_MIN_BLOCK_SIZE
#define EXT2_MAX_FRAG_SIZE EXT2_MAX_BLOCK_SIZE
#define EXT2_MIN_FRAG_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
#ifdef __KERNEL__
# define EXT2_FRAG_SIZE(s) (EXT2_SB(s)->s_frag_size)
# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_SB(s)->s_frags_per_block)
#else
# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
#endif
#define EXT2_MIN_CLUSTER_LOG_SIZE EXT2_MIN_BLOCK_LOG_SIZE
#define EXT2_MAX_CLUSTER_LOG_SIZE 29 /* 512MB */
#define EXT2_MIN_CLUSTER_SIZE EXT2_MIN_BLOCK_SIZE
#define EXT2_MAX_CLUSTER_SIZE (1 << EXT2_MAX_CLUSTER_LOG_SIZE)
#define EXT2_CLUSTER_SIZE(s) (EXT2_MIN_BLOCK_SIZE << \
(s)->s_log_cluster_size)
#define EXT2_CLUSTER_SIZE_BITS(s) ((s)->s_log_cluster_size + 10)
/*
* ACL structures
@ -521,9 +518,9 @@ struct ext2_super_block {
__u32 s_free_inodes_count; /* Free inodes count */
__u32 s_first_data_block; /* First Data Block */
__u32 s_log_block_size; /* Block size */
__s32 s_log_frag_size; /* Fragment size */
__s32 s_log_cluster_size; /* Allocation cluster size */
__u32 s_blocks_per_group; /* # Blocks per group */
__u32 s_frags_per_group; /* # Fragments per group */
__u32 s_clusters_per_group; /* # Fragments per group */
__u32 s_inodes_per_group; /* # Inodes per group */
__u32 s_mtime; /* Mount time */
__u32 s_wtime; /* Write time */
@ -617,7 +614,9 @@ struct ext2_super_block {
__u8 s_last_error_func[32]; /* function where the error happened */
#define EXT4_S_ERR_END ext4_offsetof(struct ext2_super_block, s_mount_opts)
__u8 s_mount_opts[64];
__u32 s_reserved[112]; /* Padding to the end of the block */
__u32 s_usr_quota_inum; /* inode number of user quota file */
__u32 s_grp_quota_inum; /* inode number of group quota file */
__u32 s_reserved[110]; /* Padding to the end of the block */
};
#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
@ -675,6 +674,8 @@ struct ext2_super_block {
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
#define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
#define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
@ -688,7 +689,6 @@ struct ext2_super_block {
#define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400
#define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000
#define EXT2_FEATURE_COMPAT_SUPP 0
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \

View File

@ -207,7 +207,7 @@ struct struct_ext2_filsys {
char * device_name;
struct ext2_super_block * super;
unsigned int blocksize;
int fragsize;
int clustersize;
dgrp_t group_desc_count;
unsigned long desc_blocks;
struct opaque_ext2_group_desc * group_desc;
@ -560,7 +560,7 @@ typedef struct ext2_icount *ext2_icount_t;
* to ext2fs_openfs()
*/
#define EXT2_LIB_SOFTSUPP_INCOMPAT (0)
#define EXT2_LIB_SOFTSUPP_RO_COMPAT (0)
#define EXT2_LIB_SOFTSUPP_RO_COMPAT (EXT4_FEATURE_RO_COMPAT_BIGALLOC)
/*
* function prototypes

View File

@ -87,7 +87,6 @@ errcode_t ext2fs_initialize(const char *name, int flags,
ext2_filsys fs;
errcode_t retval;
struct ext2_super_block *super;
int frags_per_block;
unsigned int rem;
unsigned int overhead = 0;
unsigned int ipg;
@ -140,7 +139,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
super->s_state = EXT2_VALID_FS;
set_field(s_log_block_size, 0); /* default blocksize: 1024 bytes */
set_field(s_log_frag_size, 0); /* default fragsize: 1024 bytes */
set_field(s_log_cluster_size, 0);
set_field(s_first_data_block, super->s_log_block_size ? 0 : 1);
set_field(s_max_mnt_count, 0);
set_field(s_errors, EXT2_ERRORS_DEFAULT);
@ -183,14 +182,13 @@ errcode_t ext2fs_initialize(const char *name, int flags,
super->s_creator_os = CREATOR_OS;
fs->blocksize = EXT2_BLOCK_SIZE(super);
fs->fragsize = EXT2_FRAG_SIZE(super);
frags_per_block = fs->blocksize / fs->fragsize;
fs->clustersize = EXT2_CLUSTER_SIZE(super);
/* default: (fs->blocksize*8) blocks/group, up to 2^16 (GDT limit) */
set_field(s_blocks_per_group, fs->blocksize * 8);
if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super))
super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super);
super->s_frags_per_group = super->s_blocks_per_group * frags_per_block;
super->s_clusters_per_group = super->s_blocks_per_group;
ext2fs_blocks_count_set(super, ext2fs_blocks_count(param));
ext2fs_r_blocks_count_set(super, ext2fs_r_blocks_count(param));
@ -253,8 +251,7 @@ retry:
super->s_blocks_per_group -= 8;
ext2fs_blocks_count_set(super,
ext2fs_blocks_count(param));
super->s_frags_per_group = super->s_blocks_per_group *
frags_per_block;
super->s_clusters_per_group = super->s_blocks_per_group;
goto retry;
} else {
retval = EXT2_ET_TOO_MANY_INODES;

View File

@ -250,7 +250,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
retval = EXT2_ET_CORRUPT_SUPERBLOCK;
goto cleanup;
}
fs->fragsize = EXT2_FRAG_SIZE(fs->super);
fs->clustersize = EXT2_CLUSTER_SIZE(fs->super);
fs->inode_blocks_per_group = ((EXT2_INODES_PER_GROUP(fs->super) *
EXT2_INODE_SIZE(fs->super) +
EXT2_BLOCK_SIZE(fs->super) - 1) /

View File

@ -31,9 +31,9 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
sb->s_free_inodes_count = ext2fs_swab32(sb->s_free_inodes_count);
sb->s_first_data_block = ext2fs_swab32(sb->s_first_data_block);
sb->s_log_block_size = ext2fs_swab32(sb->s_log_block_size);
sb->s_log_frag_size = ext2fs_swab32(sb->s_log_frag_size);
sb->s_log_cluster_size = ext2fs_swab32(sb->s_log_cluster_size);
sb->s_blocks_per_group = ext2fs_swab32(sb->s_blocks_per_group);
sb->s_frags_per_group = ext2fs_swab32(sb->s_frags_per_group);
sb->s_clusters_per_group = ext2fs_swab32(sb->s_clusters_per_group);
sb->s_inodes_per_group = ext2fs_swab32(sb->s_inodes_per_group);
sb->s_mtime = ext2fs_swab32(sb->s_mtime);
sb->s_wtime = ext2fs_swab32(sb->s_wtime);
@ -76,6 +76,8 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
sb->s_snapshot_r_blocks_count =
ext2fs_swab64(sb->s_snapshot_r_blocks_count);
sb->s_snapshot_list = ext2fs_swab32(sb->s_snapshot_list);
sb->s_usr_quota_inum = ext2fs_swab32(sb->s_usr_quota_inum);
sb->s_grp_quota_inum = ext2fs_swab32(sb->s_grp_quota_inum);
for (i=0; i < 4; i++)
sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);

View File

@ -50,9 +50,9 @@ void check_superblock_fields()
check_field(s_free_inodes_count);
check_field(s_first_data_block);
check_field(s_log_block_size);
check_field(s_log_frag_size);
check_field(s_log_cluster_size);
check_field(s_blocks_per_group);
check_field(s_frags_per_group);
check_field(s_clusters_per_group);
check_field(s_inodes_per_group);
check_field(s_mtime);
check_field(s_wtime);
@ -123,6 +123,8 @@ void check_superblock_fields()
check_field(s_last_error_block);
check_field(s_last_error_func);
check_field(s_mount_opts);
check_field(s_usr_quota_inum);
check_field(s_grp_quota_inum);
check_field(s_reserved);
printf("Ending offset is %d\n\n", cur_offset);
#endif

View File

@ -560,8 +560,13 @@ static void show_stats(ext2_filsys fs)
free(os);
printf(_("Block size=%u (log=%u)\n"), fs->blocksize,
s->s_log_block_size);
printf(_("Fragment size=%u (log=%u)\n"), fs->fragsize,
s->s_log_frag_size);
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_BIGALLOC))
printf(_("Cluster size=%u (log=%u)\n"),
fs->clustersize, s->s_log_cluster_size);
else
printf(_("Fragment size=%u (log=%u)\n"), fs->clustersize,
s->s_log_cluster_size);
printf(_("Stride=%u blocks, Stripe width=%u blocks\n"),
s->s_raid_stride, s->s_raid_stripe_width);
printf(_("%u inodes, %llu blocks\n"), s->s_inodes_count,
@ -578,8 +583,13 @@ static void show_stats(ext2_filsys fs)
printf(_("%u block groups\n"), fs->group_desc_count);
else
printf(_("%u block group\n"), fs->group_desc_count);
printf(_("%u blocks per group, %u fragments per group\n"),
s->s_blocks_per_group, s->s_frags_per_group);
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_BIGALLOC))
printf(_("%u blocks per group, %u clusters per group\n"),
s->s_blocks_per_group, s->s_clusters_per_group);
else
printf(_("%u blocks per group, %u fragments per group\n"),
s->s_blocks_per_group, s->s_clusters_per_group);
printf(_("%u inodes per group\n"), s->s_inodes_per_group);
if (fs->group_desc_count == 1) {
@ -1274,8 +1284,6 @@ profile_error:
optarg);
exit(1);
}
fs_param.s_log_frag_size =
int_log2(size >> EXT2_MIN_BLOCK_LOG_SIZE);
fprintf(stderr, _("Warning: fragments not supported. "
"Ignoring -f option\n"));
break;
@ -1507,7 +1515,7 @@ profile_error:
check_plausibility(device_name);
check_mount(device_name, force, _("filesystem"));
fs_param.s_log_frag_size = fs_param.s_log_block_size;
fs_param.s_log_cluster_size = fs_param.s_log_block_size;
/* Determine the size of the device (if possible) */
if (noaction && fs_blocks_count) {
@ -1751,7 +1759,7 @@ profile_error:
inode_ratio = blocksize;
}
fs_param.s_log_frag_size = fs_param.s_log_block_size =
fs_param.s_log_cluster_size = fs_param.s_log_block_size =
int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE);
#ifdef HAVE_BLKID_PROBE_GET_TOPOLOGY