Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
961409f0e3e9cb3849aead7501ea3cab162bcd32
[simgrid.git] / src / surf / storage.cpp
1 #include "storage.hpp"
2 #include "surf_private.h"
3
4 #define __STDC_FORMAT_MACROS
5
6 extern "C" {
7 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf,
8                                 "Logging specific to the SURF storage module");
9 }
10
11 xbt_lib_t storage_lib;
12 int ROUTING_STORAGE_LEVEL;      //Routing for storagelevel
13 int ROUTING_STORAGE_HOST_LEVEL;
14 int SURF_STORAGE_LEVEL;
15 xbt_lib_t storage_type_lib;
16 int ROUTING_STORAGE_TYPE_LEVEL; //Routing for storage_type level
17
18 static xbt_dynar_t storage_list;
19
20 xbt_dynar_t mount_list = NULL;  /* temporary store of current mount storage */
21 StorageModelPtr surf_storage_model = NULL;
22
23 static int storage_selective_update = 0;
24 static xbt_swag_t storage_running_action_set_that_does_not_need_being_checked = NULL;
25
26 /*************
27  * CallBacks *
28  *************/
29
30 static XBT_INLINE void routing_storage_type_free(void *r)
31 {
32   storage_type_t stype = (storage_type_t) r;
33   free(stype->model);
34   free(stype->type_id);
35   free(stype->content);
36   free(stype->content_type);
37   xbt_dict_free(&(stype->properties));
38   xbt_dict_free(&(stype->properties));
39   free(stype);
40 }
41
42 static XBT_INLINE void surf_storage_resource_free(void *r)
43 {
44   // specific to storage
45   StoragePtr storage = dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(r));
46   xbt_dict_free(&storage->p_content);
47   xbt_dynar_free(&storage->p_writeActions);
48   free(storage->p_typeId);
49   free(storage->p_contentType);
50   // generic resource
51   delete storage;
52 }
53
54 static XBT_INLINE void routing_storage_host_free(void *r)
55 {
56   xbt_dynar_t dyn = (xbt_dynar_t) r;
57   xbt_dynar_free(&dyn);
58 }
59
60 static void parse_storage_init(sg_platf_storage_cbarg_t storage)
61 {
62   void* stype = xbt_lib_get_or_null(storage_type_lib,
63                                     storage->type_id,
64                                     ROUTING_STORAGE_TYPE_LEVEL);
65   if(!stype) xbt_die("No storage type '%s'",storage->type_id);
66
67   // if storage content is not specified use the content of storage_type if exist
68   if(!strcmp(storage->content,"") && strcmp(((storage_type_t) stype)->content,"")){
69     storage->content = ((storage_type_t) stype)->content;
70     storage->content_type = ((storage_type_t) stype)->content_type;
71     XBT_DEBUG("For disk '%s' content is empty, inherit the content (of type %s) from storage type '%s' ",
72         storage->id,((storage_type_t) stype)->content_type,
73         ((storage_type_t) stype)->type_id);
74   }
75
76   XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' "
77       "\n\t\tmodel '%s' \n\t\tcontent '%s'\n\t\tcontent_type '%s' "
78       "\n\t\tproperties '%p'\n",
79       storage->id,
80       ((storage_type_t) stype)->model,
81       ((storage_type_t) stype)->type_id,
82       storage->content,
83       storage->content_type,
84       ((storage_type_t) stype)->properties);
85
86   surf_storage_model->createResource(storage->id, ((storage_type_t) stype)->model,
87                                      ((storage_type_t) stype)->type_id,
88                                      storage->content,
89                                      storage->content_type,
90                                      storage->properties);
91 }
92
93 static void parse_mstorage_init(sg_platf_mstorage_cbarg_t /*mstorage*/)
94 {
95   XBT_DEBUG("parse_mstorage_init");
96 }
97
98 static void parse_storage_type_init(sg_platf_storage_type_cbarg_t /*storagetype_*/)
99 {
100   XBT_DEBUG("parse_storage_type_init");
101 }
102
103 static void parse_mount_init(sg_platf_mount_cbarg_t /*mount*/)
104 {
105   XBT_DEBUG("parse_mount_init");
106 }
107
108 static void storage_parse_storage(sg_platf_storage_cbarg_t storage)
109 {
110   xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL),
111                "Reading a storage, processing unit \"%s\" already exists", storage->id);
112
113   // Verification of an existing type_id
114 #ifndef NDEBUG
115   void* storage_type = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL);
116 #endif
117   xbt_assert(storage_type,"Reading a storage, type id \"%s\" does not exists", storage->type_id);
118
119   XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'",
120       storage->id,
121       storage->type_id,
122       storage->content);
123
124   xbt_lib_set(storage_lib,
125       storage->id,
126       ROUTING_STORAGE_LEVEL,
127       (void *) xbt_strdup(storage->type_id));
128 }
129
130 static void storage_parse_storage_type(sg_platf_storage_type_cbarg_t storage_type)
131 {
132   xbt_assert(!xbt_lib_get_or_null(storage_type_lib, storage_type->id,ROUTING_STORAGE_TYPE_LEVEL),
133                "Reading a storage type, processing unit \"%s\" already exists", storage_type->id);
134
135   storage_type_t stype = xbt_new0(s_storage_type_t, 1);
136   stype->model = xbt_strdup(storage_type->model);
137   stype->properties = storage_type->properties;
138   stype->content = xbt_strdup(storage_type->content);
139   stype->content_type = xbt_strdup(storage_type->content_type);
140   stype->type_id = xbt_strdup(storage_type->id);
141   stype->size = storage_type->size;
142
143   XBT_DEBUG("ROUTING Create a storage type id '%s' with model '%s', "
144       "content '%s', and content_type '%s'",
145       stype->type_id,
146       stype->model,
147       storage_type->content,
148       storage_type->content_type);
149
150   xbt_lib_set(storage_type_lib,
151       stype->type_id,
152       ROUTING_STORAGE_TYPE_LEVEL,
153       (void *) stype);
154 }
155 static void storage_parse_mstorage(sg_platf_mstorage_cbarg_t /*mstorage*/)
156 {
157   THROW_UNIMPLEMENTED;
158 //  mount_t mnt = xbt_new0(s_mount_t, 1);
159 //  mnt->id = xbt_strdup(mstorage->type_id);
160 //  mnt->name = xbt_strdup(mstorage->name);
161 //
162 //  if(!mount_list){
163 //    XBT_DEBUG("Creata a Mount list for %s",A_surfxml_host_id);
164 //    mount_list = xbt_dynar_new(sizeof(char *), NULL);
165 //  }
166 //  xbt_dynar_push(mount_list,(void *) mnt);
167 //  free(mnt->id);
168 //  free(mnt->name);
169 //  xbt_free(mnt);
170 //  XBT_DEBUG("ROUTING Mount a storage name '%s' with type_id '%s'",mstorage->name, mstorage->id);
171 }
172
173 static void mount_free(void *p)
174 {
175   mount_t mnt = (mount_t) p;
176   xbt_free(mnt->name);
177 }
178
179 static void storage_parse_mount(sg_platf_mount_cbarg_t mount)
180 {
181   // Verification of an existing storage
182 #ifndef NDEBUG
183   void* storage = xbt_lib_get_or_null(storage_lib, mount->storageId, ROUTING_STORAGE_LEVEL);
184 #endif
185   xbt_assert(storage,"Disk id \"%s\" does not exists", mount->storageId);
186
187   XBT_DEBUG("ROUTING Mount '%s' on '%s'",mount->storageId, mount->name);
188
189   s_mount_t mnt;
190   mnt.storage = surf_storage_resource_priv(surf_storage_resource_by_name(mount->storageId));
191   mnt.name = xbt_strdup(mount->name);
192
193   if(!mount_list){
194     XBT_DEBUG("Create a Mount list for %s",A_surfxml_host_id);
195     mount_list = xbt_dynar_new(sizeof(s_mount_t), mount_free);
196   }
197   xbt_dynar_push(mount_list,&mnt);
198 }
199
200 static void storage_define_callbacks()
201 {
202   sg_platf_storage_add_cb(parse_storage_init);
203   sg_platf_storage_type_add_cb(parse_storage_type_init);
204   sg_platf_mstorage_add_cb(parse_mstorage_init);
205   sg_platf_mount_add_cb(parse_mount_init);
206 }
207
208 void storage_register_callbacks() {
209
210   ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free);
211   ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib, routing_storage_host_free);
212   ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib, routing_storage_type_free);
213   SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, surf_storage_resource_free);
214
215   sg_platf_storage_add_cb(storage_parse_storage);
216   sg_platf_mstorage_add_cb(storage_parse_mstorage);
217   sg_platf_storage_type_add_cb(storage_parse_storage_type);
218   sg_platf_mount_add_cb(storage_parse_mount);
219 }
220
221 /*********
222  * Model *
223  *********/
224
225 void surf_storage_model_init_default(void)
226 {
227   surf_storage_model = new StorageModel();
228   storage_define_callbacks();
229   xbt_dynar_push(model_list, &surf_storage_model);
230 }
231
232 StorageModel::StorageModel() : Model("Storage") {
233   StorageActionLmm action;
234
235   XBT_DEBUG("surf_storage_model_init_internal");
236
237   storage_running_action_set_that_does_not_need_being_checked =
238       xbt_swag_new(xbt_swag_offset(action, p_stateHookup));
239
240   if (!p_maxminSystem) {
241     p_maxminSystem = lmm_system_new(storage_selective_update);
242   }
243 }
244
245
246 StorageModel::~StorageModel(){
247   lmm_system_free(p_maxminSystem);
248
249   surf_storage_model = NULL;
250
251   xbt_dynar_free(&storage_list);
252
253   xbt_swag_free(storage_running_action_set_that_does_not_need_being_checked);
254   storage_running_action_set_that_does_not_need_being_checked = NULL;
255 }
256
257 StoragePtr StorageModel::createResource(const char* id, const char* model, const char* type_id,
258                 const char* content_name, const char* content_type, xbt_dict_t properties)
259 {
260
261   xbt_assert(!surf_storage_resource_priv(surf_storage_resource_by_name(id)),
262               "Storage '%s' declared several times in the platform file",
263               id);
264
265   storage_type_t storage_type = (storage_type_t) xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);
266
267   double Bread  = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->properties, "Bread"));
268   double Bwrite = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->properties, "Bwrite"));
269   double Bconnection   = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->properties, "Bconnection"));
270
271   StoragePtr storage = new StorageLmm(this, id, properties, p_maxminSystem,
272                   Bread, Bwrite, Bconnection,
273                   type_id, (char *)content_name, xbt_strdup(content_type), storage_type->size);
274
275   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, static_cast<ResourcePtr>(storage));
276
277   XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s' \n\t\tmodel '%s' \n\t\tproperties '%p'\n\t\tBread '%f'\n",
278       id,
279       model,
280       type_id,
281       storage_type->properties,
282       Bread);
283
284   if(!storage_list)
285         storage_list = xbt_dynar_new(sizeof(char *),NULL);
286   xbt_dynar_push(storage_list, &storage);
287
288   return storage;
289 }
290
291 double StorageModel::shareResources(double now)
292 {
293   XBT_DEBUG("storage_share_resources %f", now);
294   unsigned int i, j;
295   StoragePtr storage;
296   void *_write_action;
297   StorageActionLmmPtr write_action;
298
299   double min_completion = shareResourcesMaxMin(p_runningActionSet,
300       p_maxminSystem, lmm_solve);
301
302   double rate;
303   // Foreach disk
304   xbt_dynar_foreach(storage_list,i,storage)
305   {
306     rate = 0;
307     // Foreach write action on disk
308     xbt_dynar_foreach(storage->p_writeActions, j, _write_action)
309     {
310       write_action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_write_action));
311       rate += lmm_variable_getvalue(write_action->p_variable);
312     }
313     if(rate > 0)
314       min_completion = MIN(min_completion, (storage->m_size-storage->m_usedSize)/rate);
315   }
316
317   return min_completion;
318 }
319
320 void StorageModel::updateActionsState(double /*now*/, double delta)
321 {
322   void *_action, *_next_action;
323   StorageActionLmmPtr action = NULL;
324
325   xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
326         action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_action));
327     if(action->m_type == WRITE)
328     {
329       // Update the disk usage
330      // Update the file size
331      // For each action of type write
332       double rate = lmm_variable_getvalue(action->p_variable);
333       /* Hack to avoid rounding differences between x86 and x86_64
334        * (note that the next sizes are of type sg_size_t). */
335       long incr = delta * rate + MAXMIN_PRECISION;
336       action->p_storage->m_usedSize += incr; // disk usage
337       action->p_file->size += incr; // file size
338
339       sg_size_t *psize = xbt_new(sg_size_t,1);
340       *psize = action->p_file->size;
341
342       xbt_dict_t content_dict = action->p_storage->p_content;
343       xbt_dict_set(content_dict, action->p_file->name, psize, NULL);
344     }
345
346     double_update(&action->m_remains,
347                   lmm_variable_getvalue(action->p_variable) * delta);
348
349     if (action->m_maxDuration != NO_MAX_DURATION)
350       double_update(&action->m_maxDuration, delta);
351
352     if(action->m_remains > 0 &&
353         lmm_get_variable_weight(action->p_variable) > 0 &&
354         action->p_storage->m_usedSize == action->p_storage->m_size)
355     {
356       action->m_finish = surf_get_clock();
357       action->setState(SURF_ACTION_FAILED);
358     } else if ((action->m_remains <= 0) &&
359         (lmm_get_variable_weight(action->p_variable) > 0))
360     {
361       action->m_finish = surf_get_clock();
362       action->setState(SURF_ACTION_DONE);
363     } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
364                (action->m_maxDuration <= 0))
365     {
366       action->m_finish = surf_get_clock();
367       action->setState(SURF_ACTION_DONE);
368     }
369   }
370
371   return;
372 }
373
374 xbt_dict_t Storage::parseContent(char *filename)
375 {
376   m_usedSize = 0;
377   if ((!filename) || (strcmp(filename, "") == 0))
378     return NULL;
379
380   xbt_dict_t parse_content = xbt_dict_new_homogeneous(xbt_free);
381   FILE *file = NULL;
382
383   file = surf_fopen(filename, "r");
384   xbt_assert(file != NULL, "Cannot open file '%s' (path=%s)", filename,
385               xbt_str_join(surf_path, ":"));
386
387   char *line = NULL;
388   size_t len = 0;
389   ssize_t read;
390   char path[1024];
391   sg_size_t size;
392
393
394   while ((read = xbt_getline(&line, &len, file)) != -1) {
395     if (read){
396     if(sscanf(line,"%s %llu", path, &size) == 2) {
397         m_usedSize += size;
398         sg_size_t *psize = xbt_new(sg_size_t, 1);
399         *psize = size;
400         xbt_dict_set(parse_content,path,psize,NULL);
401       } else {
402         xbt_die("Be sure of passing a good format for content file.\n");
403       }
404     }
405   }
406   free(line);
407   fclose(file);
408   return parse_content;
409 }
410
411 /************
412  * Resource *
413  ************/
414
415 Storage::Storage(StorageModelPtr model, const char* name, xbt_dict_t properties)
416 :  Resource(model, name, properties)
417 {
418   p_writeActions = xbt_dynar_new(sizeof(ActionPtr),NULL);
419 }
420
421 StorageLmm::StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
422              lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
423              const char* type_id, char *content_name, char *content_type, sg_size_t size)
424  :  Resource(model, name, properties), ResourceLmm(), Storage(model, name, properties) {
425   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
426
427   p_stateCurrent = SURF_RESOURCE_ON;
428   m_usedSize = 0;
429   m_size = 0;
430
431   p_content = parseContent(content_name);
432   p_contentType = content_type;
433   p_constraint = lmm_constraint_new(maxminSystem, this, bconnection);
434   p_constraintRead  = lmm_constraint_new(maxminSystem, this, bread);
435   p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
436   m_size = size;
437   p_typeId = xbt_strdup(type_id);
438 }
439
440 bool Storage::isUsed()
441 {
442   THROW_UNIMPLEMENTED;
443   return false;
444 }
445
446 void Storage::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/)
447 {
448   THROW_UNIMPLEMENTED;
449 }
450
451 StorageActionPtr StorageLmm::ls(const char* path)
452 {
453   StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, LS);
454
455   action->p_lsDict = NULL;
456   xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
457
458   char* key;
459   sg_size_t size = 0;
460   xbt_dict_cursor_t cursor = NULL;
461
462   xbt_dynar_t dyn = NULL;
463   char* file = NULL;
464
465   // for each file in the storage content
466   xbt_dict_foreach(p_content,cursor,key,size){
467     // Search if file start with the prefix 'path'
468     if(xbt_str_start_with(key,path)){
469       file = &key[strlen(path)];
470
471       // Split file with '/'
472       dyn = xbt_str_split(file,"/");
473       file = xbt_dynar_get_as(dyn,0,char*);
474
475       // file
476       if(xbt_dynar_length(dyn) == 1){
477         sg_size_t *psize = xbt_new(sg_size_t, 1);
478         *psize=size;
479         xbt_dict_set(ls_dict, file, psize, NULL);
480       }
481       // Directory
482       else
483       {
484         // if directory does not exist yet in the dictionary
485         if(!xbt_dict_get_or_null(ls_dict,file))
486           xbt_dict_set(ls_dict,file,NULL,NULL);
487       }
488       xbt_dynar_free(&dyn);
489     }
490   }
491
492   action->p_lsDict = ls_dict;
493   return action;
494 }
495
496 StorageActionPtr StorageLmm::open(const char* mount, const char* path)
497 {
498   XBT_DEBUG("\tOpen file '%s'",path);
499   sg_size_t size, *psize;
500   psize = (sg_size_t*) xbt_dict_get_or_null(p_content, path);
501   // if file does not exist create an empty file
502   if(psize)
503     size = *psize;
504   else {
505         psize = xbt_new(sg_size_t,1);
506     size = 0;
507     *psize = size;
508     xbt_dict_set(p_content, path, psize, NULL);
509     XBT_DEBUG("File '%s' was not found, file created.",path);
510   }
511   surf_file_t file = xbt_new0(s_surf_file_t,1);
512   file->name = xbt_strdup(path);
513   file->size = size;
514   file->mount = xbt_strdup(mount);
515
516   StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
517   action->p_file = file;
518   return action;
519 }
520
521 StorageActionPtr StorageLmm::close(surf_file_t fd)
522 {
523   char *filename = fd->name;
524   XBT_DEBUG("\tClose file '%s' size '%llu'", filename, fd->size);
525   // unref write actions from storage
526   void *_write_action;
527   StorageActionLmmPtr write_action;
528   unsigned int i;
529   xbt_dynar_foreach(p_writeActions, i, _write_action) {
530         write_action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_write_action));
531     if ((write_action->p_file) == fd) {
532       xbt_dynar_cursor_rm(p_writeActions, &i);
533       write_action->unref();
534     }
535   }
536   free(fd->name);
537   free(fd->mount);
538   xbt_free(fd);
539   StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
540   return action;
541 }
542
543 StorageActionPtr StorageLmm::read(surf_file_t fd, sg_size_t size)
544 {
545   if(size > fd->size)
546     size = fd->size;
547   StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
548   return action;
549 }
550
551 StorageActionPtr StorageLmm::write(surf_file_t fd, sg_size_t size)
552 {
553   char *filename = fd->name;
554   XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
555
556   StorageActionLmmPtr action = new StorageActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
557   action->p_file = fd;
558
559   // If the storage is full
560   if(m_usedSize==m_size) {
561     action->setState(SURF_ACTION_FAILED);
562   }
563   return action;
564 }
565
566 void StorageLmm::rename(const char *src, const char *dest)
567 {
568   sg_size_t *psize, *new_psize;
569   psize = (sg_size_t*) xbt_dict_get_or_null(p_content,src);
570   new_psize = xbt_new(sg_size_t, 1);
571   *new_psize = *psize;
572   if (psize){// src file exists
573     xbt_dict_remove(p_content, src);
574     xbt_dict_set(p_content, dest, new_psize,NULL);
575     XBT_DEBUG("Change file name from %s to %s, size '%llu'",src, dest, *psize);
576   }
577   else
578     XBT_DEBUG("File %s doesn't exist",src);
579 }
580
581 xbt_dict_t StorageLmm::getContent()
582 {
583   /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
584   /*surf_action_t action = storage_action_execute(storage,0, LS);*/
585
586   xbt_dict_t content_dict = xbt_dict_new_homogeneous(NULL);
587   xbt_dict_cursor_t cursor = NULL;
588   char *file;
589   sg_size_t *psize;
590
591   xbt_dict_foreach(p_content, cursor, file, psize){
592     xbt_dict_set(content_dict,file,psize,NULL);
593   }
594   return content_dict;
595 }
596
597 sg_size_t StorageLmm::getSize(){
598   return m_size;
599 }
600
601 /**********
602  * Action *
603  **********/
604
605 StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
606   : Action(model, cost, failed),
607     ActionLmm(model, cost, failed),
608     StorageAction(model, cost, failed, storage, type) {
609   XBT_IN("(%s,%g", storage->m_name, cost);
610   p_variable = lmm_variable_new(p_model->p_maxminSystem, this, 1.0, -1.0 , 3);
611
612   // Must be less than the max bandwidth for all actions
613   lmm_expand(p_model->p_maxminSystem, storage->p_constraint, p_variable, 1.0);
614   switch(type) {
615   case OPEN:
616   case CLOSE:
617   case STAT:
618   case LS:
619     break;
620   case READ:
621     lmm_expand(p_model->p_maxminSystem, storage->p_constraintRead,
622                p_variable, 1.0);
623     break;
624   case WRITE:
625     lmm_expand(p_model->p_maxminSystem, storage->p_constraintWrite,
626                p_variable, 1.0);
627     ActionPtr action = this;
628     xbt_dynar_push(storage->p_writeActions, &action);
629     ref();
630     break;
631   }
632   XBT_OUT();
633 }
634
635 int StorageActionLmm::unref()
636 {
637   m_refcount--;
638   if (!m_refcount) {
639     xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
640     if (p_variable)
641       lmm_variable_free(p_model->p_maxminSystem, p_variable);
642 #ifdef HAVE_TRACING
643     xbt_free(p_category);
644 #endif
645     delete this;
646     return 1;
647   }
648   return 0;
649 }
650
651 void StorageActionLmm::cancel()
652 {
653   setState(SURF_ACTION_FAILED);
654   return;
655 }
656
657 void StorageActionLmm::suspend()
658 {
659   XBT_IN("(%p)", this);
660   if (m_suspended != 2) {
661     lmm_update_variable_weight(p_model->p_maxminSystem,
662                                p_variable,
663                                0.0);
664     m_suspended = 1;
665   }
666   XBT_OUT();
667 }
668
669 void StorageActionLmm::resume()
670 {
671   THROW_UNIMPLEMENTED;
672 }
673
674 bool StorageActionLmm::isSuspended()
675 {
676   return m_suspended == 1;
677 }
678
679 void StorageActionLmm::setMaxDuration(double /*duration*/)
680 {
681   THROW_UNIMPLEMENTED;
682 }
683
684 void StorageActionLmm::setPriority(double /*priority*/)
685 {
686   THROW_UNIMPLEMENTED;
687 }
688