Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 10 Jul 2017 11:18:50 +0000 (13:18 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 11 Jul 2017 07:25:30 +0000 (09:25 +0200)
include/simgrid/s4u/File.hpp
include/simgrid/s4u/Storage.hpp
src/include/surf/surf.h
src/kernel/activity/SynchroIo.cpp
src/s4u/s4u_storage.cpp
src/simix/smx_io_private.h
src/surf/FileImpl.cpp
src/surf/HostImpl.cpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
src/surf/storage_n11.cpp

index 6736f85..9fbc6f2 100644 (file)
@@ -32,11 +32,7 @@ public:
   /** Retrieves the path to the file */
   const char* getPath() { return path_; }
 
-  /** Simulates a read action. Returns the size of data actually read
-   *
-   *  FIXME: reading from a remotely mounted disk is not implemented yet.
-   *  Any storage is considered as local, and no network communication ever occur.
-   */
+  /** Simulates a local read action. Returns the size of data actually read */
   sg_size_t read(sg_size_t size);
 
   /** Simulates a write action. Returns the size of data actually written. */
@@ -66,11 +62,6 @@ public:
   /** Remove a file from disk */
   int unlink();
 
-  /* FIXME: add these to the S4U API:
-  XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t file);
-  XBT_PUBLIC(msg_error_t) MSG_file_rcopy(msg_file_t fd, msg_host_t host, const char* fullpath);
-  XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const char* fullpath);
-  */
   const char* storage_type;
   const char* storageId;
   std::string mount_point;
index 615e3e7..854e0f9 100644 (file)
@@ -32,10 +32,9 @@ public:
   const char* getName();
   const char* getType();
   Host* getHost();
+  sg_size_t getSize(); /** Retrieve the total amount of space of this storage element */
   sg_size_t getSizeFree();
   sg_size_t getSizeUsed();
-  /** Retrieve the total amount of space of this storage element */
-  sg_size_t getSize();
 
   xbt_dict_t getProperties();
   const char* getProperty(const char* key);
@@ -45,6 +44,8 @@ public:
   void setUserdata(void* data) { userdata_ = data; }
   void* getUserdata() { return userdata_; }
 
+  surf::StorageImpl* getImpl() { return pimpl_; }
+
   /* The signals */
   /** @brief Callback signal fired when a new Link is created */
   static simgrid::xbt::signal<void(s4u::Storage&)> onCreation;
@@ -53,9 +54,9 @@ public:
   static simgrid::xbt::signal<void(s4u::Storage&)> onDestruction;
 
   Host* attached_to_              = nullptr;
-  surf::StorageImpl* const pimpl_ = nullptr;
 
 private:
+  surf::StorageImpl* const pimpl_ = nullptr;
   std::string name_;
   void* userdata_ = nullptr;
 };
index f2447eb..0c183af 100644 (file)
@@ -49,7 +49,6 @@ typedef simgrid::surf::CpuModel surf_CpuModel;
 typedef simgrid::surf::Cpu surf_Cpu;
 typedef simgrid::surf::HostModel surf_HostModel;
 typedef simgrid::surf::NetworkModel surf_NetworkModel;
-typedef simgrid::surf::StorageImpl surf_Storage;
 typedef simgrid::surf::StorageModel surf_StorageModel;
 typedef simgrid::surf::Resource surf_Resource;
 typedef simgrid::surf::Action surf_Action;
@@ -62,7 +61,6 @@ typedef struct surf_CpuModel surf_CpuModel;
 typedef struct surf_Cpu surf_Cpu;
 typedef struct surf_HostModel surf_HostModel;
 typedef struct surf_NetworkModel surf_NetworkModel;
-typedef struct surf_StorageImpl surf_Storage;
 typedef struct surf_StorageModel surf_StorageModel;
 typedef struct surf_Resource surf_Resource;
 typedef struct surf_Host surf_Host;
index e954fae..a9543f7 100644 (file)
@@ -5,8 +5,6 @@
 
 #include "src/kernel/activity/SynchroIo.hpp"
 #include "src/simix/smx_private.h"
-#include "src/surf/FileImpl.hpp"
-#include "src/surf/StorageImpl.hpp"
 #include "src/surf/surf_interface.hpp"
 
 void simgrid::kernel::activity::IoImpl::suspend()
@@ -28,26 +26,21 @@ void simgrid::kernel::activity::IoImpl::post()
     case SIMCALL_FILE_WRITE:
       simcall_file_write__set__result(simcall, surf_io->getCost());
       break;
-
     case SIMCALL_FILE_READ:
       simcall_file_read__set__result(simcall, surf_io->getCost());
       break;
-
     default:
       break;
     }
   }
 
   switch (surf_io->getState()) {
-
     case simgrid::surf::Action::State::failed:
       state = SIMIX_FAILED;
       break;
-
     case simgrid::surf::Action::State::done:
       state = SIMIX_DONE;
       break;
-
     default:
       THROW_IMPOSSIBLE;
       break;
index 694466c..60a9142 100644 (file)
@@ -57,7 +57,7 @@ sg_size_t Storage::getSizeUsed()
 
 sg_size_t Storage::getSize()
 {
-  return pimpl_->size_;
+  return pimpl_->getSize();
 }
 
 xbt_dict_t Storage::getProperties()
index e4689f7..e51804d 100644 (file)
@@ -13,8 +13,6 @@
 
 XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
 XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PRIVATE smx_activity_t SIMIX_file_open(const char* mount, const char* path, sg_storage_t st);
-XBT_PRIVATE smx_activity_t SIMIX_file_close(surf_file_t fd, sg_host_t host);
 
 XBT_PRIVATE void SIMIX_io_destroy(smx_activity_t synchro);
 XBT_PRIVATE void SIMIX_io_finish(smx_activity_t synchro);
index fd81b4a..5354850 100644 (file)
@@ -5,7 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/surf/FileImpl.hpp"
-#include "src/surf/HostImpl.hpp"
+#include "src/surf/StorageImpl.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_file, surf, "Logging specific to the SURF file module");
 namespace simgrid {
@@ -14,8 +14,8 @@ namespace surf {
 FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_(path), mount_point_(mount)
 {
   XBT_DEBUG("\tOpen file '%s'", path.c_str());
-  location_ = st->pimpl_;
-  std::map<std::string, sg_size_t>* content = location_->content_;
+  location_ = st->getImpl();
+  std::map<std::string, sg_size_t>* content = location_->getContent();
   // if file does not exist create an empty file
   if (content->find(path) != content->end())
     size_ = content->at(path);
@@ -51,7 +51,7 @@ Action* FileImpl::write(sg_size_t size)
   /* Substract the part of the file that might disappear from the used sized on the storage element */
   location_->usedSize_ -= (size_ - current_position_);
   // If the storage is full before even starting to write
-  if (location_->usedSize_ >= location_->size_) {
+  if (location_->usedSize_ >= location_->getSize()) {
     action->setState(Action::State::failed);
   }
   return action;
@@ -77,7 +77,7 @@ int FileImpl::seek(sg_offset_t offset, int origin)
 int FileImpl::unlink()
 {
   /* Check if the file is on this storage */
-  if (location_->content_->find(path_) == location_->content_->end()) {
+  if (location_->getContent()->find(path_) == location_->getContent()->end()) {
     XBT_WARN("File %s is not on disk %s. Impossible to unlink", cname(), location_->cname());
     return -1;
   } else {
@@ -85,7 +85,7 @@ int FileImpl::unlink()
     location_->usedSize_ -= size_;
 
     // Remove the file from storage
-    location_->content_->erase(path_);
+    location_->getContent()->erase(path_);
 
     return 0;
   }
@@ -95,7 +95,7 @@ void FileImpl::move(const char* fullpath)
 {
   /* Check if the new full path is on the same mount point */
   if (not strncmp(mount_point_.c_str(), fullpath, mount_point_.size())) {
-    std::map<std::string, sg_size_t>* content = location_->content_;
+    std::map<std::string, sg_size_t>* content = location_->getContent();
     if (content->find(path_) != content->end()) { // src file exists
       sg_size_t new_size = content->at(path_);
       content->erase(path_);
index 76576cd..6d88f27 100644 (file)
@@ -103,7 +103,7 @@ HostImpl::HostImpl(s4u::Host* host) : piface_(host)
 void HostImpl::getAttachedStorageList(std::vector<const char*>* storages)
 {
   for (auto s : storage_)
-    if (s.second->attach_ == piface_->getCname())
+    if (s.second->getHost() == piface_->getCname())
       storages->push_back(s.second->piface_.getName());
 }
 
index 8faa657..1fb0fbc 100644 (file)
@@ -62,9 +62,8 @@ StorageImpl::StorageImpl(Model* model, const char* name, lmm_system_t maxminSyst
                          const char* type_id, const char* content_name, sg_size_t size, const char* attach)
     : Resource(model, name, lmm_constraint_new(maxminSystem, this, MAX(bread, bwrite)))
     , piface_(this)
-    , size_(size)
-    , usedSize_(0)
     , typeId_(type_id)
+    , size_(size)
     , attach_(attach)
 {
   content_ = parseContent(content_name);
index 3061a60..97a3e7d 100644 (file)
@@ -102,14 +102,6 @@ public:
   void turnOn() override;
   void turnOff() override;
 
-  std::map<std::string, sg_size_t>* content_;
-  sg_size_t size_;
-  sg_size_t usedSize_;
-  std::string typeId_;
-  std::string attach_; // Name of the host to which this storage is attached.
-                       // Only used until the platform is fully parsed only.
-                       // Then the interface stores the Host directly.
-
   /**
    * @brief Read a file
    *
@@ -146,6 +138,8 @@ public:
    * @return The used size in bytes of the current Storage
    */
   virtual sg_size_t getUsedSize();
+  virtual sg_size_t getSize() { return size_; }
+  virtual std::string getHost() { return attach_; }
 
   std::map<std::string, sg_size_t>* parseContent(const char* filename);
   static std::unordered_map<std::string, StorageImpl*>* storages;
@@ -153,6 +147,16 @@ public:
 
   lmm_constraint_t constraintWrite_; /* Constraint for maximum write bandwidth*/
   lmm_constraint_t constraintRead_;  /* Constraint for maximum write bandwidth*/
+
+  std::string typeId_;
+  sg_size_t usedSize_ = 0;
+
+private:
+  sg_size_t size_;
+  std::map<std::string, sg_size_t>* content_;
+  // Name of the host to which this storage is attached. Only used at platform parsing time, then the interface stores
+  // the Host directly.
+  std::string attach_;
 };
 
 /**********
index 819b1f5..2ab9fce 100644 (file)
@@ -18,12 +18,12 @@ extern std::map<std::string, storage_type_t> storage_types;
 static void check_disk_attachment()
 {
   for (auto s : *simgrid::surf::StorageImpl::storagesMap()) {
-    simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s.second->attach_.c_str());
+    simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s.second->getHost().c_str());
     if (not host_elm)
       surf_parse_error("Unable to attach storage %s: host %s does not exist.", s.second->cname(),
-                       s.second->attach_.c_str());
+                       s.second->getHost().c_str());
     else
-      s.second->piface_.attached_to_ = sg_host_by_name(s.second->attach_.c_str());
+      s.second->piface_.attached_to_ = sg_host_by_name(s.second->getHost().c_str());
   }
 }
 
@@ -74,10 +74,8 @@ double StorageN11Model::nextOccuringEvent(double now)
 
 void StorageN11Model::updateActionsState(double /*now*/, double delta)
 {
-
   ActionList *actionSet = getRunningActionSet();
-  for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
-      ; it != itend ; it=itNext) {
+  for (ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end()); it != itend; it = itNext) {
     ++itNext;
 
     StorageAction *action = static_cast<StorageAction*>(&*it);
@@ -104,8 +102,8 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
       //  which becomes the new file size
       action->file_->setSize(action->file_->tell());
 
-      action->storage_->content_->erase(action->file_->cname());
-      action->storage_->content_->insert({action->file_->cname(), action->file_->size()});
+      action->storage_->getContent()->erase(action->file_->cname());
+      action->storage_->getContent()->insert({action->file_->cname(), action->file_->size()});
     }
 
     action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
@@ -114,7 +112,7 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
       action->updateMaxDuration(delta);
 
     if (action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 &&
-        action->storage_->usedSize_ == action->storage_->size_) {
+        action->storage_->usedSize_ == action->storage_->getSize()) {
       action->finish();
       action->setState(Action::State::failed);
     } else if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||