Index: fs/ext2fs/ext2_extern.h =================================================================== --- fs/ext2fs/ext2_extern.h (revision 262723) +++ fs/ext2fs/ext2_extern.h (working copy) @@ -89,8 +89,7 @@ int ext2_htree_create_index(struct vnode *, struct componentname *, struct ext2fs_direct_2 *); int ext2_htree_has_idx(struct inode *); -int ext2_htree_hash(const char *, int, uint32_t *, int, uint32_t *, - uint32_t *); +int ext2_htree_hash(const char *, int, uint32_t *, int, uint64_t *); int ext2_htree_lookup(struct inode *, const char *, int, struct buf **, int *, doff_t *, doff_t *, doff_t *, struct ext2fs_searchslot *); int ext2_search_dirblock(struct inode *, void *, int *, const char *, int, Index: fs/ext2fs/ext2_hash.c =================================================================== --- fs/ext2fs/ext2_hash.c (revision 262722) +++ fs/ext2fs/ext2_hash.c (working copy) @@ -241,7 +241,7 @@ int ext2_htree_hash(const char *name, int len, uint32_t *hash_seed, int hash_version, - uint32_t *hash_major, uint32_t *hash_minor) + uint64_t *hash64) { uint32_t hash[4]; uint32_t data[8]; @@ -248,7 +248,7 @@ uint32_t major = 0, minor = 0; int unsigned_char = 0; - if (!name || !hash_major) + if (!name || !hash64) return (-1); if (len < 1 || len > 255) @@ -299,15 +299,11 @@ major &= ~1; if (major == (EXT2_HTREE_EOF << 1)) major = (EXT2_HTREE_EOF - 1) << 1; - *hash_major = major; - if (hash_minor) - *hash_minor = minor; + *hash64 = (uint64_t)major << 32 | minor; return (0); error: - *hash_major = 0; - if (hash_minor) - *hash_minor = 0; + *hash64 = 0; return (-1); } Index: fs/ext2fs/ext2_htree.c =================================================================== --- fs/ext2fs/ext2_htree.c (revision 262723) +++ fs/ext2fs/ext2_htree.c (working copy) @@ -56,20 +56,20 @@ struct ext2fs_direct_2 *new_entry); static int ext2_htree_append_block(struct vnode *vp, char *data, struct componentname *cnp, uint32_t blksize); -static int ext2_htree_check_next(struct inode *ip, uint32_t hash, +static int ext2_htree_check_next(struct inode *ip, uint64_t hash64, const char *name, struct ext2fs_htree_lookup_info *info); static int ext2_htree_cmp_sort_entry(const void *e1, const void *e2); static int ext2_htree_find_leaf(struct inode *ip, const char *name, - int namelen, uint32_t *hash, uint8_t *hash_version, + int namelen, uint64_t *hash64, uint8_t *hash_version, struct ext2fs_htree_lookup_info *info); static uint32_t ext2_htree_get_block(struct ext2fs_htree_entry *ep); static uint16_t ext2_htree_get_count(struct ext2fs_htree_entry *ep); -static uint32_t ext2_htree_get_hash(struct ext2fs_htree_entry *ep); +static uint64_t ext2_htree_get_hash(struct ext2fs_htree_entry *ep); static uint16_t ext2_htree_get_limit(struct ext2fs_htree_entry *ep); static void ext2_htree_insert_entry_to_level(struct ext2fs_htree_lookup_level *level, - uint32_t hash, uint32_t blk); + uint64_t hash64, uint32_t blk); static void ext2_htree_insert_entry(struct ext2fs_htree_lookup_info *info, - uint32_t hash, uint32_t blk); + uint64_t hash64, uint32_t blk); static uint32_t ext2_htree_node_limit(struct inode *ip); static void ext2_htree_set_block(struct ext2fs_htree_entry *ep, uint32_t blk); @@ -76,12 +76,12 @@ static void ext2_htree_set_count(struct ext2fs_htree_entry *ep, uint16_t cnt); static void ext2_htree_set_hash(struct ext2fs_htree_entry *ep, - uint32_t hash); + uint64_t hash64); static void ext2_htree_set_limit(struct ext2fs_htree_entry *ep, uint16_t limit); static int ext2_htree_split_dirblock(char *block1, char *block2, uint32_t blksize, uint32_t *hash_seed, uint8_t hash_version, - uint32_t *split_hash, struct ext2fs_direct_2 *entry); + uint64_t *split_hash, struct ext2fs_direct_2 *entry); static void ext2_htree_release(struct ext2fs_htree_lookup_info *info); static uint32_t ext2_htree_root_limit(struct inode *ip, int len); static int ext2_htree_writebuf(struct ext2fs_htree_lookup_info *info); @@ -97,13 +97,13 @@ } static int -ext2_htree_check_next(struct inode *ip, uint32_t hash, const char *name, +ext2_htree_check_next(struct inode *ip, uint64_t hash64, const char *name, struct ext2fs_htree_lookup_info *info) { struct vnode *vp = ITOV(ip); struct ext2fs_htree_lookup_level *level; struct buf *bp; - uint32_t next_hash; + uint64_t next_hash; int idx = info->h_levels_num - 1; int levels = 0; @@ -120,8 +120,8 @@ } while (1); next_hash = ext2_htree_get_hash(level->h_entry); - if ((hash & 1) == 0) { - if (hash != (next_hash & ~1)) + if ((hash64 & 1) == 0) { + if (hash64 != (next_hash & ~1)) return (0); } @@ -164,10 +164,10 @@ ((struct ext2fs_htree_count *)(ep))->h_entries_num = cnt; } -static uint32_t +static uint64_t ext2_htree_get_hash(struct ext2fs_htree_entry *ep) { - return (ep->h_hash); + return ((uint64_t)ep->h_hash32 << 32); } static uint16_t @@ -177,9 +177,9 @@ } static void -ext2_htree_set_hash(struct ext2fs_htree_entry *ep, uint32_t hash) +ext2_htree_set_hash(struct ext2fs_htree_entry *ep, uint64_t hash64) { - ep->h_hash = hash; + ep->h_hash32 = (uint32_t)((hash64 & 0xFFFFFFFF00000000) >> 32); } static void @@ -224,7 +224,7 @@ static int ext2_htree_find_leaf(struct inode *ip, const char *name, int namelen, - uint32_t *hash, uint8_t *hash_ver, + uint64_t *hash64, uint8_t *hash_ver, struct ext2fs_htree_lookup_info *info) { struct vnode *vp; @@ -234,7 +234,7 @@ struct ext2fs_htree_root *rootp; struct ext2fs_htree_entry *entp, *start, *end, *middle, *found; struct ext2fs_htree_lookup_level *level_info; - uint32_t hash_major = 0, hash_minor = 0; + uint64_t hash = 0; uint32_t levels, cnt; uint8_t hash_version; @@ -262,8 +262,7 @@ *hash_ver = hash_version; ext2_htree_hash(name, namelen, fs->e3fs_hash_seed, - hash_version, &hash_major, &hash_minor); - *hash = hash_major; + hash_version, &hash); if ((levels = rootp->h_info.h_ind_levels) > 1) goto error; @@ -284,7 +283,7 @@ end = entp + cnt - 1; while (start <= end) { middle = start + (end - start) / 2; - if (ext2_htree_get_hash(middle) > hash_major) + if (ext2_htree_get_hash(middle) > hash) end = middle - 1; else start = middle + 1; @@ -327,7 +326,7 @@ struct m_ext2fs *m_fs; struct buf *bp; uint32_t blk; - uint32_t dirhash; + uint64_t dirhash; uint32_t bsize; uint8_t hash_version; int search_next; @@ -429,7 +428,7 @@ static void ext2_htree_insert_entry_to_level(struct ext2fs_htree_lookup_level *level, - uint32_t hash, uint32_t blk) + uint64_t hash64, uint32_t blk) { struct ext2fs_htree_entry *target; int entries_num; @@ -440,7 +439,7 @@ memmove(target + 1, target, (char *)(level->h_entries + entries_num) - (char *)target); ext2_htree_set_block(target, blk); - ext2_htree_set_hash(target, hash); + ext2_htree_set_hash(target, hash64); ext2_htree_set_count(level->h_entries, entries_num + 1); } @@ -449,12 +448,12 @@ */ static void ext2_htree_insert_entry(struct ext2fs_htree_lookup_info *info, - uint32_t hash, uint32_t blk) + uint64_t hash64, uint32_t blk) { struct ext2fs_htree_lookup_level *level; level = &info->h_levels[info->h_levels_num - 1]; - ext2_htree_insert_entry_to_level(level, hash, blk); + ext2_htree_insert_entry_to_level(level, hash64, blk); } /* @@ -469,9 +468,9 @@ entry1 = (const struct ext2fs_htree_sort_entry *)e1; entry2 = (const struct ext2fs_htree_sort_entry *)e2; - if (entry1->h_hash < entry2->h_hash) + if (entry1->h_hash64 < entry2->h_hash64) return (-1); - if (entry2->h_hash > entry2->h_hash) + if (entry2->h_hash64 > entry2->h_hash64) return (1); return (0); } @@ -499,7 +498,7 @@ static int ext2_htree_split_dirblock(char *block1, char *block2, uint32_t blksize, uint32_t *hash_seed, uint8_t hash_version, - uint32_t *split_hash, struct ext2fs_direct_2 *entry) + uint64_t *split_hash, struct ext2fs_direct_2 *entry) { int entry_cnt = 0; int size = 0; @@ -506,7 +505,7 @@ int i, k; uint32_t offset; uint16_t entry_len = 0; - uint32_t entry_hash; + uint64_t entry_hash; struct ext2fs_direct_2 *ep, *last; char *dest; struct ext2fs_htree_sort_entry *sort_info; @@ -520,7 +519,7 @@ * Calculate name hash value for the entry which is to be added. */ ext2_htree_hash(entry->e2d_name, entry->e2d_namlen, hash_seed, - hash_version, &entry_hash, NULL); + hash_version, &entry_hash); /* * Fill in directory entry sort descriptors. @@ -533,7 +532,7 @@ sort_info->h_offset = (char *)ep - block1; ext2_htree_hash(ep->e2d_name, ep->e2d_namlen, hash_seed, hash_version, - &sort_info->h_hash, NULL); + &sort_info->h_hash64); } ep = (struct ext2fs_direct_2 *) ((char *)ep + ep->e2d_reclen); @@ -554,12 +553,12 @@ size += sort_info[i].h_size; } - *split_hash = sort_info[i + 1].h_hash; + *split_hash = sort_info[i + 1].h_hash64; /* * Set collision bit. */ - if (*split_hash == sort_info[i].h_hash) + if (*split_hash == sort_info[i].h_hash64) *split_hash += 1; /* @@ -626,7 +625,8 @@ struct ext2fs_direct_2 *ep, *dotdot; struct ext2fs_htree_root *root; struct ext2fs_htree_lookup_info info; - uint32_t blksize, dirlen, split_hash; + uint32_t blksize, dirlen; + uint64_t split_hash; uint8_t hash_version; char *buf1 = NULL; char *buf2 = NULL; @@ -731,7 +731,7 @@ struct m_ext2fs *m_fs; struct inode *ip; uint16_t ent_num; - uint32_t dirhash, split_hash; + uint64_t dirhash, split_hash; uint32_t blksize, blknum; uint64_t cursize, dirsize; uint8_t hash_version; Index: fs/ext2fs/htree.h =================================================================== --- fs/ext2fs/htree.h (revision 262723) +++ fs/ext2fs/htree.h (working copy) @@ -54,7 +54,7 @@ }; struct ext2fs_htree_entry { - uint32_t h_hash; + uint32_t h_hash32; uint32_t h_blk; }; @@ -94,7 +94,7 @@ struct ext2fs_htree_sort_entry { uint16_t h_offset; uint16_t h_size; - uint32_t h_hash; + uint64_t h_hash64; }; #endif /* !_FS_EXT2FS_HTREE_H_ */