Skip to content

Commit

Permalink
Merge branch 'main' of github.com:simgrid/file-system-module
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed May 24, 2024
2 parents 49ce0d7 + 5f40abb commit a24cbe2
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion include/fsmod/FileSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace simgrid::fsmod {
[[nodiscard]] std::shared_ptr<Partition> partition_by_name_or_null(const std::string& name) const;

protected:
explicit FileSystem(std::string name, int max_num_open_files) : name_(std::move(name)), max_num_open_files_(max_num_open_files) {};
explicit FileSystem(std::string name, int max_num_open_files) noexcept: name_(std::move(name)), max_num_open_files_(max_num_open_files) {};

private:
[[nodiscard]] std::pair<std::shared_ptr<Partition>, std::string> find_path_at_mount_point(const std::string &full_path) const;
Expand Down
2 changes: 1 addition & 1 deletion include/fsmod/JBODStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace simgrid::fsmod {
/** @brief RAID level 6 */
RAID6 = 6};

JBODStorage(const std::string& name, const std::vector<simgrid::s4u::Disk*>& disks);
static std::shared_ptr<JBODStorage> create(const std::string& name,
const std::vector<simgrid::s4u::Disk*>& disks,
JBODStorage::RAID raid_level = RAID::RAID0);
Expand All @@ -52,7 +53,6 @@ namespace simgrid::fsmod {
protected:
s4u::MessageQueue* mqueue() const { return mq_; }

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_; }
Expand Down
4 changes: 1 addition & 3 deletions include/fsmod/OneDiskStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ namespace simgrid::fsmod {
*/
class XBT_PUBLIC OneDiskStorage : public Storage {
public:
OneDiskStorage(const std::string &name, simgrid::s4u::Disk *disk);
static std::shared_ptr<OneDiskStorage> create(const std::string &name, simgrid::s4u::Disk *disk);

s4u::IoPtr read_async(sg_size_t size) override;
void read(sg_size_t size) override;
s4u::IoPtr write_async(sg_size_t size) override;
void write(sg_size_t size) override;

protected:
OneDiskStorage(const std::string &name, simgrid::s4u::Disk *disk);

private:
s4u::MessageQueue *mq_;
};
Expand Down
2 changes: 1 addition & 1 deletion include/fsmod/Partition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace simgrid::fsmod {
LRU = 2
};

Partition(std::string name, std::shared_ptr<Storage> storage, sg_size_t size);
virtual ~Partition() = default;

/**
Expand All @@ -60,7 +61,6 @@ namespace simgrid::fsmod {
[[nodiscard]] sg_size_t get_free_space() const { return free_space_; }

protected:
Partition(std::string name, std::shared_ptr<Storage> storage, sg_size_t size);

// Methods to perform caching
virtual void create_space(sg_size_t num_bytes);
Expand Down
2 changes: 1 addition & 1 deletion include/fsmod/PathUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace simgrid::fsmod {
public:
static std::string simplify_path_string(const std::string &path);
static void remove_trailing_slashes(std::string &path);
static std::pair<std::string, std::string> split_path(std::string &path);
static std::pair<std::string, std::string> split_path(const std::string &path);
static bool is_at_mount_point(const std::string &simplified_absolute_path, const std::string &mount_point);
static std::string path_at_mount_point(const std::string &simplified_absolute_path, const std::string &mount_point);
};
Expand Down
25 changes: 25 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is used to scan the project for issues automatically
# Browse the result here: https://sonarcloud.io/organizations/simgrid/projects?sort=-size

sonar.organization=simgrid
sonar.projectKey=simgrid_file-system-module
sonar.projectName=FSMOD
sonar.projectVersion=0.1

sonar.links.scm=https://github.com/simgrid/file-system-module/
# Comma-separated paths to directories with sources (required)
sonar.sources=src,examples,include,test

# Replace alternative operator "not" with "!"
# I like it better, so please leave me alone
sonar.issue.ignore.multicriteria.c5a.ruleKey=cpp:S3659
sonar.issue.ignore.multicriteria.c5a.resourceKey=**/*.cpp
sonar.issue.ignore.multicriteria.c5b.ruleKey=cpp:S3659
sonar.issue.ignore.multicriteria.c5b.resourceKey=**/*.hpp

# Exclude our tests from the duplication detection.
# tests are expected to be somehow repetitive
sonar.cpd.exclusions=test/**

# Encoding of the source files
sonar.sourceEncoding=UTF-8
13 changes: 6 additions & 7 deletions src/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,20 @@ namespace simgrid::fsmod {
}
}

Partition *new_partition;

switch (caching_scheme) {
case Partition::CachingScheme::NONE:
new_partition = new Partition(cleanup_mount_point, std::move(storage), size);
this->partitions_[cleanup_mount_point] =
std::make_shared<Partition>(cleanup_mount_point, std::move(storage), size);
break;
case Partition::CachingScheme::FIFO:
new_partition = new PartitionFIFOCaching(cleanup_mount_point, std::move(storage), size);
this->partitions_[cleanup_mount_point] =
std::make_shared<PartitionFIFOCaching>(cleanup_mount_point, std::move(storage), size);
break;
case Partition::CachingScheme::LRU:
new_partition = new PartitionLRUCaching(cleanup_mount_point, std::move(storage), size);
this->partitions_[cleanup_mount_point] =
std::make_shared<PartitionLRUCaching>(cleanup_mount_point, std::move(storage), size);
break;
}

this->partitions_[cleanup_mount_point] = std::shared_ptr<Partition>(new_partition);
}

std::shared_ptr<Partition> FileSystem::partition_by_name(const std::string &name) const {
Expand Down
2 changes: 1 addition & 1 deletion src/JBODStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace simgrid::fsmod {
* @return
*/
std::shared_ptr<JBODStorage> JBODStorage::create(const std::string& name, const std::vector<s4u::Disk*>& disks, RAID raid_level) {
auto storage = std::shared_ptr<JBODStorage>(new JBODStorage(name, disks));
auto storage = std::make_shared<JBODStorage>(name, disks);
// Set the RAID level
storage->set_raid_level(raid_level);
return storage;
Expand Down
2 changes: 1 addition & 1 deletion src/OneDiskStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace simgrid::fsmod {
* @return
*/
std::shared_ptr<OneDiskStorage> OneDiskStorage::create(const std::string& name, s4u::Disk* disk) {
return std::shared_ptr<OneDiskStorage>(new OneDiskStorage(name, disk));
return std::make_shared<OneDiskStorage>(name, disk);
}

OneDiskStorage::OneDiskStorage(const std::string& name, s4u::Disk* disk) : Storage(name) {
Expand Down
6 changes: 3 additions & 3 deletions src/PathUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ namespace simgrid::fsmod {
* @param path_string: a simplified path string
* @return a <prefix , suffix> pair, where either one of them could be empty
*/
std::pair<std::string, std::string> PathUtil::split_path(std::string &path) {
std::pair<std::string, std::string> PathUtil::split_path(const std::string &path) {
std::string dir;
std::string file;
auto last_slash = path.find_last_of('/');
if (last_slash == std::string::npos) {

if (auto last_slash = path.find_last_of('/'); last_slash == std::string::npos) {
dir = "";
file = path;
} else {
Expand Down

0 comments on commit a24cbe2

Please sign in to comment.