Ejemplo n.º 1
0
void simpledisk_initialize (void)
{
   int i;

   if (disksim->simplediskinfo == NULL) {
      simpledisk_initialize_diskinfo ();
   }
/*
fprintf (outputfile, "Entered simpledisk_initialize - numsimpledisks %d\n", numsimpledisks);
*/
   simpledisk_setcallbacks();
   simpledisk_postpass();

   for (i=0; i<MAXDEVICES; i++) {
      simpledisk_t *currdisk = getsimpledisk (i);
      if(!currdisk) continue;
/*        if (!currdisk->inited) { */
         currdisk->media_busy = FALSE;
         currdisk->reconnect_reason = -1;
         addlisttoextraq ((event **) &currdisk->buswait);
         currdisk->busowned = -1;
         ioqueue_initialize (currdisk->queue, i);
         simpledisk_statinit(i, TRUE);
/*        } */
   }
}
Ejemplo n.º 2
0
void controller_smart_initialize (controller *currctlr)
{
   int numdevs = device_get_numdevices();
   device *currdev;
   int i;

   controller_smart_setcallbacks ();
   currctlr->numdevices = numdevs;
   currctlr->devices = (device *) DISKSIM_malloc(numdevs * sizeof(device));
   ASSERT(currctlr->devices != NULL);
   for (i=0; i<numdevs; i++) {
      currdev = &currctlr->devices[i];
      currdev->devno = i;
      currdev->busy = FALSE;
      currdev->flag = 0;
      currdev->queue = ioqueue_copy(currctlr->queue);
      ioqueue_initialize(currdev->queue, i);
      iosim_get_path_to_device (0, i, &currdev->buspath, &currdev->slotpath);
      currdev->maxoutstanding = currctlr->maxdiskqsize;
   }
   currctlr->cache->cache_initialize(currctlr->cache, &disksim->issuefunc_ctlrsmart, currctlr, &disksim->queuefind_ctlrsmart, currctlr, &disksim->wakeupfunc_ctlrsmart, currctlr, numdevs);
}
Ejemplo n.º 3
0
void iodriver_initialize (int standalone)
{
   int numdevs;
   struct ioq * queueset[MAXDEVICES];
   int i, j;
   iodriver *curriodriver;

   i = numiodrivers;

      /* Code will be broken by multiple iodrivers */
   ASSERT1(numiodrivers == 1, "numiodrivers", numiodrivers);

   ioqueue_initialize (OVERALLQUEUE, 0);

   for (i = 0; i < numiodrivers; i++) {
      curriodriver = iodrivers[i];
      curriodriver->type = standalone;
      if (standalone != STANDALONE) {
         curriodriver->scale = 1.0;
      }
      numdevs = controller_get_numcontrollers();
      curriodriver->numctlrs = numdevs;
      curriodriver->ctlrs = (ctlr*) DISKSIM_malloc(numdevs * (sizeof(ctlr)));
      ASSERT(curriodriver->ctlrs != NULL);
      for (j=0; j < numdevs; j++) {
         ctlr *currctlr = &curriodriver->ctlrs[j];
         currctlr->ctlno = j;
         currctlr->flags = 0;
         if (controller_C700_based(j) == TRUE) {
/*
fprintf (outputfile, "This one is c700_based - %d\n", j);
*/
            currctlr->flags |= DRIVER_C700;
         }
         currctlr->buspath.value = 0;
         currctlr->slotpath.value = 0;
         iosim_get_path_to_controller(i, currctlr->ctlno, &currctlr->buspath, &currctlr->slotpath);
         currctlr->numoutstanding = 0;
         currctlr->pendio = NULL;
         currctlr->oversized = NULL;
      }

      numdevs = device_get_numdevices();
      curriodriver->numdevices = numdevs;
      curriodriver->devices = (device*) DISKSIM_malloc(numdevs * (sizeof(device)));
      ASSERT(curriodriver->devices != NULL);
      for (j = 0; j < numdevs; j++) {
         device *currdev = &curriodriver->devices[j];
         currdev->devno = j;
         currdev->busy = FALSE;
         currdev->flag = 0;
         currdev->queue = ioqueue_copy(curriodriver->queue);
         ioqueue_initialize(currdev->queue, j);
         queueset[j] = currdev->queue;
         currdev->buspath.value = 0;
         currdev->slotpath.value = 0;
         iosim_get_path_to_device(i, currdev->devno, &currdev->buspath, &currdev->slotpath);
         iodriver_set_ctl_to_device(i, currdev);
         get_device_maxoutstanding(curriodriver, currdev);
      }
      logorg_initialize(sysorgs, numsysorgs, queueset,
			drv_printlocalitystats, 
			drv_printblockingstats, 
			drv_printinterferestats, 
			drv_printstreakstats, 
			drv_printstampstats, 
			drv_printintarrstats, 
			drv_printidlestats, 
			drv_printsizestats);
/*
fprintf (outputfile, "Back from logorg_initialize\n");
*/
   }
   stat_initialize(statdeffile, statdesc_emptyqueue, &emptyqueuestats);
   stat_initialize(statdeffile, statdesc_initiatenext, &initiatenextstats);

#if 0
   print_paths_to_devices();
   print_paths_to_ctlrs();
#endif

}
Ejemplo n.º 4
0
void ssd_initialize (void)
{
   int i, j;

   if (disksim->ssdinfo == NULL) {
      ssd_initialize_diskinfo ();
   }
   initialize_device_physical_parameters(); //Initliaze the physical parameters of the device.
   ssd_setcallbacks();

   // fprintf(stdout, "MAXDEVICES = %d, numssds %d\n", MAXDEVICES, numssds);
   // vp - changing the MAXDEVICES in the below 'for' loop to numssds
   for (i=0; i<numssds; i++) {
      int exp_size;
      ssd_t *currdisk = getssd (i);
      if (!currdisk) continue;

      ssd_alloc_queues(currdisk); //also allocates the refresh queue
      currdisk->params.refresh_interval*=1000; //in ms.
      currdisk->next_refresh_time = currdisk->params.refresh_interval;
      currdisk->params.refresh_service_time = currdisk->params.block_erase_latency + 
                                      ( (currdisk->params.page_write_latency + 
                                        currdisk->params.page_read_latency) * 
                                      currdisk->params.pages_per_block);
      if (currdisk->params.checkpoint_time == 0)
        currdisk->params.checkpoint_time = 0.5;

      currdisk->params.checkpoint_time *= (60* 60 *1000);//hours to milli seconds.
      //vp - some verifications:
      ssd_verify_parameters(currdisk);

      //vp - this was not initialized and caused so many bugs
      currdisk->devno = i;


       currdisk->numblocks = currdisk->params.nelements *
                 currdisk->params.blocks_per_element *
                 currdisk->params.pages_per_block *
                 currdisk->params.page_size;
       currdisk->reconnect_reason = -1;
       addlisttoextraq ((event **) &currdisk->buswait);
       currdisk->busowned = -1;
       currdisk->completion_queue = NULL;
       /* hack to init queue structure */
       ioqueue_initialize (currdisk->queue, i);
       ssd_statinit(i, TRUE);
       currdisk->timing_t = ssd_new_timing_t(&currdisk->params);

       // initialize the gang
       exp_size = ssd_elem_export_size(currdisk);
       for (j = 0; j < SSD_NUM_GANG(currdisk); j ++) {
           int tot_pages = exp_size * currdisk->params.elements_per_gang;
           currdisk->gang_meta[j].busy = 0;
           currdisk->gang_meta[j].cleaning = 0;
           currdisk->gang_meta[j].reqs_waiting = 0;
           currdisk->gang_meta[j].oldest = 0;
           currdisk->gang_meta[j].pg2elem = (ssd_elem_number*)malloc(sizeof(ssd_elem_number) * tot_pages);
           memset(currdisk->gang_meta[j].pg2elem, 0, sizeof(ssd_elem_number) * tot_pages);

           ioqueue_initialize (currdisk->gang_meta[j].queue, i);
       }

       for (j=0; j<currdisk->params.nelements; j++) {
           ssd_element *elem = &currdisk->elements[j];
           ioqueue_initialize (elem->queue, i);

           /* hack to init queue structure */
           elem->media_busy = FALSE;

           // vp - pins are also free
           elem->pin_busy = FALSE;

           // vp - initialize the planes in the element
           ssd_plane_init(elem, currdisk, i);

          // vp - initialize the ssd element metadata
          // FIXME: where to free these data?
          if (currdisk->params.write_policy == DISKSIM_SSD_WRITE_POLICY_OSR) {
              ssd_element_metadata_init(j, &(elem->metadata), currdisk);
          }

          //vp - initialize the stat structure
          memset(&elem->stat, 0, sizeof(ssd_element_stat));

       }
   }
  fprintf(stderr,"Finished loading state from snapshot\n");
}
Ejemplo n.º 5
0
void ssd_initialize (void)
{
//    static print1 = 1;
   int i, j;

   if (disksim->ssdinfo == NULL) {
      ssd_initialize_diskinfo ();
   }
/*
fprintf (outputfile, "Entered ssd_initialize - numssds %d\n", numssds);
*/
   ssd_setcallbacks();

   // fprintf(stdout, "MAXDEVICES = %d, numssds %d\n", MAXDEVICES, numssds);
   // vp - changing the MAXDEVICES in the below 'for' loop to numssds
   for (i=0; i<numssds; i++) {
       int exp_size;
      ssd_t *currdisk = getssd (i);
      ssd_alloc_queues(currdisk);

      //vp - some verifications:
      ssd_verify_parameters(currdisk);

      //vp - this was not initialized and caused so many bugs
      currdisk->devno = i;

      if (!currdisk) continue;
/*        if (!currdisk->inited) { */
         currdisk->numblocks = currdisk->params.nelements *
                   currdisk->params.blocks_per_element *
                   currdisk->params.pages_per_block *
                   currdisk->params.page_size;
         currdisk->reconnect_reason = -1;
         addlisttoextraq ((event **) &currdisk->buswait);
         currdisk->busowned = -1;
         currdisk->completion_queue = NULL;
         /* hack to init queue structure */
         ioqueue_initialize (currdisk->queue, i);
         ssd_statinit(i, TRUE);
         currdisk->timing_t = ssd_new_timing_t(&currdisk->params);

         // initialize the gang
         exp_size = ssd_elem_export_size(currdisk);
         for (j = 0; j < SSD_NUM_GANG(currdisk); j ++) {
             int tot_pages = exp_size * currdisk->params.elements_per_gang;
             currdisk->gang_meta[j].busy = 0;
             currdisk->gang_meta[j].cleaning = 0;
             currdisk->gang_meta[j].reqs_waiting = 0;
             currdisk->gang_meta[j].oldest = 0;
             currdisk->gang_meta[j].pg2elem = malloc(sizeof(ssd_elem_number) * tot_pages);
             memset(currdisk->gang_meta[j].pg2elem, 0, sizeof(ssd_elem_number) * tot_pages);

             ioqueue_initialize (currdisk->gang_meta[j].queue, i);
         }

         for (j=0; j<currdisk->params.nelements; j++) {
             ssd_element *elem = &currdisk->elements[j];
             ioqueue_initialize (elem->queue, i);

             /* hack to init queue structure */
             elem->media_busy = FALSE;

             // vp - pins are also free
             elem->pin_busy = FALSE;

             // vp - initialize the planes in the element
             ssd_plane_init(elem, currdisk, i);

            // vp - initialize the ssd element metadata
            // FIXME: where to free these data?
             memset(&elem->stat, 0, sizeof(elem->stat));
            if (currdisk->params.write_policy == DISKSIM_SSD_WRITE_POLICY_OSR) {
                ssd_element_metadata_init(j, &(elem->metadata), currdisk);
            }

            //vp - initialize the stat structure
            memset(&elem->stat, 0, sizeof(ssd_element_stat));
         }
/*        } */
   }
}
Ejemplo n.º 6
0
/* Initialize device structures */
void
mems_initialize (void)
{
  int i;
  int j;
  int k;
  mems_t *dev;

  if (disksim->memsinfo == NULL) return;

  ioqueue_setcallbacks();

  /* Initialize all devices that have been inited (huh?) */
  for (i = 0; i < disksim->memsinfo->devices_len; i++) {
    dev = getmems(i);
    if (dev) {
      dev->busowned = -1;
      addlisttoextraq((event **)&dev->buswait);
      ioqueue_initialize(dev->queue, i);
      dev->dataxfer_req = NULL;
      dev->dataxfer_queue = NULL;

      /* Segment initialization stuff taken in part from disksim_disk.c */
      if ((dev->numsegs > 0) && (dev->seglist == NULL)) {
	dev->seglist = (struct mems_segment *)DISKSIM_malloc(sizeof(struct mems_segment));
	dev->seglist->next = NULL;
	dev->seglist->prev = NULL;
	dev->seglist->time = 0.0;
	dev->seglist->startblkno = 0;
	dev->seglist->endblkno   = 0;
	for (k = 1; k < dev->numsegs; k++) {
	  struct mems_segment *tmpseg = (struct mems_segment *)DISKSIM_malloc(sizeof(struct mems_segment));
	  tmpseg->next = dev->seglist;
	  dev->seglist = tmpseg;
	  tmpseg->next->prev = tmpseg;
	  tmpseg->prev = NULL;
	  tmpseg->startblkno = 0;
	  tmpseg->endblkno   = 0;
	}
      }
      if (dev->numsegs == 0) addlisttoextraq((event **)&dev->seglist);

      mems_check_numblocks(dev);

      for (j = 0; j < dev->num_sleds; j++) {
	dev->sled[j].dev = dev;

	ioqueue_initialize(dev->sled[j].queue, i);

	dev->sled[j].active = MEMS_SLED_INACTIVE;
	dev->sled[j].active_request = NULL;
	dev->sled[j].prefetch_info  = NULL;
	dev->sled[j].lastreq_lbn = mems_centermost_lbn(&dev->sled[j]);
	dev->sled[j].lastreq_comptime = 0.0;

	/* Initialize sled position, velocity at centermost LBN */
	mems_lbn_to_position(dev->sled[j].lastreq_lbn, &dev->sled[j], &dev->sled[j].coordset_up, &dev->sled[j].coordset_dn, &dev->sled[j].tipset, NULL, NULL, NULL);
	mems_coord_t_copy(&dev->sled[j].coordset_up.servo_start, &dev->sled[j].pos);

      }
      mems_statinit(i, TRUE);
      if (dev->precompute_seek_count > 0) {
	mems_precompute_seek_curve(dev);
      }
    }
  }
}