Skip to content

Commit d95cc97

Browse files
committed
Fix devdax_open_ipc_handle()
The consumer should use another /dev/dax device than the producer. Fix devdax_open_ipc_handle(). Fix ipc_devdax_prov.sh. Fix ipc_devdax_prov_consumer. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
1 parent 80e55db commit d95cc97

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

src/provider/provider_devdax_memory.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -442,47 +442,33 @@ static umf_result_t devdax_open_ipc_handle(void *provider,
442442
(devdax_memory_provider_t *)provider;
443443
devdax_ipc_data_t *devdax_ipc_data = (devdax_ipc_data_t *)providerIpcData;
444444

445-
// verify it is the same devdax - first verify the path
446-
if (strncmp(devdax_ipc_data->dd_path, devdax_provider->path, PATH_MAX)) {
447-
LOG_ERR("devdax path mismatch (local: %s, ipc: %s)",
448-
devdax_provider->path, devdax_ipc_data->dd_path);
449-
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
450-
}
451-
452-
// verify the size of the /dev/dax
453-
if (devdax_ipc_data->dd_size != devdax_provider->size) {
454-
LOG_ERR("devdax size mismatch (local: %zu, ipc: %zu)",
455-
devdax_provider->size, devdax_ipc_data->dd_size);
456-
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
457-
}
458-
459445
umf_result_t ret = UMF_RESULT_SUCCESS;
460-
int fd = utils_devdax_open(devdax_provider->path);
446+
int fd = utils_devdax_open(devdax_ipc_data->dd_path);
461447
if (fd == -1) {
462-
LOG_PERR("opening a devdax (%s) failed", devdax_provider->path);
448+
LOG_PERR("opening a devdax (%s) failed", devdax_ipc_data->dd_path);
463449
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
464450
}
465451

466452
unsigned map_sync_flag = 0;
467453
utils_translate_mem_visibility_flag(UMF_MEM_MAP_SYNC, &map_sync_flag);
468454

469455
// mmap /dev/dax with the MAP_SYNC xor MAP_SHARED flag (if MAP_SYNC fails)
470-
char *base = utils_mmap_file(NULL, devdax_provider->size,
456+
char *base = utils_mmap_file(NULL, devdax_ipc_data->dd_size,
471457
devdax_provider->protection, map_sync_flag, fd,
472458
0 /* offset */);
473459
if (base == NULL) {
474460
devdax_store_last_native_error(UMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED,
475461
errno);
476462
LOG_PERR("devdax mapping failed (path: %s, size: %zu, protection: %i, "
477463
"fd: %i)",
478-
devdax_provider->path, devdax_provider->size,
464+
devdax_ipc_data->dd_path, devdax_ipc_data->dd_size,
479465
devdax_provider->protection, fd);
480466
ret = UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC;
481467
}
482468

483469
LOG_DEBUG("devdax mapped (path: %s, size: %zu, protection: %i, fd: %i, "
484470
"offset: %zu)",
485-
devdax_provider->path, devdax_provider->size,
471+
devdax_ipc_data->dd_path, devdax_ipc_data->dd_size,
486472
devdax_provider->protection, fd, devdax_ipc_data->offset);
487473

488474
(void)utils_close_fd(fd);

test/ipc_devdax_prov.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ if [ "$UMF_TESTS_DEVDAX_SIZE" = "" ]; then
1919
exit 0
2020
fi
2121

22+
if [ "$UMF_TESTS_DEVDAX_PATH_2" = "" ]; then
23+
echo "Test skipped, UMF_TESTS_DEVDAX_PATH_2 is not set"
24+
exit 0
25+
fi
26+
27+
if [ "$UMF_TESTS_DEVDAX_SIZE_2" = "" ]; then
28+
echo "Test skipped, UMF_TESTS_DEVDAX_SIZE_2 is not set"
29+
exit 0
30+
fi
31+
2232
# port should be a number from the range <1024, 65535>
2333
PORT=$(( 1024 + ( $$ % ( 65535 - 1024 ))))
2434

test/ipc_devdax_prov_consumer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ int main(int argc, char *argv[]) {
2121

2222
int port = atoi(argv[1]);
2323

24-
char *path = getenv("UMF_TESTS_DEVDAX_PATH");
24+
char *path = getenv("UMF_TESTS_DEVDAX_PATH_2");
2525
if (path == NULL || path[0] == 0) {
26-
fprintf(stderr, "Test skipped, UMF_TESTS_DEVDAX_PATH is not set\n");
26+
fprintf(stderr, "Test skipped, UMF_TESTS_DEVDAX_PATH_2 is not set\n");
2727
return 0;
2828
}
2929

30-
char *size = getenv("UMF_TESTS_DEVDAX_SIZE");
30+
char *size = getenv("UMF_TESTS_DEVDAX_SIZE_2");
3131
if (size == NULL || size[0] == 0) {
32-
fprintf(stderr, "Test skipped, UMF_TESTS_DEVDAX_SIZE is not set\n");
32+
fprintf(stderr, "Test skipped, UMF_TESTS_DEVDAX_SIZE_2 is not set\n");
3333
return 0;
3434
}
3535

0 commit comments

Comments
 (0)