diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-01-01 10:59:57 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-01-01 10:59:57 -0500 |
commit | d66c38329e9897563bd29908043e5187f868b46d (patch) | |
tree | 77e0054dd12930e3e498c0e6a6c70d3b39d84ec8 /e2fsck/rehash.c | |
parent | c9eaebf6ff51bbb0a3938b20e01a7b3971ba7207 (diff) | |
download | e2fsprogs-d66c38329e9897563bd29908043e5187f868b46d.tar.gz |
e2fsck: When optimizing non-htree directories, sort by inode number
Previously "e2fsck -fD" on a non-htree directory would sort the
directory alphabetically by name. That's stupid. Better to sort the
directory by inode number, since that will optimize performance much
more significantly than sorting by name!
Addresses-Sourceforge-Feature-Request: #532439
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck/rehash.c')
-rw-r--r-- | e2fsck/rehash.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index 3aa3c06d..8e25f52f 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -66,6 +66,7 @@ struct fill_dir_struct { struct hash_entry { ext2_dirhash_t hash; ext2_dirhash_t minor_hash; + ino_t ino; struct ext2_dir_entry *dir; }; @@ -147,6 +148,7 @@ static int fill_dir_block(ext2_filsys fs, ent = fd->harray + fd->num_array++; ent->dir = dirent; fd->dir_size += EXT2_DIR_REC_LEN(dirent->name_len & 0xFF); + ent->ino = dirent->inode; if (fd->compress) ent->hash = ent->minor_hash = 0; else { @@ -163,6 +165,15 @@ static int fill_dir_block(ext2_filsys fs, } /* Used for sorting the hash entry */ +static EXT2_QSORT_TYPE ino_cmp(const void *a, const void *b) +{ + const struct hash_entry *he_a = (const struct hash_entry *) a; + const struct hash_entry *he_b = (const struct hash_entry *) b; + + return (he_a->ino - he_b->ino); +} + +/* Used for sorting the hash entry */ static EXT2_QSORT_TYPE name_cmp(const void *a, const void *b) { const struct hash_entry *he_a = (const struct hash_entry *) a; @@ -717,7 +728,7 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino) resort: if (fd.compress) qsort(fd.harray+2, fd.num_array-2, - sizeof(struct hash_entry), name_cmp); + sizeof(struct hash_entry), ino_cmp); else qsort(fd.harray, fd.num_array, sizeof(struct hash_entry), hash_cmp); |