From e3b3e9ed17cea6c1d5adbe28ffe86620138a811b Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Fri, 27 Sep 2024 20:30:43 +0200 Subject: [PATCH] Use UMF_MEM_MAP_SYNC for FSDAX in the FSDAX IPC example Signed-off-by: Lukasz Dorau --- test/ipc_file_prov_consumer.c | 20 ++++++++++++++++++-- test/ipc_file_prov_fsdax.sh | 4 ++-- test/ipc_file_prov_producer.c | 20 ++++++++++++++++++-- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/test/ipc_file_prov_consumer.c b/test/ipc_file_prov_consumer.c index 834fe1054..d1e622efe 100644 --- a/test/ipc_file_prov_consumer.c +++ b/test/ipc_file_prov_consumer.c @@ -5,8 +5,11 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +#include #include #include +#include +#include #include @@ -15,17 +18,30 @@ int main(int argc, char *argv[]) { if (argc < 3) { - fprintf(stderr, "usage: %s \n", argv[0]); + fprintf(stderr, "usage: %s \n", argv[0]); + fprintf(stderr, " should be \"FSDAX\" or \"fsdax\" if " + " is located on FSDAX \n"); return -1; } int port = atoi(argv[1]); char *file_name = argv[2]; + bool is_fsdax = false; + + if (argc >= 4) { + if (strncasecmp(argv[3], "FSDAX", strlen("FSDAX")) == 0) { + is_fsdax = true; + } + } umf_file_memory_provider_params_t file_params; file_params = umfFileMemoryProviderParamsDefault(file_name); - file_params.visibility = UMF_MEM_MAP_SHARED; + if (is_fsdax) { + file_params.visibility = UMF_MEM_MAP_SYNC; + } else { + file_params.visibility = UMF_MEM_MAP_SHARED; + } return run_consumer(port, umfFileMemoryProviderOps(), &file_params, memcopy, NULL); diff --git a/test/ipc_file_prov_fsdax.sh b/test/ipc_file_prov_fsdax.sh index f2c799f11..56c540a65 100755 --- a/test/ipc_file_prov_fsdax.sh +++ b/test/ipc_file_prov_fsdax.sh @@ -25,13 +25,13 @@ UMF_LOG_VAL="level:debug;flush:debug;output:stderr;pid:yes" rm -f ${FILE_NAME} echo "Starting ipc_file_prov_fsdax CONSUMER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_consumer $PORT $FILE_NAME & +UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_consumer $PORT $FILE_NAME "FSDAX" & echo "Waiting 1 sec ..." sleep 1 echo "Starting ipc_file_prov_fsdax PRODUCER on port $PORT ..." -UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_producer $PORT $FILE_NAME +UMF_LOG=$UMF_LOG_VAL ./umf_test-ipc_file_prov_producer $PORT $FILE_NAME "FSDAX" # remove the SHM file rm -f ${FILE_NAME} diff --git a/test/ipc_file_prov_producer.c b/test/ipc_file_prov_producer.c index 783cff31d..1e7052efb 100644 --- a/test/ipc_file_prov_producer.c +++ b/test/ipc_file_prov_producer.c @@ -5,8 +5,11 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +#include #include #include +#include +#include #include @@ -15,17 +18,30 @@ int main(int argc, char *argv[]) { if (argc < 3) { - fprintf(stderr, "usage: %s \n", argv[0]); + fprintf(stderr, "usage: %s \n", argv[0]); + fprintf(stderr, " should be \"FSDAX\" or \"fsdax\" if " + " is located on FSDAX \n"); return -1; } int port = atoi(argv[1]); char *file_name = argv[2]; + bool is_fsdax = false; + + if (argc >= 4) { + if (strncasecmp(argv[3], "FSDAX", strlen("FSDAX")) == 0) { + is_fsdax = true; + } + } umf_file_memory_provider_params_t file_params; file_params = umfFileMemoryProviderParamsDefault(file_name); - file_params.visibility = UMF_MEM_MAP_SHARED; + if (is_fsdax) { + file_params.visibility = UMF_MEM_MAP_SYNC; + } else { + file_params.visibility = UMF_MEM_MAP_SHARED; + } return run_producer(port, umfFileMemoryProviderOps(), &file_params, memcopy, NULL);