From 94a5e6c017fdcf4882fe6cb518b6005d4c8dd8ae Mon Sep 17 00:00:00 2001 From: navarro Date: Fri, 2 Mar 2012 19:22:02 +0100 Subject: [PATCH 1/1] Add storage to functions --- include/msg/msg.h | 10 +++++----- include/simix/simix.h | 10 +++++----- src/include/surf/surf.h | 31 +++++++++++++++++-------------- src/msg/msg_io.c | 20 ++++++++++---------- src/simix/smx_io.c | 25 +++++++++++++++---------- src/simix/smx_io_private.h | 10 +++++----- src/simix/smx_smurf_private.h | 5 +++++ src/simix/smx_user.c | 15 ++++++++++----- 8 files changed, 72 insertions(+), 54 deletions(-) diff --git a/include/msg/msg.h b/include/msg/msg.h index 3aef4bb39b..e8b4adeb0d 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -38,11 +38,11 @@ XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void); /************************** File handling ***********************************/ -XBT_PUBLIC(size_t) MSG_file_read(void* ptr, size_t size, size_t nmemb, m_file_t stream); -XBT_PUBLIC(size_t) MSG_file_write(const void* ptr, size_t size, size_t nmemb, m_file_t stream); -XBT_PUBLIC(m_file_t) MSG_file_open(const char* path, const char* mode); -XBT_PUBLIC(int) MSG_file_close(m_file_t fp); -XBT_PUBLIC(int) MSG_file_stat(int fd, void* buf); +XBT_PUBLIC(size_t) MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, m_file_t stream); +XBT_PUBLIC(size_t) MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream); +XBT_PUBLIC(m_file_t) MSG_file_open(const char* storage, const char* path, const char* mode); +XBT_PUBLIC(int) MSG_file_close(const char* storage, m_file_t fp); +XBT_PUBLIC(int) MSG_file_stat(const char* storage, int fd, void* buf); /************************** Host handling ***********************************/ diff --git a/include/simix/simix.h b/include/simix/simix.h index 12fb3b77b0..3c5919e9ff 100644 --- a/include/simix/simix.h +++ b/include/simix/simix.h @@ -244,11 +244,11 @@ XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem, XBT_PUBLIC(unsigned int) simcall_sem_acquire_any(xbt_dynar_t sems); XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem); -XBT_PUBLIC(size_t) simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream); -XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream); -XBT_PUBLIC(smx_file_t) simcall_file_open(const char* path, const char* mode); -XBT_PUBLIC(int) simcall_file_close(smx_file_t fp); -XBT_PUBLIC(int) simcall_file_stat(int fd, void* buf); +XBT_PUBLIC(size_t) simcall_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream); +XBT_PUBLIC(size_t) simcall_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream); +XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path, const char* mode); +XBT_PUBLIC(int) simcall_file_close(const char* storage, smx_file_t fp); +XBT_PUBLIC(int) simcall_file_stat(const char* storage, int fd, void* buf); SG_END_DECL() #endif /* _SIMIX_SIMIX_H */ diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index eb1a9a232c..8cfa80ad49 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -208,13 +208,13 @@ typedef struct s_surf_file *surf_file_t; */ typedef struct surf_storage_model_extension_public { - surf_action_t(*open) (void *workstation, const char* path, const char* mode); - surf_action_t(*close) (void *workstation, surf_file_t fp); - surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream); - surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream); - surf_action_t(*stat) (void *workstation, int fd, void* buf); - void* (*create_resource) (const char* id, const char* model, - const char* content, xbt_dict_t properties); + surf_action_t(*open) (void *storage, const char* path, const char* mode); + surf_action_t(*close) (void *storage, surf_file_t fp); + surf_action_t(*read) (void *storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream); + surf_action_t(*write) (void *storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream); + surf_action_t(*stat) (void *storage, int fd, void* buf); + void* (*create_resource) (const char* id, const char* model,const char* type_id, + const char* content, xbt_dict_t storage_properties); } s_surf_model_extension_storage_t; /** \brief Workstation model extension public @@ -242,11 +242,11 @@ typedef struct surf_workstation_model_extension_public { double amount, double rate); double (*get_link_bandwidth) (const void *link); /**< Return the current bandwidth of a network link */ double (*get_link_latency) (const void *link); /**< Return the current latency of a network link */ - surf_action_t(*open) (void *workstation, const char* path, const char* mode); - surf_action_t(*close) (void *workstation, surf_file_t fp); - surf_action_t(*read) (void *workstation, void* ptr, size_t size, size_t nmemb, surf_file_t stream); - surf_action_t(*write) (void *workstation, const void* ptr, size_t size, size_t nmemb, surf_file_t stream); - surf_action_t(*stat) (void *workstation, int fd, void* buf); + surf_action_t(*open) (void *workstation, const char* storage, const char* path, const char* mode); + surf_action_t(*close) (void *workstation, const char* storage, surf_file_t fp); + surf_action_t(*read) (void *workstation, const char* storage, void* ptr, size_t size, size_t nmemb, surf_file_t stream); + surf_action_t(*write) (void *workstation, const char* storage, const void* ptr, size_t size, size_t nmemb, surf_file_t stream); + surf_action_t(*stat) (void *workstation, const char* storage, int fd, void* buf); int (*link_shared) (const void *link); xbt_dict_t(*get_properties) (const void *resource); void* (*link_create_resource) (const char *name, @@ -329,6 +329,9 @@ static inline void *surf_workstation_resource_by_name(const char *name){ static inline void *surf_network_resource_by_name(const char *name){ return xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL); } +static inline void *surf_storage_resource_by_name(const char *name){ + return xbt_lib_get_or_null(storage_lib, name, SURF_STORAGE_LEVEL); +} typedef struct surf_resource { surf_model_t model; @@ -342,12 +345,12 @@ typedef struct surf_resource { typedef struct s_storage_type { char *model; char *content; - xbt_dict_t properties; char *type_id; + xbt_dict_t properties; } s_storage_type_t, *storage_type_t; typedef struct s_mount { - char *type_id; + char *id; char *name; } s_mount_t, *mount_t; diff --git a/src/msg/msg_io.c b/src/msg/msg_io.c index 0ab1ee1cb9..d7486cfcd7 100644 --- a/src/msg/msg_io.c +++ b/src/msg/msg_io.c @@ -8,27 +8,27 @@ // FILE -size_t MSG_file_read(void* ptr, size_t size, size_t nmemb, m_file_t stream) +size_t MSG_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, m_file_t stream) { - return simcall_file_read(ptr, size, nmemb, (smx_file_t)stream); + return simcall_file_read(storage, ptr, size, nmemb, (smx_file_t)stream); } -size_t MSG_file_write(const void* ptr, size_t size, size_t nmemb, m_file_t stream) +size_t MSG_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, m_file_t stream) { - return simcall_file_write(ptr, size, nmemb, (smx_file_t)stream); + return simcall_file_write(storage, ptr, size, nmemb, (smx_file_t)stream); } -m_file_t MSG_file_open(const char* path, const char* mode) +m_file_t MSG_file_open(const char* storage, const char* path, const char* mode) { - return (m_file_t) simcall_file_open(path, mode); + return (m_file_t) simcall_file_open(storage, path, mode); } -int MSG_file_close(m_file_t fp) +int MSG_file_close(const char* storage, m_file_t fp) { - return simcall_file_close((smx_file_t)fp); + return simcall_file_close(storage, (smx_file_t)fp); } -int MSG_file_stat(int fd, void* buf) +int MSG_file_stat(const char* storage, int fd, void* buf) { - return simcall_file_stat(fd, buf); + return simcall_file_stat(storage, fd, buf); } diff --git a/src/simix/smx_io.c b/src/simix/smx_io.c index df706e660a..e96222564a 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.c @@ -18,6 +18,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, void SIMIX_pre_file_read(smx_simcall_t simcall) { smx_action_t action = SIMIX_file_read(simcall->issuer, + simcall->file_read.storage, simcall->file_read.ptr, simcall->file_read.size, simcall->file_read.nmemb, @@ -26,7 +27,7 @@ void SIMIX_pre_file_read(smx_simcall_t simcall) simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream) +smx_action_t SIMIX_file_read(smx_process_t process, const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream) { smx_action_t action; smx_host_t host = process->smx_host; @@ -46,7 +47,7 @@ smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size #endif action->io.host = host; - action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, ptr, size, nmemb, (surf_file_t)stream), + action->io.surf_io = surf_workstation_model->extension.workstation.read(host->host, storage, ptr, size, nmemb, (surf_file_t)stream), surf_workstation_model->action_data_set(action->io.surf_io, action); XBT_DEBUG("Create io action %p", action); @@ -58,6 +59,7 @@ smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size void SIMIX_pre_file_write(smx_simcall_t simcall) { smx_action_t action = SIMIX_file_write(simcall->issuer, + simcall->file_write.storage, simcall->file_write.ptr, simcall->file_write.size, simcall->file_write.nmemb, @@ -66,7 +68,7 @@ void SIMIX_pre_file_write(smx_simcall_t simcall) simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream) +smx_action_t SIMIX_file_write(smx_process_t process, const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream) { smx_action_t action; smx_host_t host = process->smx_host; @@ -86,7 +88,7 @@ smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t siz #endif action->io.host = host; - action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, ptr, size, nmemb, (surf_file_t)stream); + action->io.surf_io = surf_workstation_model->extension.workstation.write(host->host, storage, ptr, size, nmemb, (surf_file_t)stream); surf_workstation_model->action_data_set(action->io.surf_io, action); XBT_DEBUG("Create io action %p", action); @@ -98,13 +100,14 @@ smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t siz void SIMIX_pre_file_open(smx_simcall_t simcall) { smx_action_t action = SIMIX_file_open(simcall->issuer, + simcall->file_open.storage, simcall->file_open.path, simcall->file_open.mode); xbt_fifo_push(action->simcalls, simcall); simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_open(smx_process_t process, const char* path, const char* mode) +smx_action_t SIMIX_file_open(smx_process_t process ,const char* storage, const char* path, const char* mode) { smx_action_t action; smx_host_t host = process->smx_host; @@ -124,7 +127,7 @@ smx_action_t SIMIX_file_open(smx_process_t process, const char* path, const char #endif action->io.host = host; - action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, path, mode); + action->io.surf_io = surf_workstation_model->extension.workstation.open(host->host, storage, path, mode); surf_workstation_model->action_data_set(action->io.surf_io, action); XBT_DEBUG("Create io action %p", action); @@ -136,12 +139,13 @@ smx_action_t SIMIX_file_open(smx_process_t process, const char* path, const char void SIMIX_pre_file_close(smx_simcall_t simcall) { smx_action_t action = SIMIX_file_close(simcall->issuer, + simcall->file_close.storage, simcall->file_close.fp); xbt_fifo_push(action->simcalls, simcall); simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp) +smx_action_t SIMIX_file_close(smx_process_t process ,const char* storage, smx_file_t fp) { smx_action_t action; smx_host_t host = process->smx_host; @@ -161,7 +165,7 @@ smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp) #endif action->io.host = host; - action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, (surf_file_t)fp); + action->io.surf_io = surf_workstation_model->extension.workstation.close(host->host, storage, (surf_file_t)fp); surf_workstation_model->action_data_set(action->io.surf_io, action); XBT_DEBUG("Create io action %p", action); @@ -173,13 +177,14 @@ smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp) void SIMIX_pre_file_stat(smx_simcall_t simcall) { smx_action_t action = SIMIX_file_stat(simcall->issuer, + simcall->file_stat.storage, simcall->file_stat.fd, simcall->file_stat.buf); xbt_fifo_push(action->simcalls, simcall); simcall->issuer->waiting_action = action; } -smx_action_t SIMIX_file_stat(smx_process_t process, int fd, void* buf) +smx_action_t SIMIX_file_stat(smx_process_t process ,const char* storage, int fd, void* buf) { smx_action_t action; smx_host_t host = process->smx_host; @@ -199,7 +204,7 @@ smx_action_t SIMIX_file_stat(smx_process_t process, int fd, void* buf) #endif action->io.host = host; - action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, fd, buf); + action->io.surf_io = surf_workstation_model->extension.workstation.stat(host->host, storage, fd, buf); surf_workstation_model->action_data_set(action->io.surf_io, action); XBT_DEBUG("Create io action %p", action); diff --git a/src/simix/smx_io_private.h b/src/simix/smx_io_private.h index 821e9cd6df..1c2e59479c 100644 --- a/src/simix/smx_io_private.h +++ b/src/simix/smx_io_private.h @@ -24,11 +24,11 @@ void SIMIX_pre_file_open(smx_simcall_t simcall); void SIMIX_pre_file_close(smx_simcall_t simcall); void SIMIX_pre_file_stat(smx_simcall_t simcall); -smx_action_t SIMIX_file_read(smx_process_t process, void* ptr, size_t size, size_t nmemb, smx_file_t stream); -smx_action_t SIMIX_file_write(smx_process_t process, const void* ptr, size_t size, size_t nmemb, smx_file_t stream); -smx_action_t SIMIX_file_open(smx_process_t process, const char* path, const char* mode); -smx_action_t SIMIX_file_close(smx_process_t process, smx_file_t fp); -smx_action_t SIMIX_file_stat(smx_process_t process, int fd, void* buf); +smx_action_t SIMIX_file_read(smx_process_t process, const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream); +smx_action_t SIMIX_file_write(smx_process_t process, const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream); +smx_action_t SIMIX_file_open(smx_process_t process, const char* storage, const char* path, const char* mode); +smx_action_t SIMIX_file_close(smx_process_t process, const char* storage, smx_file_t fp); +smx_action_t SIMIX_file_stat(smx_process_t process, const char* storage, int fd, void* buf); void SIMIX_post_io(smx_action_t action); void SIMIX_io_destroy(smx_action_t action); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 0a914619b9..07385e95dd 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -508,6 +508,7 @@ typedef struct s_smx_simcall { } sem_get_capacity; struct { + const char* storage; void *ptr; size_t size; size_t nmemb; @@ -516,6 +517,7 @@ typedef struct s_smx_simcall { } file_read; struct { + const char* storage; const void *ptr; size_t size; size_t nmemb; @@ -524,17 +526,20 @@ typedef struct s_smx_simcall { } file_write; struct { + const char* storage; const char* path; const char* mode; smx_file_t result; } file_open; struct { + const char* storage; smx_file_t fp; int result; } file_close; struct { + const char* storage; int fd; //Next should be struct stat* buf void* buf; diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 4acc81d1d4..9d90214e1d 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1177,11 +1177,12 @@ int simcall_sem_get_capacity(smx_sem_t sem) return simcall->sem_get_capacity.result; } -size_t simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream) +size_t simcall_file_read(const char* storage, void* ptr, size_t size, size_t nmemb, smx_file_t stream) { smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_FILE_READ; + simcall->file_read.storage = storage; simcall->file_read.ptr = ptr; simcall->file_read.size = size; simcall->file_read.nmemb = nmemb; @@ -1191,11 +1192,12 @@ size_t simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream return simcall->file_read.result; } -size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream) +size_t simcall_file_write(const char* storage, const void* ptr, size_t size, size_t nmemb, smx_file_t stream) { smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_FILE_WRITE; + simcall->file_write.storage = storage; simcall->file_write.ptr = ptr; simcall->file_write.size = size; simcall->file_write.nmemb = nmemb; @@ -1205,11 +1207,12 @@ size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t return simcall->file_write.result; } -smx_file_t simcall_file_open(const char* path, const char* mode) +smx_file_t simcall_file_open(const char* storage, const char* path, const char* mode) { smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_FILE_OPEN; + simcall->file_open.storage = storage; simcall->file_open.path = path; simcall->file_open.mode = mode; SIMIX_simcall_push(simcall->issuer); @@ -1217,22 +1220,24 @@ smx_file_t simcall_file_open(const char* path, const char* mode) return simcall->file_open.result; } -int simcall_file_close(smx_file_t fp) +int simcall_file_close(const char* storage, smx_file_t fp) { smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_FILE_CLOSE; + simcall->file_close.storage = storage; simcall->file_close.fp = fp; SIMIX_simcall_push(simcall->issuer); return simcall->file_close.result; } -int simcall_file_stat(int fd, void* buf) +int simcall_file_stat(const char* storage, int fd, void* buf) { smx_simcall_t simcall = SIMIX_simcall_mine(); simcall->call = SIMCALL_FILE_STAT; + simcall->file_stat.storage = storage; simcall->file_stat.fd = fd; simcall->file_stat.buf = buf; SIMIX_simcall_push(simcall->issuer); -- 2.20.1