mirror of https://github.com/vitalif/e2fsprogs
libext2fs: optimize ext2fs_bg_has_super()
Reduce the CPU time needed when checking whether a block group has a sparse superblock. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>debian-1.42.9
parent
3ac420165c
commit
4718395120
|
@ -20,12 +20,12 @@
|
||||||
#include "ext2_fs.h"
|
#include "ext2_fs.h"
|
||||||
#include "ext2fsP.h"
|
#include "ext2fsP.h"
|
||||||
|
|
||||||
static int test_root(int a, int b)
|
static int test_root(unsigned int a, unsigned int b)
|
||||||
{
|
{
|
||||||
if (a == 0)
|
|
||||||
return 1;
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (a == 1)
|
if (a < b)
|
||||||
|
return 0;
|
||||||
|
if (a == b)
|
||||||
return 1;
|
return 1;
|
||||||
if (a % b)
|
if (a % b)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -33,14 +33,15 @@ static int test_root(int a, int b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ext2fs_bg_has_super(ext2_filsys fs, int group_block)
|
int ext2fs_bg_has_super(ext2_filsys fs, dgrp_t group)
|
||||||
{
|
{
|
||||||
if (!(fs->super->s_feature_ro_compat &
|
if (!(fs->super->s_feature_ro_compat &
|
||||||
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
|
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) || group <= 1)
|
||||||
return 1;
|
return 1;
|
||||||
|
if (!(group & 1))
|
||||||
if (test_root(group_block, 3) || (test_root(group_block, 5)) ||
|
return 0;
|
||||||
test_root(group_block, 7))
|
if (test_root(group, 3) || (test_root(group, 5)) ||
|
||||||
|
test_root(group, 7))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -911,7 +911,7 @@ extern errcode_t ext2fs_close(ext2_filsys fs);
|
||||||
extern errcode_t ext2fs_close2(ext2_filsys fs, int flags);
|
extern errcode_t ext2fs_close2(ext2_filsys fs, int flags);
|
||||||
extern errcode_t ext2fs_flush(ext2_filsys fs);
|
extern errcode_t ext2fs_flush(ext2_filsys fs);
|
||||||
extern errcode_t ext2fs_flush2(ext2_filsys fs, int flags);
|
extern errcode_t ext2fs_flush2(ext2_filsys fs, int flags);
|
||||||
extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block);
|
extern int ext2fs_bg_has_super(ext2_filsys fs, dgrp_t group_block);
|
||||||
extern errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
|
extern errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
|
||||||
dgrp_t group,
|
dgrp_t group,
|
||||||
blk64_t *ret_super_blk,
|
blk64_t *ret_super_blk,
|
||||||
|
|
Loading…
Reference in New Issue