From: Frederic Suter Date: Wed, 8 Mar 2017 14:44:18 +0000 (+0100) Subject: simplify storage internals X-Git-Tag: v3_15~183 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4c26ba57441232984df834fb6056d511478e02ff simplify storage internals --- diff --git a/include/surf/surf_routing.h b/include/surf/surf_routing.h index 20384e322a..abe93e0bd9 100644 --- a/include/surf/surf_routing.h +++ b/include/surf/surf_routing.h @@ -17,7 +17,6 @@ XBT_PUBLIC_DATA(int) SIMIX_STORAGE_LEVEL; //Simix storage level XBT_PUBLIC_DATA(xbt_lib_t) storage_lib; XBT_PUBLIC_DATA(int) ROUTING_STORAGE_LEVEL; //Routing storage level -XBT_PUBLIC_DATA(int) ROUTING_STORAGE_HOST_LEVEL; XBT_PUBLIC_DATA(int) SURF_STORAGE_LEVEL; // Surf storage level XBT_PUBLIC_DATA(xbt_lib_t) file_lib; XBT_PUBLIC_DATA(xbt_lib_t) storage_type_lib; diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 407c77fd31..d74dfd2f91 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -3,7 +3,6 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "src/surf/HostImpl.hpp" #include "src/plugins/vm/VirtualMachineImpl.hpp" #include @@ -113,11 +112,9 @@ HostImpl::~HostImpl() = default; simgrid::surf::Storage* HostImpl::findStorageOnMountList(const char* mount) { simgrid::surf::Storage* st = nullptr; - s_mount_t mnt; - unsigned int cursor; XBT_DEBUG("Search for storage name '%s' on '%s'", mount, piface_->cname()); - xbt_dynar_foreach (storage_, cursor, mnt) { + for (auto mnt : storage_) { XBT_DEBUG("See '%s'", mnt.name); if (!strcmp(mount, mnt.name)) { st = static_cast(mnt.storage); @@ -131,12 +128,10 @@ simgrid::surf::Storage* HostImpl::findStorageOnMountList(const char* mount) xbt_dict_t HostImpl::getMountedStorageList() { - s_mount_t mnt; - unsigned int i; xbt_dict_t storage_list = xbt_dict_new_homogeneous(nullptr); char* storage_name = nullptr; - xbt_dynar_foreach (storage_, i, mnt) { + for (auto mnt : storage_) { storage_name = (char*)static_cast(mnt.storage)->cname(); xbt_dict_set(storage_list, mnt.name, storage_name, nullptr); } @@ -166,14 +161,12 @@ Action* HostImpl::open(const char* fullpath) { simgrid::surf::Storage* st = nullptr; - s_mount_t mnt; - unsigned int cursor; size_t longest_prefix_length = 0; std::string path; std::string mount_name; XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath, piface_->cname()); - xbt_dynar_foreach (storage_, cursor, mnt) { + for (auto mnt : storage_) { XBT_DEBUG("See '%s'", mnt.name); std::string file_mount_name = std::string(fullpath).substr(0, strlen(mnt.name)); diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 3cf0989c73..70887a8b44 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -173,7 +173,7 @@ public: */ virtual int fileMove(surf_file_t fd, const char* fullpath); - xbt_dynar_t storage_ = nullptr; + std::vector storage_; simgrid::s4u::Host* piface_ = nullptr; simgrid::s4u::Host* getHost() { return piface_; } diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 4a237e7226..139683d24d 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -27,7 +27,7 @@ #include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse); -XBT_PRIVATE xbt_dynar_t mount_list = nullptr; +XBT_PRIVATE std::vector mount_list; namespace simgrid { namespace surf { @@ -77,8 +77,7 @@ void sg_platf_new_host(sg_platf_host_cbarg_t args) routing_get_current()->createHost(args->id, &args->speed_per_pstate, args->core_amount, &props); host->pimpl_->storage_ = mount_list; - xbt_lib_set(storage_lib, args->id, ROUTING_STORAGE_HOST_LEVEL, static_cast(mount_list)); - mount_list = nullptr; + mount_list.clear(); /* Change from the defaults */ if (args->state_trace) @@ -442,11 +441,9 @@ void sg_platf_new_mount(sg_platf_mount_cbarg_t mount){ mnt.storage = surf_storage_resource_priv(surf_storage_resource_by_name(mount->storageId)); mnt.name = xbt_strdup(mount->name); - if(!mount_list){ - XBT_DEBUG("Create a Mount list for %s",A_surfxml_host_id); - mount_list = xbt_dynar_new(sizeof(s_mount_t), mount_free); - } - xbt_dynar_push(mount_list, &mnt); + if (mount_list.empty()) + XBT_DEBUG("Create a Mount list for %s", A_surfxml_host_id); + mount_list.push_back(mnt); } void sg_platf_new_route(sg_platf_route_cbarg_t route) diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index dbbb601a02..89a0d0c046 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -17,7 +17,6 @@ xbt_lib_t storage_lib; int SIMIX_STORAGE_LEVEL = -1; // Simix storage level int MSG_STORAGE_LEVEL = -1; // Msg storage level int ROUTING_STORAGE_LEVEL = -1; // Routing for storage level -int ROUTING_STORAGE_HOST_LEVEL = -1; int SURF_STORAGE_LEVEL = -1; xbt_lib_t storage_type_lib; int ROUTING_STORAGE_TYPE_LEVEL = -1; //Routing for storage_type level diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index eb203e53b6..b89e1956ee 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -28,12 +28,6 @@ static inline void routing_storage_type_free(void *r) free(stype); } -static inline void routing_storage_host_free(void *r) -{ - xbt_dynar_t dyn = (xbt_dynar_t) r; - xbt_dynar_free(&dyn); -} - static void check_disk_attachment() { xbt_lib_cursor_t cursor; @@ -56,7 +50,6 @@ void storage_register_callbacks() instr_routing_define_callbacks(); ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, xbt_free_f); - ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib, routing_storage_host_free); ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib, routing_storage_type_free); SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, [](void *self) { delete static_cast(self);