diff options
-rw-r--r-- | fs/reiserfs/super.c | 105 |
1 files changed, 47 insertions, 58 deletions
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index e26ec564758f..a392cef6acc6 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -1668,71 +1668,60 @@ static __u32 find_hash_out(struct super_block *s) | |||
1668 | struct cpu_key key; | 1668 | struct cpu_key key; |
1669 | INITIALIZE_PATH(path); | 1669 | INITIALIZE_PATH(path); |
1670 | struct reiserfs_dir_entry de; | 1670 | struct reiserfs_dir_entry de; |
1671 | struct reiserfs_de_head *deh; | ||
1671 | __u32 hash = DEFAULT_HASH; | 1672 | __u32 hash = DEFAULT_HASH; |
1673 | __u32 deh_hashval, teahash, r5hash, yurahash; | ||
1672 | 1674 | ||
1673 | inode = s->s_root->d_inode; | 1675 | inode = s->s_root->d_inode; |
1674 | 1676 | ||
1675 | do { /* Some serious "goto"-hater was there ;) */ | 1677 | make_cpu_key(&key, inode, ~0, TYPE_DIRENTRY, 3); |
1676 | u32 teahash, r5hash, yurahash; | 1678 | retval = search_by_entry_key(s, &key, &path, &de); |
1679 | if (retval == IO_ERROR) { | ||
1680 | pathrelse(&path); | ||
1681 | return UNSET_HASH; | ||
1682 | } | ||
1683 | if (retval == NAME_NOT_FOUND) | ||
1684 | de.de_entry_num--; | ||
1677 | 1685 | ||
1678 | make_cpu_key(&key, inode, ~0, TYPE_DIRENTRY, 3); | 1686 | set_de_name_and_namelen(&de); |
1679 | retval = search_by_entry_key(s, &key, &path, &de); | 1687 | deh = de.de_deh + de.de_entry_num; |
1680 | if (retval == IO_ERROR) { | 1688 | |
1681 | pathrelse(&path); | 1689 | if (deh_offset(deh) == DOT_DOT_OFFSET) { |
1682 | return UNSET_HASH; | 1690 | /* allow override in this case */ |
1683 | } | 1691 | if (reiserfs_rupasov_hash(s)) |
1684 | if (retval == NAME_NOT_FOUND) | ||
1685 | de.de_entry_num--; | ||
1686 | set_de_name_and_namelen(&de); | ||
1687 | if (deh_offset(&(de.de_deh[de.de_entry_num])) == DOT_DOT_OFFSET) { | ||
1688 | /* allow override in this case */ | ||
1689 | if (reiserfs_rupasov_hash(s)) { | ||
1690 | hash = YURA_HASH; | ||
1691 | } | ||
1692 | reiserfs_info(s, "FS seems to be empty, autodetect " | ||
1693 | "is using the default hash\n"); | ||
1694 | break; | ||
1695 | } | ||
1696 | r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen)); | ||
1697 | teahash = GET_HASH_VALUE(keyed_hash(de.de_name, de.de_namelen)); | ||
1698 | yurahash = GET_HASH_VALUE(yura_hash(de.de_name, de.de_namelen)); | ||
1699 | if (((teahash == r5hash) | ||
1700 | && | ||
1701 | (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num]))) | ||
1702 | == r5hash)) || ((teahash == yurahash) | ||
1703 | && (yurahash == | ||
1704 | GET_HASH_VALUE(deh_offset | ||
1705 | (& | ||
1706 | (de. | ||
1707 | de_deh[de. | ||
1708 | de_entry_num]))))) | ||
1709 | || ((r5hash == yurahash) | ||
1710 | && (yurahash == | ||
1711 | GET_HASH_VALUE(deh_offset | ||
1712 | (&(de.de_deh[de.de_entry_num])))))) { | ||
1713 | reiserfs_warning(s, "reiserfs-2506", "Unable to " | ||
1714 | "automatically detect hash function. " | ||
1715 | "Please mount with -o " | ||
1716 | "hash={tea,rupasov,r5}"); | ||
1717 | hash = UNSET_HASH; | ||
1718 | break; | ||
1719 | } | ||
1720 | if (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num]))) == | ||
1721 | yurahash) | ||
1722 | hash = YURA_HASH; | 1692 | hash = YURA_HASH; |
1723 | else if (GET_HASH_VALUE | 1693 | reiserfs_info(s, "FS seems to be empty, autodetect is using the default hash\n"); |
1724 | (deh_offset(&(de.de_deh[de.de_entry_num]))) == teahash) | 1694 | goto out; |
1725 | hash = TEA_HASH; | 1695 | } |
1726 | else if (GET_HASH_VALUE | ||
1727 | (deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash) | ||
1728 | hash = R5_HASH; | ||
1729 | else { | ||
1730 | reiserfs_warning(s, "reiserfs-2506", | ||
1731 | "Unrecognised hash function"); | ||
1732 | hash = UNSET_HASH; | ||
1733 | } | ||
1734 | } while (0); | ||
1735 | 1696 | ||
1697 | deh_hashval = GET_HASH_VALUE(deh_offset(deh)); | ||
1698 | r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen)); | ||
1699 | teahash = GET_HASH_VALUE(keyed_hash(de.de_name, de.de_namelen)); | ||
1700 | yurahash = GET_HASH_VALUE(yura_hash(de.de_name, de.de_namelen)); | ||
1701 | |||
1702 | if ((teahash == r5hash && deh_hashval == r5hash) || | ||
1703 | (teahash == yurahash && deh_hashval == yurahash) || | ||
1704 | (r5hash == yurahash && deh_hashval == yurahash)) { | ||
1705 | reiserfs_warning(s, "reiserfs-2506", | ||
1706 | "Unable to automatically detect hash " | ||
1707 | "function. Please mount with -o " | ||
1708 | "hash={tea,rupasov,r5}"); | ||
1709 | hash = UNSET_HASH; | ||
1710 | goto out; | ||
1711 | } | ||
1712 | |||
1713 | if (deh_hashval == yurahash) | ||
1714 | hash = YURA_HASH; | ||
1715 | else if (deh_hashval == teahash) | ||
1716 | hash = TEA_HASH; | ||
1717 | else if (deh_hashval == r5hash) | ||
1718 | hash = R5_HASH; | ||
1719 | else { | ||
1720 | reiserfs_warning(s, "reiserfs-2506", | ||
1721 | "Unrecognised hash function"); | ||
1722 | hash = UNSET_HASH; | ||
1723 | } | ||
1724 | out: | ||
1736 | pathrelse(&path); | 1725 | pathrelse(&path); |
1737 | return hash; | 1726 | return hash; |
1738 | } | 1727 | } |