Skip to content

Commit

Permalink
Implemented new HAL multi-tenancy threading in NFS
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-JanGootzen committed May 30, 2023
1 parent 3a683ce commit 4d39510
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 99 deletions.
11 changes: 9 additions & 2 deletions dpfs_hal/src/snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ static void dpfs_hal_loop_static(struct dpfs_hal *hal)
// Only the first thread does mmio polling (sometimes)
if (pthread_create(&tdatas[i].thread, NULL, dpfs_hal_loop_static_thread, &tdatas[i])) {
warn("Failed to create thread for io %d", i);
for (int j = i - 1; j >= 0; j--) {
for (int j = 0; j < i; i++) {
pthread_cancel(tdatas[j].thread);
pthread_join(tdatas[j].thread, NULL);
}
return;
}
}

Expand Down Expand Up @@ -368,7 +369,7 @@ struct dpfs_hal *dpfs_hal_new(struct dpfs_hal_params *params)
// polling threads, which thread id it has
if (pthread_key_create(&dpfs_hal_thread_id_key, NULL)) {
fprintf(stderr, "Failed to create thread-local key for dpfs_hal threadid\n");
goto clear_pci_list;
goto out;
}

// Yes I know, we don't do NVMe here
Expand Down Expand Up @@ -421,6 +422,10 @@ struct dpfs_hal *dpfs_hal_new(struct dpfs_hal_params *params)
struct virtio_fs_ctrl *snap_ctrl = virtio_fs_ctrl_init(&param);
if (!snap_ctrl) {
fprintf(stderr, "failed to initialize virtio-fs device using SNAP on PF %u\n", param.pf_id);
for (uint16_t j = 0; j < i; j++) {
virtio_fs_ctrl_destroy(hal->devices[j].snap_ctrl);
free(hal->devices[j].tag);
}
goto clear_pci_list;
}

Expand Down Expand Up @@ -449,6 +454,8 @@ struct dpfs_hal *dpfs_hal_new(struct dpfs_hal_params *params)
out:
free(tag.u.s);
free(emu_manager.u.s);
free(hal->devices);
free(hal);
return NULL;
}

Expand Down
Loading

0 comments on commit 4d39510

Please sign in to comment.