From: Frederic Suter Date: Wed, 29 Nov 2017 11:48:50 +0000 (+0100) Subject: Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid X-Git-Tag: v3.18~210 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b5384472c9da0b343dccfbbdcf18c49f1e798b3f?hp=e81d794214e733cedb4c48f6dcd061d5e28599b0 Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid --- diff --git a/examples/s4u/io/s4u-io.cpp b/examples/s4u/io/s4u-io.cpp index c78369746d..ab43a7a735 100644 --- a/examples/s4u/io/s4u-io.cpp +++ b/examples/s4u/io/s4u-io.cpp @@ -21,12 +21,8 @@ public: simgrid::s4u::Storage* storage = kv.second; // Retrieve disk's information - sg_size_t free_size = storage->getSizeFree(); - sg_size_t used_size = storage->getSizeUsed(); - sg_size_t size = storage->getSize(); - - XBT_INFO(" %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->getCname(), mountpoint.c_str(), used_size, - free_size, size); + XBT_INFO(" %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->getCname(), mountpoint.c_str(), + sg_storage_get_size_used(storage), sg_storage_get_size_free(storage), sg_storage_get_size(storage)); } } diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index c8af06f4e4..ad8c242bba 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -234,8 +234,6 @@ XBT_PUBLIC(msg_error_t) MSG_file_rcopy(msg_file_t fd, msg_host_t host, const cha XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const char* fullpath); /************************** Storage handling ***********************************/ XBT_PUBLIC(const char *) MSG_storage_get_name(msg_storage_t storage); -XBT_PUBLIC(sg_size_t) MSG_storage_get_free_size(msg_storage_t storage); -XBT_PUBLIC(sg_size_t) MSG_storage_get_used_size(msg_storage_t storage); XBT_PUBLIC(msg_storage_t) MSG_storage_get_by_name(const char *name); XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage); XBT_PUBLIC(void) MSG_storage_set_property_value(msg_storage_t storage, const char* name, char* value); @@ -244,7 +242,6 @@ XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar(); XBT_PUBLIC(msg_error_t) MSG_storage_set_data(msg_storage_t host, void *data); XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage); XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage); -XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage); XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage); XBT_PUBLIC(sg_size_t) MSG_storage_read(msg_storage_t storage, sg_size_t size); XBT_PUBLIC(sg_size_t) MSG_storage_write(msg_storage_t storage, sg_size_t size); diff --git a/include/simgrid/plugins/file_system.h b/include/simgrid/plugins/file_system.h index bb22a1a63a..b89b951380 100644 --- a/include/simgrid/plugins/file_system.h +++ b/include/simgrid/plugins/file_system.h @@ -13,8 +13,14 @@ SG_BEGIN_DECL() XBT_PUBLIC(void) sg_storage_file_system_init(); +XBT_PUBLIC(sg_size_t) sg_storage_get_size_free(sg_storage_t st); +XBT_PUBLIC(sg_size_t) sg_storage_get_size_used(sg_storage_t st); +XBT_PUBLIC(sg_size_t) sg_storage_get_size(sg_storage_t st); #define MSG_storage_file_system_init() sg_storage_file_system_init() +#define MSG_storage_get_free_size(st) sg_storage_get_size_free(st) +#define MSG_storage_get_used_size(st) sg_storage_get_size_used(st) +#define MSG_storage_get_size(st) sg_storage_get_size(st) SG_END_DECL() diff --git a/include/simgrid/s4u/Storage.hpp b/include/simgrid/s4u/Storage.hpp index 8ba939c39e..9b1fe85d12 100644 --- a/include/simgrid/s4u/Storage.hpp +++ b/include/simgrid/s4u/Storage.hpp @@ -39,11 +39,6 @@ public: const char* getCname() const; 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(); - void decrUsedSize(sg_size_t size); - void incrUsedSize(sg_size_t size); std::map* getProperties(); const char* getProperty(std::string key); diff --git a/src/bindings/java/jmsg_storage.cpp b/src/bindings/java/jmsg_storage.cpp index a31349deb1..548780c373 100644 --- a/src/bindings/java/jmsg_storage.cpp +++ b/src/bindings/java/jmsg_storage.cpp @@ -6,6 +6,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simgrid/msg.h" +#include "simgrid/plugins/file_system.h" #include "include/xbt/signal.hpp" #include "jmsg.hpp" diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index 394998768c..9484c56b78 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -361,26 +361,6 @@ const char* MSG_storage_get_name(msg_storage_t storage) return storage->getCname(); } -/** \ingroup msg_storage_management - * \brief Returns the free space size of a storage element - * \param storage a storage - * \return the free space size of the storage element (as a #sg_size_t) - */ -sg_size_t MSG_storage_get_free_size(msg_storage_t storage) -{ - return storage->getSizeFree(); -} - -/** \ingroup msg_storage_management - * \brief Returns the used space size of a storage element - * \param storage a storage - * \return the used space size of the storage element (as a #sg_size_t) - */ -sg_size_t MSG_storage_get_used_size(msg_storage_t storage) -{ - return storage->getSizeUsed(); -} - /** \ingroup msg_storage_management * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this storage * \param storage a storage @@ -489,17 +469,6 @@ xbt_dict_t MSG_storage_get_content(msg_storage_t storage) return content_as_dict; } -/** \ingroup msg_storage_management - * - * \brief Returns the size of a #msg_storage_t. - * \param storage a storage - * \return The size of the storage - */ -sg_size_t MSG_storage_get_size(msg_storage_t storage) -{ - return storage->getSize(); -} - /** \ingroup msg_storage_management * * \brief Returns the host name the storage is attached to diff --git a/src/s4u/s4u_file.cpp b/src/s4u/s4u_file.cpp index a78e0f93b1..a81e922acb 100644 --- a/src/s4u/s4u_file.cpp +++ b/src/s4u/s4u_file.cpp @@ -76,13 +76,13 @@ sg_size_t File::write(sg_size_t size) { XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), localStorage->getCname(), size, size_); // If the storage is full before even starting to write - if (localStorage->getSizeUsed() >= localStorage->getSize()) + if (sg_storage_get_size_used(localStorage) >= sg_storage_get_size(localStorage)) return 0; /* Substract the part of the file that might disappear from the used sized on the storage element */ - localStorage->decrUsedSize(size_ - current_position_); + localStorage->extension()->decrUsedSize(size_ - current_position_); sg_size_t write_size = localStorage->write(size); - localStorage->incrUsedSize(write_size); + localStorage->extension()->incrUsedSize(write_size); current_position_ += write_size; size_ = current_position_; @@ -153,7 +153,7 @@ int File::unlink() return -1; } else { XBT_DEBUG("UNLINK %s on disk '%s'", path_.c_str(), localStorage->getCname()); - localStorage->decrUsedSize(size_); + localStorage->extension()->decrUsedSize(size_); // Remove the file from storage localStorage->getContent()->erase(fullpath_); @@ -228,4 +228,19 @@ void sg_storage_file_system_init() simgrid::s4u::Storage::onDestruction.connect(&onStorageDestruction); } +sg_size_t sg_storage_get_size_free(sg_storage_t st) +{ + return st->getImpl()->getSize() - st->extension()->getUsedSize(); +} + +sg_size_t sg_storage_get_size_used(sg_storage_t st) +{ + return st->extension()->getUsedSize(); +} + +sg_size_t sg_storage_get_size(sg_storage_t st) +{ + return st->getImpl()->getSize(); +} + SG_END_DECL() diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index 9123343960..96f9733a83 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -55,35 +55,6 @@ Host* Storage::getHost() return attached_to_; } -sg_size_t Storage::getSizeFree() -{ - FileSystemStorageExt* file_system = extension(); - - return pimpl_->getSize() - file_system->getUsedSize(); -} - -sg_size_t Storage::getSizeUsed() -{ - FileSystemStorageExt* file_system = extension(); - return file_system->getUsedSize(); -} - -void Storage::decrUsedSize(sg_size_t size) -{ - FileSystemStorageExt* file_system = extension(); - file_system->decrUsedSize(size); -} - -void Storage::incrUsedSize(sg_size_t size) -{ - FileSystemStorageExt* file_system = extension(); - file_system->incrUsedSize(size); -} - -sg_size_t Storage::getSize() -{ - return pimpl_->getSize(); -} std::map* Storage::getProperties() { diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index 78598bcd5f..3e0169b071 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -107,11 +107,8 @@ static void storage_info(simgrid::s4u::Host* host) simgrid::s4u::Storage* storage = elm.second; XBT_INFO("\tStorage name: %s, mount name: %s", storage->getCname(), mount_name.c_str()); - sg_size_t free_size = storage->getSizeFree(); - sg_size_t used_size = storage->getSizeUsed(); - - XBT_INFO("\t\tFree size: %llu bytes", free_size); - XBT_INFO("\t\tUsed size: %llu bytes", used_size); + XBT_INFO("\t\tFree size: %llu bytes", sg_storage_get_size_free(storage)); + XBT_INFO("\t\tUsed size: %llu bytes", sg_storage_get_size_used(storage)); display_storage_properties(storage); dump_storage_by_name(storage->getCname());