void *SyncThreadWriteOrRead(void *arg) { struct thread_data *data = arg; bind2node_id(data->node_id); int node_id = data->node_id; int num = data->num; int off_start = data->off_start; int i; char *buffer = (char *) numa_alloc_onnode(block_size, node_id); ssd_file_desc_t fd = ssd_open(data->file_name, node_id, 0); printf("thread %d: access %d blocks\n", data->idx, num); for (i = 0; i < num; i++) { off_t offset = offs[off_start + i]; if (access == READ) ssd_read(fd, (void *) buffer, block_size, offset); else ssd_write(fd, (void *) buffer, block_size, offset); } numa_free(buffer, block_size); ssd_close(fd); return NULL; }
/** * @brief * Close and exit. * */ static void main_exit (void) { RM_TRACE(TF_NORMAL, "%s: Route Manager exits.", __func__); ssd_close(); config_clear(); kcom_close(); exit(0); }
void *AsyncThreadWriteOrRead(void *arg) { struct thread_data *data = arg; bind2node_id(data->node_id); int node_id = data->node_id; int num_completes = 0; int num = data->num; int off_start = data->off_start; int i; ssd_file_desc_t fd = ssd_open(data->file_name, node_id, 0); struct buf_pool *buf_allocator = create_buf_pool(block_size, block_size * 10000, node_id); struct callback_data *cb_data = (struct callback_data *) malloc(sizeof(*cb_data)); assert(cb_data); cb_data->num_completes = &num_completes; cb_data->buf_allocator = buf_allocator; ssd_set_callback(fd, cb_func, cb_data); for (i = 0; i < num; i++) { char *buffer = alloc_buf(buf_allocator); assert(buffer); off_t offset = offs[off_start + i]; if (access == READ) ssd_aread(fd, (void *) buffer, block_size, offset); else ssd_awrite(fd, (void *) buffer, block_size, offset); if (ssd_get_io_slots(fd) == 0) { ssd_wait(fd, 1); } } ssd_close(fd); return NULL; }