void SSD_WRITE(unsigned int length, int32_t sector_nb, float* ratios) { FTL_WRITE(sector_nb, length, ratios); }
void DEQUEUE_IO(void) { #ifdef FIRM_IO_BUF_DEBUG printf("[%s] Start.\n",__FUNCTION__); #endif if(e_queue->entry_nb == 0 || e_queue->head == NULL){ printf("ERROR[%s] There is no event. \n", __FUNCTION__); return; } event_queue_entry* e_q_entry = e_queue->head; int io_type = e_q_entry->io_type; int valid = e_q_entry->valid; int32_t sector_nb = e_q_entry->sector_nb; unsigned int length = e_q_entry->length; void* buf = e_q_entry->buf; /* Deallocation event queue entry */ e_queue->entry_nb--; if(e_queue->entry_nb == 0){ e_queue->head = NULL; e_queue->tail = NULL; } else{ e_queue->head = e_q_entry->next; } if(e_q_entry->io_type == WRITE){ free(e_q_entry); } else{ if(e_q_entry == last_read_entry){ last_read_entry = NULL; } } if(valid == VALID){ /* Call FTL Function */ if(io_type == READ){ if(buf != NULL){ /* The data is already read from write buffer */ } else{ /* Allocate read pointer */ e_q_entry->buf = ftl_read_ptr; FTL_READ(sector_nb, length); } } else if(io_type == WRITE){ FTL_WRITE(sector_nb, length); } else{ printf("ERROR[%s] Invalid IO type. \n",__FUNCTION__); } } #ifdef SSD_THREAD pthread_mutex_lock(&cq_lock); #endif if(io_type == READ){ /* Move event queue entry to completed event queue */ e_q_entry->next = NULL; if(c_e_queue->entry_nb == 0){ c_e_queue->head = e_q_entry; c_e_queue->tail = e_q_entry; } else{ c_e_queue->tail->next = e_q_entry; c_e_queue->tail = e_q_entry; } c_e_queue->entry_nb++; } #ifdef SSD_THREAD pthread_mutex_unlock(&cq_lock); #endif #ifdef FIRM_IO_BUF_DEBUG printf("[%s] End.\n",__FUNCTION__); #endif }