Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 5 Jul 2017 12:16:29 +0000 (14:16 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 5 Jul 2017 12:16:29 +0000 (14:16 +0200)
16 files changed:
examples/s4u/actor-daemon/s4u_actor-daemon.cpp
include/simgrid/s4u/File.hpp
src/include/surf/surf.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.hpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/surf_c_bindings.cpp
tools/cmake/DefinePackages.cmake

index 5ef84f6..bc075a6 100644 (file)
@@ -39,5 +39,7 @@ int main(int argc, char* argv[])
 
   e->run();
 
+  delete e;
+
   return 0;
 }
index e3b644b..d6cd734 100644 (file)
@@ -64,8 +64,8 @@ public:
   void move(const char* fullpath);
 
   /** Remove a file from disk */
-  void unlink();
-  void unlink(sg_host_t host);
+  int unlink();
+  int unlink(sg_host_t host);
 
   /* FIXME: add these to the S4U API:
   XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t file);
index 30066f4..d691b54 100644 (file)
@@ -147,16 +147,6 @@ XBT_PUBLIC(surf_action_t) surf_host_read(sg_host_t host, surf_file_t fd, sg_size
 /** @brief Create a file writing action on the given host  */
 XBT_PUBLIC(surf_action_t) surf_host_write(sg_host_t host, surf_file_t fd, sg_size_t size);
 
-/**
- * @brief Unlink a file descriptor
- *
- * @param host The surf host
- * @param fd The file descriptor
- *
- * @return 0 if failed to unlink, 1 otherwise
- */
-XBT_PUBLIC(int) surf_host_unlink(sg_host_t host, surf_file_t fd);
-
 /**
  * @brief Move a file to another location on the *same mount point*.
  * @details [long description]
@@ -169,21 +159,6 @@ XBT_PUBLIC(int) surf_host_unlink(sg_host_t host, surf_file_t fd);
  */
 XBT_PUBLIC(int) surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath);
 
-/**
- * @brief Set the position indictator assiociated with the file descriptor to a new position
- * @details [long description]
- *
- * @param host The surf host
- * @param fd The file descriptor
- * @param offset The offset from the origin
- * @param origin Position used as a reference for the offset
- *  - SEEK_SET: beginning of the file
- *  - SEEK_CUR: current position indicator
- *  - SEEK_END: end of the file
- * @return MSG_OK if successful, otherwise MSG_TASK_CANCELED
- */
-XBT_PUBLIC(int) surf_host_file_seek(sg_host_t host, surf_file_t fd, sg_offset_t offset, int origin);
-
 /**
  * @brief [brief description]
  * @details [long description]
index 25595a9..7f9a7d5 100644 (file)
@@ -93,14 +93,14 @@ void File::move(const char* fullpath)
   simcall_file_move(pimpl_,fullpath);
 }
 
-void File::unlink()
+int File::unlink()
 {
-  simcall_file_unlink(pimpl_, Host::current());
+  return simgrid::simix::kernelImmediate([this] { return pimpl_->unlink(Host::current()); });
 }
 
-void File::unlink(sg_host_t host)
+int File::unlink(sg_host_t host)
 {
-  simcall_file_unlink(pimpl_, host);
+  return simgrid::simix::kernelImmediate([this, host] { return pimpl_->unlink(host); });
 }
 
 }} // namespace simgrid::s4u
index 55059b5..b5d9fc0 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
- *
- */
-int simcall_file_unlink(surf_file_t fd, sg_host_t host)
-{
-  return simcall_BODY_file_unlink(fd, host);
-}
-
-
 /**
  * \ingroup simix_file_management
  * \brief Move a file to another location on the *same mount point*.
index 7d414e6..617d35b 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_unlink__get__fd(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]);
-}
-static inline surf_file_t simcall_file_unlink__getraw__fd(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<surf_file_t>(simcall->args[0]);
-}
-static inline void simcall_file_unlink__set__fd(smx_simcall_t simcall, surf_file_t arg)
-{
-  simgrid::simix::marshal<surf_file_t>(simcall->args[0], arg);
-}
-static inline sg_host_t simcall_file_unlink__get__host(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]);
-}
-static inline sg_host_t simcall_file_unlink__getraw__host(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[1]);
-}
-static inline void simcall_file_unlink__set__host(smx_simcall_t simcall, sg_host_t arg)
-{
-  simgrid::simix::marshal<sg_host_t>(simcall->args[1], arg);
-}
-static inline int simcall_file_unlink__get__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal<int>(simcall->result);
-}
-static inline int simcall_file_unlink__getraw__result(smx_simcall_t simcall)
-{
-  return simgrid::simix::unmarshal_raw<int>(simcall->result);
-}
-static inline void simcall_file_unlink__set__result(smx_simcall_t simcall, int result){
-    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]);
index 0833c32..538c063 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_unlink(surf_file_t fd, sg_host_t host)
-  {
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_file_unlink(fd, host);
-    return simcall<int, surf_file_t, sg_host_t>(SIMCALL_FILE_UNLINK, 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 */
index e9a0bd4..a0c7fd9 100644 (file)
@@ -65,7 +65,6 @@ typedef enum {
   SIMCALL_FILE_WRITE,
   SIMCALL_FILE_OPEN,
   SIMCALL_FILE_CLOSE,
-  SIMCALL_FILE_UNLINK,
   SIMCALL_FILE_MOVE,
   SIMCALL_MC_RANDOM,
   SIMCALL_SET_CATEGORY,
index 69c9e26..84ed2a8 100644 (file)
@@ -71,7 +71,6 @@ const char* simcall_names[] = {
     "SIMCALL_FILE_WRITE",
     "SIMCALL_FILE_OPEN",
     "SIMCALL_FILE_CLOSE",
-    "SIMCALL_FILE_UNLINK",
     "SIMCALL_FILE_MOVE",
     "SIMCALL_MC_RANDOM",
     "SIMCALL_SET_CATEGORY",
@@ -358,13 +357,6 @@ case SIMCALL_FILE_CLOSE:
                              simgrid::simix::unmarshal<sg_host_t>(simcall->args[1]));
   break;
 
-case SIMCALL_FILE_UNLINK:
-  simgrid::simix::marshal<int>(simcall->result,
-                               SIMIX_file_unlink(simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
-                                                 simgrid::simix::unmarshal<sg_host_t>(simcall->args[1])));
-  SIMIX_simcall_answer(simcall);
-  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]),
index 68ad25d..8eb3659 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_unlink(surf_file_t fd, sg_host_t host) [[nohandler]];
 int         file_move(surf_file_t fd, const char* fullpath);
 
 int        mc_random(int min, int max);
index f106155..f303ed6 100644 (file)
@@ -113,15 +113,6 @@ smx_activity_t SIMIX_file_close(surf_file_t file, sg_host_t host)
   return synchro;
 }
 
-//SIMIX FILE UNLINK
-int SIMIX_file_unlink(surf_file_t file, sg_host_t host)
-{
-  if (host->isOff())
-    THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->cname());
-
-  return surf_host_unlink(host, file);
-}
-
 int simcall_HANDLER_file_move(smx_simcall_t simcall, surf_file_t file, const char* fullpath)
 {
   return SIMIX_file_move(simcall->issuer, file, fullpath);
index eea45fc..0150b5c 100644 (file)
@@ -26,22 +26,8 @@ public:
   void setPosition(sg_size_t size) { current_position_ = size; }
   void incrPosition(sg_size_t incr) { current_position_ += incr; }
   sg_size_t tell() { return current_position_; }
-  int seek(sg_offset_t offset, int origin)
-  {
-    switch (origin) {
-      case SEEK_SET:
-        current_position_ = offset;
-        return 0;
-      case SEEK_CUR:
-        current_position_ += offset;
-        return 0;
-      case SEEK_END:
-        current_position_ = size_ + offset;
-        return 0;
-      default:
-        return -1;
-    }
-  }
+  int seek(sg_offset_t offset, int origin);
+  int unlink(sg_host_t host);
 
 private:
   std::string path_;
index 66be41d..0b5ac06 100644 (file)
@@ -137,30 +137,6 @@ Action* HostImpl::write(surf_file_t fd, sg_size_t size)
   return st->write(fd, size);
 }
 
-int HostImpl::unlink(surf_file_t fd)
-{
-  if (not fd) {
-    XBT_WARN("No such file descriptor. Impossible to unlink");
-    return -1;
-  } else {
-
-    simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount());
-    /* Check if the file is on this storage */
-    if (st->content_->find(fd->cname()) == st->content_->end()) {
-      XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->cname(), st->cname());
-      return -1;
-    } else {
-      XBT_DEBUG("UNLINK %s on disk '%s'", fd->cname(), st->cname());
-      st->usedSize_ -= fd->size();
-
-      // Remove the file from storage
-      st->content_->erase(fd->cname());
-
-      return 0;
-    }
-  }
-}
-
 int HostImpl::fileMove(surf_file_t fd, const char* fullpath)
 {
   /* Check if the new full path is on the same mount point */
index 6fe5755..fd170de 100644 (file)
@@ -80,15 +80,6 @@ public:
    */
   virtual Action* close(surf_file_t fd);
 
-  /**
-   * @brief Unlink a file
-   * @details [long description]
-   *
-   * @param fd [description]
-   * @return [description]
-   */
-  virtual int unlink(surf_file_t fd);
-
   /**
    * @brief Read a file
    *
index 07be1f9..300d1ad 100644 (file)
@@ -169,10 +169,6 @@ surf_action_t surf_host_close(sg_host_t host, surf_file_t fd){
   return host->pimpl_->close(fd);
 }
 
-int surf_host_unlink(sg_host_t host, surf_file_t fd){
-  return host->pimpl_->unlink(fd);
-}
-
 surf_action_t surf_host_read(sg_host_t host, surf_file_t fd, sg_size_t size){
   return host->pimpl_->read(fd, size);
 }
index f4d5b0f..dd2b085 100644 (file)
@@ -325,6 +325,7 @@ set(SURF_SRC
   src/surf/cpu_interface.cpp
   src/surf/cpu_ti.cpp
   src/surf/fair_bottleneck.cpp
+  src/surf/FileImpl.cpp
   src/surf/instr_routing.cpp
   src/surf/instr_surf.cpp
   src/surf/lagrange.cpp