Commit 157ff882 authored by Hans Reiser's avatar Hans Reiser Committed by Linus Torvalds

[PATCH] 04-hash_autodetect_fix.diff

   Correctly detect and print hash values, when manual hash detection is used.
parent fe60646e
...@@ -477,6 +477,17 @@ static int print_leaf (struct buffer_head * bh, int print_mode, int first, int l ...@@ -477,6 +477,17 @@ static int print_leaf (struct buffer_head * bh, int print_mode, int first, int l
return 0; return 0;
} }
char * reiserfs_hashname(int code)
{
if ( code == YURA_HASH)
return "rupasov";
if ( code == TEA_HASH)
return "tea";
if ( code == R5_HASH)
return "r5";
return "unknown";
}
/* return 1 if this is not super block */ /* return 1 if this is not super block */
static int print_super_block (struct buffer_head * bh) static int print_super_block (struct buffer_head * bh)
{ {
...@@ -519,8 +530,7 @@ static int print_super_block (struct buffer_head * bh) ...@@ -519,8 +530,7 @@ static int print_super_block (struct buffer_head * bh)
printk ("Journal orig size %d\n", sb_jp_journal_size(rs)); printk ("Journal orig size %d\n", sb_jp_journal_size(rs));
printk ("FS state %d\n", sb_fs_state(rs)); printk ("FS state %d\n", sb_fs_state(rs));
printk ("Hash function \"%s\"\n", printk ("Hash function \"%s\"\n",
sb_hash_function_code(rs) == TEA_HASH ? "tea" : reiserfs_hashname(sb_hash_function_code(rs)));
( sb_hash_function_code(rs) == YURA_HASH ? "rupasov" : (sb_hash_function_code(rs) == R5_HASH ? "r5" : "unknown")));
printk ("Tree height %d\n", sb_tree_height(rs)); printk ("Tree height %d\n", sb_tree_height(rs));
return 0; return 0;
......
...@@ -850,7 +850,9 @@ __u32 find_hash_out (struct super_block * s) ...@@ -850,7 +850,9 @@ __u32 find_hash_out (struct super_block * s)
inode = s->s_root->d_inode; inode = s->s_root->d_inode;
while (1) { do { // Some serious "goto"-hater was there ;)
u32 teahash, r5hash, yurahash;
make_cpu_key (&key, inode, ~0, TYPE_DIRENTRY, 3); make_cpu_key (&key, inode, ~0, TYPE_DIRENTRY, 3);
retval = search_by_entry_key (s, &key, &path, &de); retval = search_by_entry_key (s, &key, &path, &de);
if (retval == IO_ERROR) { if (retval == IO_ERROR) {
...@@ -869,20 +871,30 @@ __u32 find_hash_out (struct super_block * s) ...@@ -869,20 +871,30 @@ __u32 find_hash_out (struct super_block * s)
"is using the default hash\n"); "is using the default hash\n");
break; break;
} }
if (GET_HASH_VALUE(yura_hash (de.de_name, de.de_namelen)) == r5hash=GET_HASH_VALUE (r5_hash (de.de_name, de.de_namelen));
GET_HASH_VALUE(keyed_hash (de.de_name, de.de_namelen))) { teahash=GET_HASH_VALUE (keyed_hash (de.de_name, de.de_namelen));
reiserfs_warning ("reiserfs: Could not detect hash function " yurahash=GET_HASH_VALUE (yura_hash (de.de_name, de.de_namelen));
"please mount with -o hash={tea,rupasov,r5}\n") ; if ( ( (teahash == r5hash) && (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash) ) ||
hash = UNSET_HASH ; ( (teahash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ||
( (r5hash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ) {
reiserfs_warning("reiserfs: Unable to automatically detect hash"
"function for device %s\n"
"please mount with -o hash={tea,rupasov,r5}\n", kdevname (s->s_dev));
hash = UNSET_HASH;
break; break;
} }
if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == yurahash)
GET_HASH_VALUE (yura_hash (de.de_name, de.de_namelen)))
hash = YURA_HASH; hash = YURA_HASH;
else else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == teahash)
hash = TEA_HASH; hash = TEA_HASH;
break; else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == r5hash)
} hash = R5_HASH;
else {
reiserfs_warning("reiserfs: Unrecognised hash function for "
"device %s\n", kdevname (s->s_dev));
hash = UNSET_HASH;
}
} while (0);
pathrelse (&path); pathrelse (&path);
return hash; return hash;
...@@ -907,16 +919,16 @@ static int what_hash (struct super_block * s) ...@@ -907,16 +919,16 @@ static int what_hash (struct super_block * s)
** mount options ** mount options
*/ */
if (reiserfs_rupasov_hash(s) && code != YURA_HASH) { if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
printk("REISERFS: Error, tea hash detected, " printk("REISERFS: Error, %s hash detected, "
"unable to force rupasov hash\n") ; "unable to force rupasov hash\n", reiserfs_hashname(code)) ;
code = UNSET_HASH ; code = UNSET_HASH ;
} else if (reiserfs_tea_hash(s) && code != TEA_HASH) { } else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
printk("REISERFS: Error, rupasov hash detected, " printk("REISERFS: Error, %s hash detected, "
"unable to force tea hash\n") ; "unable to force tea hash\n", reiserfs_hashname(code)) ;
code = UNSET_HASH ; code = UNSET_HASH ;
} else if (reiserfs_r5_hash(s) && code != R5_HASH) { } else if (reiserfs_r5_hash(s) && code != R5_HASH) {
printk("REISERFS: Error, r5 hash detected, " printk("REISERFS: Error, %s hash detected, "
"unable to force r5 hash\n") ; "unable to force r5 hash\n", reiserfs_hashname(code)) ;
code = UNSET_HASH ; code = UNSET_HASH ;
} }
} else { } else {
......
...@@ -1960,6 +1960,7 @@ void print_block_head (struct buffer_head * bh, char * mes); ...@@ -1960,6 +1960,7 @@ void print_block_head (struct buffer_head * bh, char * mes);
void check_leaf (struct buffer_head * bh); void check_leaf (struct buffer_head * bh);
void check_internal (struct buffer_head * bh); void check_internal (struct buffer_head * bh);
void print_statistics (struct super_block * s); void print_statistics (struct super_block * s);
char * reiserfs_hashname(int code);
/* lbalance.c */ /* lbalance.c */
int leaf_move_items (int shift_mode, struct tree_balance * tb, int mov_num, int mov_bytes, struct buffer_head * Snew); int leaf_move_items (int shift_mode, struct tree_balance * tb, int mov_num, int mov_bytes, struct buffer_head * Snew);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment