free(stype->model);
free(stype->type_id);
free(stype->content);
+ free(stype->content_type);
xbt_dict_free(&(stype->properties));
xbt_dict_free(&(stype->properties));
free(stype);
/* Hack to avoid rounding differences between x86 and x86_64
* (note that the next sizes are of type sg_size_t). */
long incr = delta * rate + MAXMIN_PRECISION;
- action->p_storage->m_usedSize += incr; // disk usage
- action->p_file->size += incr; // file size
+ action->p_storage->m_usedSize += (incr - action->p_file->size); // disk usage
+ action->p_file->size = incr; // file size
sg_size_t *psize = xbt_new(sg_size_t,1);
*psize = action->p_file->size;
StorageLmm::StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
- const char* type_id, char *content_name, char *content_type, size_t size)
+ const char* type_id, char *content_name, char *content_type, sg_size_t size)
: Resource(model, name, properties), ResourceLmm(), Storage(model, name, properties) {
- XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%lu'", bconnection, bread, bwrite, ((unsigned long)size));
+ XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
p_stateCurrent = SURF_RESOURCE_ON;
m_usedSize = 0;
file->name = xbt_strdup(path);
file->size = size;
file->mount = xbt_strdup(mount);
+ file->current_position = 0;
StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
action->p_file = file;
StorageActionPtr StorageLmm::read(surf_file_t fd, sg_size_t size)
{
- if(size > fd->size)
+ if(size > fd->size){
size = fd->size;
+ fd->current_position = fd->size;
+ }
+ else
+ fd->current_position += size;
+
StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
return action;
}
StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
action->p_file = fd;
-
+ fd->current_position += size;
// If the storage is full
if(m_usedSize==m_size) {
action->setState(SURF_ACTION_FAILED);