* Action *
**********/
StorageAction::StorageAction(ModelPtr model, double cost, bool failed,
- StoragePtr storage, e_surf_action_storage_type_t type)
+ StoragePtr storage, e_surf_action_storage_type_t type)
: Action(model, cost, failed)
-, m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL)
-{
+, m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL){
+ progress = 0;
};
StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var,
- StoragePtr storage, e_surf_action_storage_type_t type)
+ StoragePtr storage, e_surf_action_storage_type_t type)
: Action(model, cost, failed, var)
, m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL) {
+ progress = 0;
}
void StorageAction::setState(e_surf_action_state_t state){
#include "storage_n11.hpp"
#include "surf_private.h"
-
+#include <math.h> /*ceil*/
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_storage);
static int storage_selective_update = 0;
; it != itend ; it=itNext) {
++itNext;
action = static_cast<StorageActionPtr>(&*it);
+
if(action->m_type == WRITE)
{
// Update the disk usage
- // Update the file size
- // For each action of type write
- double rate = lmm_variable_getvalue(action->getVariable());
- /* 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 + 0.00001; // Use legacy value. I don't know what this hack can be... FIXME: Pierre, please check.
+ // Update the file size
+ // For each action of type write
+ double current_progress =
+ delta * lmm_variable_getvalue(action->getVariable());
+ long int incr = current_progress;
+
+ XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, "
+ "incr = %ld, lrint(1) = %ld, lrint(2) = %ld",
+ action->p_file->name,
+ action->progress, current_progress, incr,
+ lrint(action->progress + current_progress),
+ lrint(action->progress)+ incr);
+
+ /* Take care of rounding error accumulation */
+ if (lrint(action->progress + current_progress) >
+ lrint(action->progress)+ incr)
+ incr++;
+
+ action->progress +=current_progress;
+
action->p_storage->m_usedSize += incr; // disk usage
- action->p_file->size += incr; // file size
+ action->p_file->current_position+= incr; // current_position
+ // which becomes the new file size
+ action->p_file->size = action->p_file->current_position ;
sg_size_t *psize = xbt_new(sg_size_t,1);
*psize = action->p_file->size;
if(psize)
size = *psize;
else {
- psize = xbt_new(sg_size_t,1);
+ psize = xbt_new(sg_size_t,1);
size = 0;
*psize = size;
xbt_dict_set(p_content, path, psize, NULL);
StorageActionPtr action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, WRITE);
action->p_file = fd;
- fd->current_position += size;
- // If the storage is full
+ /* Substract the part of the file that might disappear from the used sized on
+ * the storage element */
+ m_usedSize -= (fd->size - fd->current_position);
+ // If the storage is full before even starting to write
if(m_usedSize==m_size) {
action->setState(SURF_ACTION_FAILED);
}
break;
case READ:
lmm_expand(model->getMaxminSystem(), storage->p_constraintRead,
- getVariable(), 1.0);
+ getVariable(), 1.0);
break;
case WRITE:
lmm_expand(model->getMaxminSystem(), storage->p_constraintWrite,
- getVariable(), 1.0);
+ getVariable(), 1.0);
ActionPtr action = this;
xbt_dynar_push(storage->p_writeActions, &action);
ref();