Skip to content

Commit

Permalink
do not expose read/write_init() + implem of write on JBOD (deadlock f…
Browse files Browse the repository at this point in the history
…or now)
  • Loading branch information
frs69wq committed May 1, 2024
1 parent ba07a41 commit dbb1dd3
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 30 deletions.
10 changes: 6 additions & 4 deletions include/JBODStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,25 @@ namespace simgrid::module::fs {
void set_raid_level(RAID raid_level) { raid_level_ = raid_level; }
s4u::MessageQueue* mqueue() { return mq_; }

s4u::ActivityPtr read_init(sg_size_t size) override;
s4u::ActivityPtr read_async(sg_size_t size) override;
void read(sg_size_t size) override;
s4u::ActivityPtr write_init(sg_size_t size) override;
s4u::ActivityPtr write_async(sg_size_t size) override;
void write(sg_size_t size) override;

protected:
JBODStorage(const std::string& name, const std::vector<simgrid::s4u::Disk*>& disks);
void update_parity_disk_idx() { parity_disk_idx_ = (parity_disk_idx_- 1) % num_disks_; }

int get_next_read_disk_idx() { return (++read_disk_idx_) % num_disks_; }

s4u::MessageQueue* mq_;

protected:
private:
unsigned int num_disks_;
RAID raid_level_;
unsigned int parity_disk_idx_;
int read_disk_idx_ = -1;
};

}

#endif //FSMOD_JBODSTORAGE_HPP
2 changes: 0 additions & 2 deletions include/OneDiskStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ namespace simgrid::module::fs {
public:
static std::shared_ptr<OneDiskStorage> create(const std::string &name, simgrid::s4u::Disk *disk);

s4u::ActivityPtr read_init(sg_size_t size) override;
s4u::ActivityPtr read_async(sg_size_t size) override;
void read(sg_size_t size) override;
s4u::ActivityPtr write_init(sg_size_t size) override;
s4u::ActivityPtr write_async(sg_size_t size) override;
void write(sg_size_t size) override;

Expand Down
2 changes: 0 additions & 2 deletions include/Storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ namespace simgrid::module::fs {
s4u::ActorPtr get_controller() const { return controller_; }
std::vector<s4u::Disk*> get_disks() const { return disks_; };

virtual s4u::ActivityPtr read_init(sg_size_t size) = 0;
virtual s4u::ActivityPtr read_async(sg_size_t size) = 0;
virtual void read(sg_size_t size) = 0;

virtual s4u::ActivityPtr write_init(sg_size_t size) = 0;
virtual s4u::ActivityPtr write_async(sg_size_t size) = 0;
virtual void write(sg_size_t size) = 0;

Expand Down
90 changes: 76 additions & 14 deletions src/JBODStorage.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include "JBODStorage.hpp"
#include <simgrid/s4u/Actor.hpp>
#include <simgrid/s4u/Comm.hpp>
#include <simgrid/s4u/Exec.hpp>

XBT_LOG_NEW_DEFAULT_CATEGORY(fsmode_jbod, "File System module: JBOD Storage related logs");

namespace simgrid::module::fs {

static void jbod_controller(JBODStorage* js) {
js->mqueue()->get<void*>();
}
/**
* @brief Method to create an instance of a JBOD (Just a Bunch of Disks) storage
* @param name: the storage's name
Expand All @@ -19,17 +20,16 @@ namespace simgrid::module::fs {
JBODStorage::JBODStorage(const std::string& name, const std::vector<s4u::Disk*>& disks) : Storage(name) {
disks_ = disks;
num_disks_ = disks.size();
parity_disk_idx_ = num_disks_ - 1;
controller_host_ = disks_.front()->get_host();
// Create a no-op controller
mq_ = s4u::MessageQueue::by_name(name+"_controller_mq");
controller_ = s4u::Actor::create(name+"_controller", controller_host_, jbod_controller, this);
controller_ = s4u::Actor::create(name+"_controller", controller_host_, [this](){
//mq_->get<void*>();
});
controller_->daemonize();
}

s4u::ActivityPtr JBODStorage::read_init(sg_size_t size) {
throw std::runtime_error("JBODStorage::read_init(): NOT IMPLEMENTED YET");
}

s4u::ActivityPtr JBODStorage::read_async(sg_size_t size) {
throw std::runtime_error("JBODStorage::read_async(): NOT IMPLEMENTED YET");
}
Expand All @@ -39,15 +39,77 @@ namespace simgrid::module::fs {

}

s4u::ActivityPtr JBODStorage::write_init(sg_size_t size) {
throw std::runtime_error("JBODStorage::write_init(): NOT IMPLEMENTED YET");
}

s4u::ActivityPtr JBODStorage::write_async(sg_size_t size) {
throw std::runtime_error("JBODStorage::write_async(): NOT IMPLEMENTED YET");
// Transfer data from the host that requested a write to the controller host of the JBOD
auto comm = s4u::Comm::sendto_init(s4u::Host::current(), controller_host_);
// Determine what size to write on individual disks according to RAID level, and update information on
// parity disk index
sg_size_t write_size = 0;
switch(raid_level_) {
case RAID::RAID0:
write_size = size / num_disks_;
break;
case RAID::RAID1:
write_size = size;
break;
case RAID::RAID4:
write_size = size / (num_disks_ - 1);
break;
case RAID::RAID5:
update_parity_disk_idx();
write_size = size / (num_disks_ - 1);
break;
case RAID::RAID6:
update_parity_disk_idx();
update_parity_disk_idx();
write_size = size / (num_disks_ - 2);
break;
default:
throw std::runtime_error("Unsupported RAID level. Supported level are: 0, 1, 4, 5, and 6");
}
// Compute the parity block (if any)
s4u::ExecPtr parity_block_comp = nullptr;
if (raid_level_ == RAID::RAID4 || raid_level_ == RAID::RAID5 || raid_level_ == RAID::RAID6) {
// Assume 1 flop per byte to write per parity block and two for RAID6.
// Do not assign the Exec yet, will be done after the completion of the CommPtr
if (raid_level_ == RAID::RAID6)
parity_block_comp = s4u::Exec::init()->set_flops_amount(200 * write_size);
else
parity_block_comp = s4u::Exec::init()->set_flops_amount(write_size);
} else // Create a no-op activity
parity_block_comp = s4u::Exec::init()->set_flops_amount(0);

// Do not start computing the parity block before the completion of the comm to the controller
comm->add_successor(parity_block_comp);
// Start the comm by setting its payload
comm->set_payload_size(size);
// Parity Block Computation is now blocked by Comm, start it by assigning it the controller host
parity_block_comp->set_host(controller_host_);

// Create a no-op Activity that depends on the completion of all I/Os. This is the one ActivityPtr returned
// to the caller
s4u::ExecPtr completion_activity = s4u::Exec::init()->set_flops_amount(0);

// Create the I/O activities on individual disks
std::vector<s4u::IoPtr> ios;
for (const auto* disk : disks_) {
auto io = s4u::IoPtr(disk->io_init(write_size, s4u::Io::OpType::WRITE));
io->set_name(disk->get_name());
ios.push_back(io);
// Do no start the I/Os before the completion of the computation of the parity block
parity_block_comp->add_successor(io);
// Have the completion activity depend on every I/O
io->add_successor(completion_activity);
io->start();
}

// Completion Actitity is now blocked by I/Os, start it
completion_activity->start();

return completion_activity;
}

void JBODStorage::write(sg_size_t size) {
throw std::runtime_error("JBODStorage::write(): NOT IMPLEMENTED YET");
write_async(size)->wait();
}
}
8 changes: 0 additions & 8 deletions src/OneDiskStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ namespace simgrid::module::fs {
controller_->daemonize();
}

s4u::ActivityPtr OneDiskStorage::read_init(sg_size_t size) {
throw std::runtime_error("OneDiskStorage::read_init(): NOT IMPLEMENTED YET");
}

s4u::ActivityPtr OneDiskStorage::read_async(sg_size_t size) {
throw std::runtime_error("OneDiskStorage::read_async(): NOT IMPLEMENTED YET");
}
Expand All @@ -37,10 +33,6 @@ namespace simgrid::module::fs {

}

s4u::ActivityPtr OneDiskStorage::write_init(sg_size_t size) {
throw std::runtime_error("OneDiskStorage::write_init(): NOT IMPLEMENTED YET");
}

s4u::ActivityPtr OneDiskStorage::write_async(sg_size_t size) {
throw std::runtime_error("OneDiskStorage::write_async(): NOT IMPLEMENTED YET");
}
Expand Down

0 comments on commit dbb1dd3

Please sign in to comment.