diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-04-23 01:30:42 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-04-23 01:30:42 -0400 |
commit | 8203fe506a06524587c18940b6cd19a0592a4bd2 (patch) | |
tree | 03fbbea949cb0d7deab52c2fc3a83ddf0713907e /lib | |
parent | 982dd30ce87d5fdfb9a6de5732633f31b3840090 (diff) | |
download | e2fsprogs-8203fe506a06524587c18940b6cd19a0592a4bd2.tar.gz |
libext2fs: read the block group descriptors more efficiently
When opening a filesystem, make ext2fs_open2() much more efficient by
reading the normal block group descriptors all at once, instead of one
block at a time.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ext2fs/openfs.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index f6fe3f08..1ca63dba 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -84,7 +84,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, { ext2_filsys fs; errcode_t retval; - unsigned long i; + unsigned long i, first_meta_bg; __u32 features; int groups_per_block, blocks_per_group, io_flags; blk_t group_block, blk; @@ -304,7 +304,23 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, group_block = fs->super->s_first_data_block; dest = (char *) fs->group_desc; groups_per_block = EXT2_DESC_PER_BLOCK(fs->super); - for (i=0 ; i < fs->desc_blocks; i++) { + if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) + first_meta_bg = fs->super->s_first_meta_bg; + else + first_meta_bg = fs->desc_blocks; + if (first_meta_bg) { + retval = io_channel_read_blk(fs->io, group_block+1, + first_meta_bg, dest); + if (retval) + goto cleanup; +#ifdef WORDS_BIGENDIAN + gdp = (struct ext2_group_desc *) dest; + for (j=0; j < groups_per_block*first_meta_bg; j++) + ext2fs_swap_group_desc(gdp++); +#endif + dest += fs->blocksize*first_meta_bg; + } + for (i=first_meta_bg ; i < fs->desc_blocks; i++) { blk = ext2fs_descriptor_block_loc(fs, group_block, i); retval = io_channel_read_blk(fs->io, blk, 1, dest); if (retval) |