Verified Commit 330eb623 authored by Marc Vef's avatar Marc Vef
Browse files

Remove double hash from random slicing

parent 52a03054
Loading
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -322,8 +322,6 @@ host_t
RandomSlicingDistributor::locate_file_metadata(const std::string& path,
                                               const int num_copy) const {
    auto myhash = str_hash(path);
    // TODO placeExtent hashes the hash with it's own hash, is this a problem?
    // (migh be unavoidable if multiple copies should be stored sometime)
    return dist_impl_->placeExtent(myhash);
}

+11 −3
Original line number Diff line number Diff line
@@ -262,6 +262,7 @@ DistRandSlice::partition_capacity(Disk* disk, uint64_t new_total_capacity) {
/**
 * 64 bit Integer Hash Function
 * found at http://www.concentric.net/~Ttwang/tech/inthash.htm by Thomas Wang
 * currently unused
 */
static inline uint64_t
my_hash(int64_t i) {
@@ -287,11 +288,18 @@ my_hash(int64_t i) {

uint64_t
DistRandSlice::placeExtent(int64_t position) {
    // function heavily modified for GekkoFS
    assert(m_copies == 1);
    uint64_t key = my_hash(position);
    // original uses my_hash function.
    //    uint64_t key = my_hash(position);
    // For debugging with smaller VSPACE_MAX.
    if(DistRandSlice::VSPACE_MAX != UINT64_MAX) {
#ifndef DEBUG
        assert(!"Running with VSPACE_MAX != UINT64_MAX but no DEBUG");
#endif
        position = position % DistRandSlice::VSPACE_MAX;
    }
    uint64_t partition_id = 0;
    m_interval_tree->search_tree(key, partition_id);
    m_interval_tree->search_tree(position, partition_id);
    return partition_id;
}