Loading include/global/random_slicing/DistRandSlice.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ public: /** * @see Distributor::placeExtent */ virtual std::list<Disk*>* uint64_t placeExtent(int64_t position); /** Loading src/global/random_slicing/DistRandSlice.cpp +7 −58 Original line number Diff line number Diff line Loading @@ -281,65 +281,14 @@ my_hash(int64_t i) { return i; } std::list<Disk*>* uint64_t DistRandSlice::placeExtent(int64_t position) { // XXX: for tests we want to avoid id clashing with copies so // int64_t offset = 200; // if(position > INT64_MAX / offset - 1) // abort(); // position *= offset; std::list<Disk*>* result = new std::list<Disk*>(); std::vector<uint64_t> selected_partitions; uint64_t idx = 0; #if defined DEBUG && defined DUMP_COPIES uint64_t retries = 0; #endif while(result->size() < (uint32_t) m_copies) { // XXX: at the moment, we ignore the virtualVolumeId uint64_t key = my_hash(position + idx); // lookup interval containing the key and retrieve the partition ID // function heavily modified for GekkoFS assert(m_copies == 1); uint64_t key = my_hash(position); uint64_t partition_id = 0; m_interval_tree->search_tree(key, partition_id); // check if this partition has already been selected bool found = false; for(uint i = 0; i < selected_partitions.size() && !found; ++i) { if(partition_id == selected_partitions[i]) found = true; } if(found) { #if defined DEBUG && defined DUMP_COPIES ++retries; #endif ++idx; // assert(idx <= (uint64_t) offset); // XXX continue; } // Find the corresponding disk and return it // XXX: ATM, partition_id == disk_id uint64_t disk_id = partition_id; assert(m_disks->count(disk_id) != 0); Disk* d = (*m_disks)[disk_id]; result->push_back(new Disk(*d)); selected_partitions.push_back(partition_id); ++idx; } #if defined DEBUG && defined DUMP_COPIES // std::cout << " DEBUG: Extent placed with " << retries << " retries " << // std::endl; #endif return result; return partition_id; } std::list<Disk*>* Loading src/global/rpc/distributor.cpp +1 −8 Original line number Diff line number Diff line Loading @@ -152,14 +152,7 @@ RandomSlicingDistributor::locate_file_metadata(const std::string& path) 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) auto disklist = dist_impl_->placeExtent(myhash); assert(disklist->size() == 1); auto disk = disklist->front(); auto id = disk->getId(); delete disk; delete disklist; // TODO Avoid memory allocation for this task and make this much simpler return id; return dist_impl_->placeExtent(myhash); } std::vector<host_t> Loading Loading
include/global/random_slicing/DistRandSlice.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ public: /** * @see Distributor::placeExtent */ virtual std::list<Disk*>* uint64_t placeExtent(int64_t position); /** Loading
src/global/random_slicing/DistRandSlice.cpp +7 −58 Original line number Diff line number Diff line Loading @@ -281,65 +281,14 @@ my_hash(int64_t i) { return i; } std::list<Disk*>* uint64_t DistRandSlice::placeExtent(int64_t position) { // XXX: for tests we want to avoid id clashing with copies so // int64_t offset = 200; // if(position > INT64_MAX / offset - 1) // abort(); // position *= offset; std::list<Disk*>* result = new std::list<Disk*>(); std::vector<uint64_t> selected_partitions; uint64_t idx = 0; #if defined DEBUG && defined DUMP_COPIES uint64_t retries = 0; #endif while(result->size() < (uint32_t) m_copies) { // XXX: at the moment, we ignore the virtualVolumeId uint64_t key = my_hash(position + idx); // lookup interval containing the key and retrieve the partition ID // function heavily modified for GekkoFS assert(m_copies == 1); uint64_t key = my_hash(position); uint64_t partition_id = 0; m_interval_tree->search_tree(key, partition_id); // check if this partition has already been selected bool found = false; for(uint i = 0; i < selected_partitions.size() && !found; ++i) { if(partition_id == selected_partitions[i]) found = true; } if(found) { #if defined DEBUG && defined DUMP_COPIES ++retries; #endif ++idx; // assert(idx <= (uint64_t) offset); // XXX continue; } // Find the corresponding disk and return it // XXX: ATM, partition_id == disk_id uint64_t disk_id = partition_id; assert(m_disks->count(disk_id) != 0); Disk* d = (*m_disks)[disk_id]; result->push_back(new Disk(*d)); selected_partitions.push_back(partition_id); ++idx; } #if defined DEBUG && defined DUMP_COPIES // std::cout << " DEBUG: Extent placed with " << retries << " retries " << // std::endl; #endif return result; return partition_id; } std::list<Disk*>* Loading
src/global/rpc/distributor.cpp +1 −8 Original line number Diff line number Diff line Loading @@ -152,14 +152,7 @@ RandomSlicingDistributor::locate_file_metadata(const std::string& path) 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) auto disklist = dist_impl_->placeExtent(myhash); assert(disklist->size() == 1); auto disk = disklist->front(); auto id = disk->getId(); delete disk; delete disklist; // TODO Avoid memory allocation for this task and make this much simpler return id; return dist_impl_->placeExtent(myhash); } std::vector<host_t> Loading