Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
another move to FileImpl
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 5 Jul 2017 20:46:13 +0000 (22:46 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 5 Jul 2017 20:46:13 +0000 (22:46 +0200)
14 files changed:
include/simgrid/simix.h
src/s4u/s4u_file.cpp
src/simix/libsmx.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in
src/simix/smx_io.cpp
src/surf/FileImpl.cpp
src/surf/FileImpl.hpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/surf_c_bindings.cpp

index f1bb900..a544922 100644 (file)
@@ -295,17 +295,10 @@ XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration)
 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
 
 /*****************************   File   **********************************/
-XBT_PUBLIC(void*) simcall_file_get_data(surf_file_t fd);
-XBT_PUBLIC(void) simcall_file_set_data(surf_file_t fd, void* data);
 XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
 XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
 XBT_PUBLIC(surf_file_t) simcall_file_open(const char* mount, const char* path, sg_storage_t st);
 XBT_PUBLIC(int) simcall_file_close(surf_file_t fd, sg_host_t host);
-XBT_PUBLIC(int) simcall_file_unlink(surf_file_t fd, sg_host_t host);
-XBT_PUBLIC(sg_size_t) simcall_file_get_size(surf_file_t fd);
-XBT_PUBLIC(sg_size_t) simcall_file_tell(surf_file_t fd);
-XBT_PUBLIC(int) simcall_file_seek(surf_file_t fd, sg_offset_t offset, int origin);
-XBT_PUBLIC(int) simcall_file_move(surf_file_t fd, const char* fullpath);
 /************************** MC simcalls   **********************************/
 XBT_PUBLIC(int) simcall_mc_random(int min, int max);
 
index 7f9a7d5..64753e8 100644 (file)
@@ -90,12 +90,13 @@ sg_size_t File::tell()
 
 void File::move(const char* fullpath)
 {
-  simcall_file_move(pimpl_,fullpath);
+  sg_host_t host = Host::current();
+  simgrid::simix::kernelImmediate([this, host, fullpath] { pimpl_->move(host, fullpath); });
 }
 
 int File::unlink()
 {
-  return simgrid::simix::kernelImmediate([this] { return pimpl_->unlink(Host::current()); });
+  return unlink(Host::current());
 }
 
 int File::unlink(sg_host_t host)
index b5d9fc0..8a0d0fc 100644 (file)
@@ -689,16 +689,6 @@ int simcall_file_close(surf_file_t fd, sg_host_t host)
   return simcall_BODY_file_close(fd, host);
 }
 
-/**
- * \ingroup simix_file_management
- * \brief Move a file to another location on the *same mount point*.
- *
- */
-int simcall_file_move(surf_file_t fd, const char* fullpath)
-{
-  return simcall_BODY_file_move(fd, fullpath);
-}
-
 void simcall_run_kernel(std::function<void()> const& code)
 {
   simcall_BODY_run_kernel(&code);
index 617d35b..8f517f0 100644 (file)
@@ -1723,42 +1723,6 @@ static inline void simcall_file_close__set__result(smx_simcall_t simcall, int re
     simgrid::simix::marshal<int>(simcall->result, result);
 }
 
-static inline surf_file_t simcall_file_move__get__fd(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]);
-}
-static inline surf_file_t simcall_file_move__getraw__fd(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<surf_file_t>(simcall->args[0]);
-}
-static inline void simcall_file_move__set__fd(smx_simcall_t simcall, surf_file_t arg)
-{
-  simgrid::simix::marshal<surf_file_t>(simcall->args[0], arg);
-}
-static inline const char* simcall_file_move__get__fullpath(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<const char*>(simcall->args[1]);
-}
-static inline const char* simcall_file_move__getraw__fullpath(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<const char*>(simcall->args[1]);
-}
-static inline void simcall_file_move__set__fullpath(smx_simcall_t simcall, const char* arg)
-{
-  simgrid::simix::marshal<const char*>(simcall->args[1], arg);
-}
-static inline int simcall_file_move__get__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<int>(simcall->result);
-}
-static inline int simcall_file_move__getraw__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<int>(simcall->result);
-}
-static inline void simcall_file_move__set__result(smx_simcall_t simcall, int result){
-    simgrid::simix::marshal<int>(simcall->result, result);
-}
-
 static inline int simcall_mc_random__get__min(smx_simcall_t simcall)
 {
   return simgrid::simix::unmarshal<int>(simcall->args[0]);
@@ -1901,5 +1865,4 @@ XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd
 XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
 XBT_PRIVATE void simcall_HANDLER_file_open(smx_simcall_t simcall, const char* mount, const char* path, sg_storage_t st);
 XBT_PRIVATE void simcall_HANDLER_file_close(smx_simcall_t simcall, surf_file_t fd, sg_host_t host);
-XBT_PRIVATE int simcall_HANDLER_file_move(smx_simcall_t simcall, surf_file_t fd, const char* fullpath);
 XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
\ No newline at end of file
index 538c063..afb58a3 100644 (file)
@@ -360,13 +360,6 @@ inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) {
     return simcall<int, surf_file_t, sg_host_t>(SIMCALL_FILE_CLOSE, fd, host);
   }
 
-  inline static int simcall_BODY_file_move(surf_file_t fd, const char* fullpath)
-  {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) simcall_HANDLER_file_move(&SIMIX_process_self()->simcall, fd, fullpath);
-    return simcall<int, surf_file_t, const char*>(SIMCALL_FILE_MOVE, fd, fullpath);
-  }
-
 inline static int simcall_BODY_mc_random(int min, int max) {
     /* Go to that function to follow the code flow through the simcall barrier */
     if (0) simcall_HANDLER_mc_random(&SIMIX_process_self()->simcall, min, max);
index a0c7fd9..21c5fd3 100644 (file)
@@ -65,7 +65,6 @@ typedef enum {
   SIMCALL_FILE_WRITE,
   SIMCALL_FILE_OPEN,
   SIMCALL_FILE_CLOSE,
-  SIMCALL_FILE_MOVE,
   SIMCALL_MC_RANDOM,
   SIMCALL_SET_CATEGORY,
   SIMCALL_RUN_KERNEL,
index 84ed2a8..262e7e0 100644 (file)
@@ -71,7 +71,6 @@ const char* simcall_names[] = {
     "SIMCALL_FILE_WRITE",
     "SIMCALL_FILE_OPEN",
     "SIMCALL_FILE_CLOSE",
-    "SIMCALL_FILE_MOVE",
     "SIMCALL_MC_RANDOM",
     "SIMCALL_SET_CATEGORY",
     "SIMCALL_RUN_KERNEL",
@@ -357,13 +356,6 @@ case SIMCALL_FILE_CLOSE:
                              simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]));
   break;
 
-case SIMCALL_FILE_MOVE:
-  simgrid::simix::marshal<int>(
-      simcall->result, simcall_HANDLER_file_move(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
-                                                 simgrid::simix::unmarshal<const char*>(simcall->args[1])));
-  SIMIX_simcall_answer(simcall);
-  break;
-
 case SIMCALL_MC_RANDOM:
       simgrid::simix::marshal<int>(simcall->result, simcall_HANDLER_mc_random(simcall, simgrid::simix::unmarshal<int>(simcall->args[0]), simgrid::simix::unmarshal<int>(simcall->args[1])));
       SIMIX_simcall_answer(simcall);
index 8eb3659..e3cce1a 100644 (file)
@@ -89,7 +89,6 @@ sg_size_t   file_read(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
 sg_size_t   file_write(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
 surf_file_t  file_open(const char* mount, const char* path, sg_storage_t st) [[block]];
 int         file_close(surf_file_t fd, sg_host_t host) [[block]];
-int         file_move(surf_file_t fd, const char* fullpath);
 
 int        mc_random(int min, int max);
 void       set_category(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> synchro, const char* category) [[nohandler]];
index f303ed6..5089731 100644 (file)
@@ -113,17 +113,6 @@ smx_activity_t SIMIX_file_close(surf_file_t file, sg_host_t host)
   return synchro;
 }
 
-int simcall_HANDLER_file_move(smx_simcall_t simcall, surf_file_t file, const char* fullpath)
-{
-  return SIMIX_file_move(simcall->issuer, file, fullpath);
-}
-
-int SIMIX_file_move(smx_actor_t process, surf_file_t file, const char* fullpath)
-{
-  sg_host_t host = process->host;
-  return surf_host_file_move(host, file, fullpath);
-}
-
 void SIMIX_io_destroy(smx_activity_t synchro)
 {
   simgrid::kernel::activity::IoImplPtr io = boost::static_pointer_cast<simgrid::kernel::activity::IoImpl>(synchro);
index 2380376..59530a9 100644 (file)
@@ -45,5 +45,24 @@ int FileImpl::unlink(sg_host_t host)
     return 0;
   }
 }
+
+void FileImpl::move(sg_host_t host, 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 = host->pimpl_->findStorageOnMountList(mount_point_.c_str())->content_;
+    if (content->find(path_) != content->end()) { // src file exists
+      sg_size_t new_size = content->at(path_);
+      content->erase(path_);
+      std::string path = std::string(fullpath).substr(mount_point_.size(), strlen(fullpath));
+      content->insert({path.c_str(), new_size});
+      XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath, new_size);
+    } else {
+      XBT_WARN("File %s doesn't exist", path_.c_str());
+    }
+  } else {
+    XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath, mount_point_.c_str());
+  }
+}
 }
 }
index 0150b5c..98cb343 100644 (file)
@@ -28,6 +28,7 @@ public:
   sg_size_t tell() { return current_position_; }
   int seek(sg_offset_t offset, int origin);
   int unlink(sg_host_t host);
+  void move(sg_host_t host, const char* fullpath);
 
 private:
   std::string path_;
index 0b5ac06..9e03407 100644 (file)
@@ -137,27 +137,5 @@ Action* HostImpl::write(surf_file_t fd, sg_size_t size)
   return st->write(fd, size);
 }
 
-int HostImpl::fileMove(surf_file_t fd, const char* fullpath)
-{
-  /* Check if the new full path is on the same mount point */
-  if (not strncmp(fd->mount(), fullpath, strlen(fd->mount()))) {
-    std::map<std::string, sg_size_t>* content = findStorageOnMountList(fd->mount())->content_;
-    if (content->find(fd->name()) != content->end()) { // src file exists
-      sg_size_t new_size = content->at(fd->name());
-      content->erase(fd->name());
-      std::string path = std::string(fullpath).substr(strlen(fd->mount()), strlen(fullpath));
-      content->insert({path.c_str(), new_size});
-      XBT_DEBUG("Move file from %s to %s, size '%llu'", fd->cname(), fullpath, new_size);
-      return 0;
-    } else {
-      XBT_WARN("File %s doesn't exist", fd->cname());
-      return -1;
-    }
-  } else {
-    XBT_WARN("New full path %s is not on the same mount point: %s. Action has been canceled.", fullpath, fd->mount());
-    return -1;
-  }
-}
-
 }
 }
index fd170de..c8c36cd 100644 (file)
@@ -98,17 +98,6 @@ public:
    */
   virtual Action* write(surf_file_t fd, sg_size_t size);
 
-  /**
-   * @brief Move a file to another location on the *same mount point*.
-   * @details [long description]
-   *
-   * @param fd The file descriptor
-   * @param fullpath The new full path
-   * @return MSG_OK if successful, MSG_TASK_CANCELED and a warning if the new
-   * full path is not on the same mount point
-   */
-  virtual int fileMove(surf_file_t fd, const char* fullpath);
-
   std::map<std::string, simgrid::surf::StorageImpl*> storage_;
   simgrid::s4u::Host* piface_ = nullptr;
 
index 300d1ad..ab9f20b 100644 (file)
@@ -177,10 +177,6 @@ surf_action_t surf_host_write(sg_host_t host, surf_file_t fd, sg_size_t size){
   return host->pimpl_->write(fd, size);
 }
 
-int surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath){
-  return host->pimpl_->fileMove(fd, fullpath);
-}
-
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
   static_cast<simgrid::surf::CpuAction*>(action)->setBound(bound);
 }