From 30e14195657a8cde200b0deeab3662588bae5ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sat, 10 May 2025 11:00:23 +0800 Subject: [PATCH 01/13] hyperaio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- bundle.json | 15 +++- interfaces/kits/hyperaio/BUILD.gn | 67 ++++++++++++++ interfaces/kits/hyperaio/include/hyperaio.h | 97 +++++++++++++++++++++ 3 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 interfaces/kits/hyperaio/BUILD.gn create mode 100644 interfaces/kits/hyperaio/include/hyperaio.h diff --git a/bundle.json b/bundle.json index ded14f6a7..5fdf841c8 100644 --- a/bundle.json +++ b/bundle.json @@ -45,7 +45,8 @@ "napi", "samgr", "app_file_service", - "os_account" + "os_account", + "liburing" ], "third_party": [ "e2fsprogs", @@ -59,7 +60,8 @@ "//foundation/filemanagement/file_api/interfaces/kits/js:build_kits_js", "//foundation/filemanagement/file_api/interfaces/kits/ts/streamrw:streamrw_packages", "//foundation/filemanagement/file_api/interfaces/kits/ts/streamhash:streamhash_packages", - "//foundation/filemanagement/file_api/interfaces/kits/cj:fs_ffi_packages" + "//foundation/filemanagement/file_api/interfaces/kits/cj:fs_ffi_packages", + "//foundation/filemanagement/file_api/interfaces/kits/hyperaio:group_hyperaio" ], "service_group": [] }, @@ -73,6 +75,15 @@ "header_base": "//foundation/filemanagement/file_api/interfaces/kits/native/remote_uri" } }, + { + "name": "//foundation/filemanagement/file_api/interfaces/kits/hyperaio:HyperAio", + "header": { + "header_files": [ + "hyperaio.h" + ], + "header_base": "//foundation/filemanagement/file_api/interfaces/kits/hyperaio/include" + } + }, { "name": "//foundation/filemanagement/file_api/interfaces/kits/native:environment_native", "header": { diff --git a/interfaces/kits/hyperaio/BUILD.gn b/interfaces/kits/hyperaio/BUILD.gn new file mode 100644 index 000000000..5a35a775c --- /dev/null +++ b/interfaces/kits/hyperaio/BUILD.gn @@ -0,0 +1,67 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//foundation/filemanagement/file_api/file_api.gni") + +group("group_hyperaio") { + deps = [ + ":HyperAio", + ] +} + +config("hyperaio_config") { + visibility = [ ":*" ] + include_dirs = [ "include" ] +} + +ohos_shared_library("HyperAio") { + if (!use_mingw_win && !use_mac) { + cflags = [ + "-fdata-sections", + "-ffunction-sections", + "-Oz", + ] + cflags_cc = [ + "-fvisibility-inlines-hidden", + "-Oz", + ] + branch_protector_ret = "pac_ret" + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + } + + sources = [ "src/hyperaio.cpp" ] + + public_configs = [ ":hyperaio_config" ] + + deps = [ ] + + external_deps = [ + "c_utils:utils", + "liburing:liburing", + "hilog:libhilog", + "ipc:ipc_core", + "access_token:libaccesstoken_sdk" + ] + + innerapi_tags = [ "platformsdk" ] + part_name = "file_api" + subsystem_name = "filemanagement" +} \ No newline at end of file diff --git a/interfaces/kits/hyperaio/include/hyperaio.h b/interfaces/kits/hyperaio/include/hyperaio.h new file mode 100644 index 000000000..b4fd06b38 --- /dev/null +++ b/interfaces/kits/hyperaio/include/hyperaio.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FILEMANAGEMENT_FILE_API_INTERFACES_KITS_IOURING_HYPER_AIO_H +#define FILEMANAGEMENT_FILE_API_INTERFACES_KITS_IOURING_HYPER_AIO_H + +#include +#include +#include "liburing.h" + +namespace OHOS { +namespace HyperAio { +#define IOURING_APP_PERMISSION (1U << 0) +#ifndef EOK +#define EOK (0) +#endif + +struct ReadInfo { + int32_t fd; + uint32_t len; + uint64_t offset; + void *buf; + uint64_t userData; +}; + +struct ReadReqs { + uint32_t reqNum; + struct ReadInfo *reqs; +}; + +struct OpenInfo { + int32_t dfd; + int32_t flags; + mode_t mode; + void *path; + uint64_t userData; +}; + +struct OpenReqs { + uint32_t reqNum; + struct OpenInfo *reqs; +}; + +struct CancelInfo { + uint64_t userData; + uint64_t targetUserData; +}; + +struct CancelReqs { + uint32_t reqNum; + struct CancelInfo *reqs; +}; + +struct IoResponse { + uint64_t userData; + int32_t res; + uint32_t flags; + IoResponse(uint64_t userData, int32_t res, uint32_t flags) + : userData(userData), + res(res), + flags(flags) { + } +}; + +class HyperAio { +public: + using ProcessIoResultCallBack = std::function)>; + uint32_t SupportIouring(); + int32_t CtxInit(ProcessIoResultCallBack *callBack); + int32_t StartReadReqs(ReadReqs *req); + int32_t StartOpenReqs(OpenReqs *req); + int32_t StartCancelReqs(CancelReqs *req); + int32_t DestroyCtx(); +private: + io_uring uring_; + ProcessIoResultCallBack ioResultCallBack_ = nullptr; + std::thread harvestThread_; + std::atomic stopThread_; + std::atomic initialized_; + void HarvestRes(); + struct io_uring_sqe* GetSqeWithRetry(struct io_uring *ring); +}; +} +} +#endif \ No newline at end of file -- Gitee From 250919b909a1f7ec7e9721e216a3f9983d51a1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 9 May 2025 20:34:40 +0800 Subject: [PATCH 02/13] hyperaio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/include/hyperaio.h | 3 + interfaces/kits/hyperaio/include/libhilog.h | 56 +++++ interfaces/kits/hyperaio/src/hyperaio.cpp | 236 ++++++++++++++++++++ 3 files changed, 295 insertions(+) create mode 100644 interfaces/kits/hyperaio/include/libhilog.h create mode 100644 interfaces/kits/hyperaio/src/hyperaio.cpp diff --git a/interfaces/kits/hyperaio/include/hyperaio.h b/interfaces/kits/hyperaio/include/hyperaio.h index b4fd06b38..e6ff82d6e 100644 --- a/interfaces/kits/hyperaio/include/hyperaio.h +++ b/interfaces/kits/hyperaio/include/hyperaio.h @@ -23,9 +23,12 @@ namespace OHOS { namespace HyperAio { #define IOURING_APP_PERMISSION (1U << 0) +<<<<<<< HEAD #ifndef EOK #define EOK (0) #endif +======= +>>>>>>> 3b9c19b... hyperaio struct ReadInfo { int32_t fd; diff --git a/interfaces/kits/hyperaio/include/libhilog.h b/interfaces/kits/hyperaio/include/libhilog.h new file mode 100644 index 000000000..9e882f46b --- /dev/null +++ b/interfaces/kits/hyperaio/include/libhilog.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FILEMGMT_LIBHILOG_H +#define FILEMGMT_LIBHILOG_H + +#include "hilog/log.h" + +#include + +namespace OHOS { +#ifndef LOG_DOMAIN +#define LOG_DOMAIN 0xD001600 +#endif + +#ifndef LOG_TAG +#define LOG_TAG "FileManagement" +#endif + +#if defined __FILE_NAME__ +#define FILEMGMT_FILE_NAME __FILE_NAME__ +#else +#include +#define FILEMGMT_FILE_NAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) +#endif + +#define HILOGF(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, LOG_DOMAIN, LOG_TAG, \ + "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) +#define HILOGE(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, LOG_DOMAIN, LOG_TAG, \ + "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) +#define HILOGW(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, LOG_DOMAIN, LOG_TAG, \ + "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) +#define HILOGI(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, LOG_DOMAIN, LOG_TAG, \ + "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) +#define HILOGD(fmt, ...) \ + ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \ + "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) +} // namespace OHOS + +#endif // FILEMGMT_LIBHILOG_H \ No newline at end of file diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp new file mode 100644 index 000000000..70f424b5c --- /dev/null +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hyperaio.h" + +#include +#include +#include "accesstoken_kit.h" +#include "libhilog.h" +#include "ipc_skeleton.h" + +namespace OHOS { +namespace HyperAio { +const uint32_t URING_QUEUE_SIZE = 512; +const uint32_t DELAY = 20; +const uint32_t BATCH_SIZE = 128; +const uint32_t RETRIES = 3; + +static bool HasAccessIouringPermission() +{ + Security::AccessToken::AccessTokenID tokenCaller = IPCSkeleton::GetCallingTokenID(); + const std::string permissionName = "ohos.permission.ALLOW_IOURING"; + int32_t res = Security::AccessToken::AccessTokenKit::VerifyAccessToken(tokenCaller, permissionName); + if (res != Security::AccessToken::PermissionState::PERMISSION_GRANTED) { + HILOGE("have no ALLOW_IOURING permission"); + return false; + } + return true; +} + +uint32_t HyperAio::SupportIouring() +{ + uint32_t flags = 0; + if (HasAccessIouringPermission()) { + flags |= IOURING_APP_PERMISSION; + } + return flags; +} + +int32_t HyperAio::CtxInit(ProcessIoResultCallBack *callBack) +{ + if (callBack == nullptr) { + HILOGE("callBack is null"); + return -EINVAL; + } + int32_t ret = io_uring_queue_init(URING_QUEUE_SIZE, &uring_, 0); + if (ret < 0) { + HILOGE("init io_uring failed, ret = %{public}d", ret); + return ret; + } + ioResultCallBack_ = *callBack; + stopThread_.store(false); + harvestThread_ = std::thread(&HyperAio::HarvestRes, this); + initialized_.store(true); + HILOGI("init hyperaio success"); + return EOK; +} + +struct io_uring_sqe* HyperAio::GetSqeWithRetry(struct io_uring *ring) +{ + struct io_uring_sqe *sqe; + for (uint32_t i = 0; i < RETRIES; i++) { + sqe = io_uring_get_sqe(ring); + if (sqe != nullptr) { + return sqe; + } + io_uring_submit(ring); + std::this_thread::sleep_for(std::chrono::milliseconds(DELAY)); + } + return nullptr; +} + +int32_t HyperAio::StartOpenReqs(OpenReqs *req) +{ + if (req == nullptr || req->reqs == nullptr) { + return -EINVAL; + } + if (!initialized_.load()) { + HILOGE("HyperAio is not initialized"); + return -EPERM; + } + uint32_t totalReqs = req->reqNum; + uint32_t count = 0; + for(uint32_t i = 0; i < totalReqs; i++){ + struct io_uring_sqe *sqe = GetSqeWithRetry(&uring_); + if (sqe == nullptr) { + HILOGE("get sqe failed"); + return -ENOMEM; + } + struct OpenInfo *openInfo = &req->reqs[i]; + io_uring_sqe_set_data(sqe, reinterpret_cast(openInfo->userData)); + io_uring_prep_openat(sqe, openInfo->dfd, static_cast(openInfo->path), + openInfo->flags, openInfo->mode); + count++; + if (count >= BATCH_SIZE) { + count = 0; + int32_t ret = io_uring_submit(&uring_); + if (ret < 0) { + HILOGE("submit open reqs failed, ret = %{public}d", ret); + return ret; + } + } + } + if (count > 0 && count < BATCH_SIZE) { + int32_t ret = io_uring_submit(&uring_); + if (ret < 0) { + HILOGE("submit open reqs failed, ret = %{public}d", ret); + return ret; + } + } + return EOK; +} + +int32_t HyperAio::StartReadReqs(ReadReqs *req) +{ + if (req == nullptr || req->reqs == nullptr) { + return -EINVAL; + } + if (!initialized_.load()) { + HILOGE("HyperAio is not initialized"); + return -EPERM; + } + uint32_t totalReqs = req->reqNum; + uint32_t count = 0; + for(uint32_t i = 0; i < totalReqs; i++) + { + struct io_uring_sqe *sqe = GetSqeWithRetry(&uring_); + if (sqe == nullptr) { + HILOGE("get sqe failed"); + return -ENOMEM; + } + struct ReadInfo *readInfo = &req->reqs[i]; + io_uring_sqe_set_data(sqe, reinterpret_cast(readInfo->userData)); + io_uring_prep_read(sqe, readInfo->fd, readInfo->buf, readInfo->len, readInfo->offset); + count++; + if (count >= BATCH_SIZE) { + count = 0; + int32_t ret = io_uring_submit(&uring_); + if (ret < 0) { + HILOGE("submit read reqs failed, ret = %{public}d", ret); + return ret; + } + } + } + if (count > 0 && count < BATCH_SIZE) { + int32_t ret = io_uring_submit(&uring_); + if (ret < 0) { + HILOGE("submit read reqs failed, ret = %{public}d", ret); + return ret; + } + } + return EOK; +} + +int32_t HyperAio::StartCancelReqs(CancelReqs *req) +{ + if (req == nullptr || req->reqs == nullptr) { + return -EINVAL; + } + if (!initialized_.load()) { + HILOGE("HyperAio is not initialized"); + return -EPERM; + } + uint32_t totalReqs = req->reqNum; + uint32_t count = 0; + for(uint32_t i = 0; i < totalReqs; i++) + { + struct io_uring_sqe *sqe = GetSqeWithRetry(&uring_); + if (sqe == nullptr) { + HILOGE("get sqe failed"); + return -ENOMEM; + } + struct CancelInfo *cancelInfo = &req->reqs[i]; + io_uring_sqe_set_data(sqe, reinterpret_cast(cancelInfo->userData)); + io_uring_prep_cancel(sqe, reinterpret_cast(cancelInfo->targetUserData), 0); + count++; + if (count >= BATCH_SIZE) { + count = 0; + int32_t ret = io_uring_submit(&uring_); + if (ret < 0) { + HILOGE("submit cancel reqs failed, ret = %{public}d", ret); + return ret; + } + } + } + if (count > 0 && count < BATCH_SIZE) { + int32_t ret = io_uring_submit(&uring_); + if (ret < 0) { + HILOGE("submit cancel reqs failed, ret = %{public}d", ret); + return ret; + } + } + return EOK; +} + +void HyperAio::HarvestRes() +{ + while (!stopThread_.load()) { + struct io_uring_cqe *cqe; + int32_t ret = io_uring_wait_cqe(&uring_, &cqe); + if (ret < 0 || cqe == nullptr) { + HILOGI("wait cqe failed, ret = %{public}d", ret); + continue; + } + auto response = std::make_unique(cqe->user_data, cqe->res, cqe->flags); + io_uring_cqe_seen(&uring_, cqe); + if (ioResultCallBack_) { + ioResultCallBack_(std::move(response)); + } + } +} + +int32_t HyperAio::DestroyCtx() +{ + stopThread_.store(true); + if (harvestThread_.joinable()) { + harvestThread_.join(); + } + io_uring_queue_exit(&uring_); + initialized_.store(false); + return EOK; +} +} +} \ No newline at end of file -- Gitee From b68448a4a1b59335b677048591f17fc488033285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 23 May 2025 11:47:53 +0800 Subject: [PATCH 03/13] a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/include/hyperaio.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/interfaces/kits/hyperaio/include/hyperaio.h b/interfaces/kits/hyperaio/include/hyperaio.h index e6ff82d6e..b4fd06b38 100644 --- a/interfaces/kits/hyperaio/include/hyperaio.h +++ b/interfaces/kits/hyperaio/include/hyperaio.h @@ -23,12 +23,9 @@ namespace OHOS { namespace HyperAio { #define IOURING_APP_PERMISSION (1U << 0) -<<<<<<< HEAD #ifndef EOK #define EOK (0) #endif -======= ->>>>>>> 3b9c19b... hyperaio struct ReadInfo { int32_t fd; -- Gitee From 70edc6b1e46608f1be2bac2d7608983f91b40de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sat, 10 May 2025 18:37:53 +0800 Subject: [PATCH 04/13] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/include/hyperaio.h | 2 +- interfaces/kits/hyperaio/include/libhilog.h | 8 ++++---- interfaces/kits/hyperaio/src/hyperaio.cpp | 10 ++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/interfaces/kits/hyperaio/include/hyperaio.h b/interfaces/kits/hyperaio/include/hyperaio.h index b4fd06b38..b950ddc86 100644 --- a/interfaces/kits/hyperaio/include/hyperaio.h +++ b/interfaces/kits/hyperaio/include/hyperaio.h @@ -22,7 +22,7 @@ namespace OHOS { namespace HyperAio { -#define IOURING_APP_PERMISSION (1U << 0) +#define HYPERAIO_APP_PERMISSION (1U << 0) #ifndef EOK #define EOK (0) #endif diff --git a/interfaces/kits/hyperaio/include/libhilog.h b/interfaces/kits/hyperaio/include/libhilog.h index 9e882f46b..91c7c0943 100644 --- a/interfaces/kits/hyperaio/include/libhilog.h +++ b/interfaces/kits/hyperaio/include/libhilog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef FILEMGMT_LIBHILOG_H -#define FILEMGMT_LIBHILOG_H +#ifndef HYPERAIO_LIBHILOG_H +#define HYPERAIO_LIBHILOG_H #include "hilog/log.h" @@ -26,7 +26,7 @@ namespace OHOS { #endif #ifndef LOG_TAG -#define LOG_TAG "FileManagement" +#define LOG_TAG "HyperAio" #endif #if defined __FILE_NAME__ diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 70f424b5c..95d96e87e 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -44,7 +44,7 @@ uint32_t HyperAio::SupportIouring() { uint32_t flags = 0; if (HasAccessIouringPermission()) { - flags |= IOURING_APP_PERMISSION; + flags |= HYERAIO_APP_PERMISSION; } return flags; } @@ -93,7 +93,7 @@ int32_t HyperAio::StartOpenReqs(OpenReqs *req) } uint32_t totalReqs = req->reqNum; uint32_t count = 0; - for(uint32_t i = 0; i < totalReqs; i++){ + for (uint32_t i = 0; i < totalReqs; i++) { struct io_uring_sqe *sqe = GetSqeWithRetry(&uring_); if (sqe == nullptr) { HILOGE("get sqe failed"); @@ -134,8 +134,7 @@ int32_t HyperAio::StartReadReqs(ReadReqs *req) } uint32_t totalReqs = req->reqNum; uint32_t count = 0; - for(uint32_t i = 0; i < totalReqs; i++) - { + for (uint32_t i = 0; i < totalReqs; i++) { struct io_uring_sqe *sqe = GetSqeWithRetry(&uring_); if (sqe == nullptr) { HILOGE("get sqe failed"); @@ -175,8 +174,7 @@ int32_t HyperAio::StartCancelReqs(CancelReqs *req) } uint32_t totalReqs = req->reqNum; uint32_t count = 0; - for(uint32_t i = 0; i < totalReqs; i++) - { + for (uint32_t i = 0; i < totalReqs; i++) { struct io_uring_sqe *sqe = GetSqeWithRetry(&uring_); if (sqe == nullptr) { HILOGE("get sqe failed"); -- Gitee From 8a72154cfdcfb6530112cbaf16d9b905b439b264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 11 May 2025 17:39:53 +0800 Subject: [PATCH 05/13] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/BUILD.gn | 2 +- interfaces/kits/hyperaio/include/libhilog.h | 49 +++- interfaces/test/unittest/hyperaio/BUILD.gn | 41 +++ .../test/unittest/hyperaio/hyperaio_test.cpp | 260 ++++++++++++++++++ 4 files changed, 337 insertions(+), 15 deletions(-) create mode 100644 interfaces/test/unittest/hyperaio/BUILD.gn create mode 100644 interfaces/test/unittest/hyperaio/hyperaio_test.cpp diff --git a/interfaces/kits/hyperaio/BUILD.gn b/interfaces/kits/hyperaio/BUILD.gn index 5a35a775c..0ac7313ef 100644 --- a/interfaces/kits/hyperaio/BUILD.gn +++ b/interfaces/kits/hyperaio/BUILD.gn @@ -61,7 +61,7 @@ ohos_shared_library("HyperAio") { "access_token:libaccesstoken_sdk" ] - innerapi_tags = [ "platformsdk" ] + install_images = [ "system" ] part_name = "file_api" subsystem_name = "filemanagement" } \ No newline at end of file diff --git a/interfaces/kits/hyperaio/include/libhilog.h b/interfaces/kits/hyperaio/include/libhilog.h index 91c7c0943..f4f81721d 100644 --- a/interfaces/kits/hyperaio/include/libhilog.h +++ b/interfaces/kits/hyperaio/include/libhilog.h @@ -21,36 +21,57 @@ #include namespace OHOS { -#ifndef LOG_DOMAIN -#define LOG_DOMAIN 0xD001600 -#endif - -#ifndef LOG_TAG -#define LOG_TAG "HyperAio" -#endif +namespace HyperAio { #if defined __FILE_NAME__ #define FILEMGMT_FILE_NAME __FILE_NAME__ #else -#include #define FILEMGMT_FILE_NAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) #endif +#ifndef HYPERAIO_LOG_DOMAIN +#define HYPERAIO_LOG_DOMAIN 0xD004388 +#endif + +#undef HYPERAIO_LOG_TAG +#define HYPERAIO_LOG_TAG "hyperaio" + +#ifdef HILOGD +#undef HILOGD +#endif + +#ifdef HILOGF +#undef HILOGF +#endif + +#ifdef HILOGE +#undef HILOGE +#endif + +#ifdef HILOGW +#undef HILOGW +#endif + +#ifdef HILOGI +#undef HILOGI +#endif + #define HILOGF(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) #define HILOGE(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) #define HILOGW(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) #define HILOGI(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) #define HILOGD(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) +} // namespace HyperAio } // namespace OHOS -#endif // FILEMGMT_LIBHILOG_H \ No newline at end of file +#endif // HYPERAIO_LIBHILOG_H \ No newline at end of file diff --git a/interfaces/test/unittest/hyperaio/BUILD.gn b/interfaces/test/unittest/hyperaio/BUILD.gn new file mode 100644 index 000000000..0a7a58c87 --- /dev/null +++ b/interfaces/test/unittest/hyperaio/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/filemanagement/file_api/file_api.gni") + +ohos_unittest("hyperaio_test") { + module_out_path = "file_api/file_api" + + resource_config_file = "../resource/ohos_test.xml" + + sources = [ "hyperaio_test.cpp" ] + + include_dirs = [ + "include", + "${file_api_path}/interfaces/kits/hyperaio/include", + ] + + deps = [ + "${file_api_path}/interfaces/kits/hyperaio:HyperAio", + ] + + external_deps = [ + "access_token:libaccesstoken_sdk", + "c_utils:utils", + "c_utils:utilsbase", + "ipc:ipc_core", + "googletest:gtest_main", + "liburing:liburing", + ] +} diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp new file mode 100644 index 000000000..4ae580af6 --- /dev/null +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "hyperaio.h" + +namespace { + using namespace std; + using namespace OHOS::HyperAio; + const uint64_t userData = 12345; + const uint32_t len = 1024; + class HyperAioTest : public testing::Test { + public: + static void SetUpTestCase(void) {}; + static void TearDownTestCase() {}; + void SetUp() {}; + void TearDown() {}; + }; + std::function)> callBack = [](std::unique_ptr response) { + GTEST_LOG_(INFO) << "HyperAioTest callBack"; + } + + /** + * @tc.name: HyperAio_StartOpenReqs_0000 + * @tc.desc: Test function of StartOpenReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0000, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0000"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + result = hyperAio_->CtxInit(nullptr); + EXPECT_EQ(result, -EINVAL); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartOpenReqs_0000"; + } + + /** + * @tc.name: HyperAio_StartOpenReqs_0001 + * @tc.desc: Test function of StartOpenReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0001, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0001"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + OpenInfo openInfo = {0, O_RDWR, 0, nullptr, userData}; + OpenReqs openReqs = {1, &openInfo}; + result = hyperAio_->StartOpenReqs(&openReqs); + EXPECT_EQ(result, 0); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartOpenReqs_0001"; + } + + /** + * @tc.name: HyperAio_StartOpenReqs_0002 + * @tc.desc: Test function of StartOpenReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartOpenReqs_0002, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0002"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + OpenInfo openInfo = {0, O_RDWR, 0, nullptr, userData}; + OpenReqs openReqs = {1, &openInfo}; + result = hyperAio_->StartOpenReqs(&openReqs); + EXPECT_EQ(result, -EPERM); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartOpenReqs_0002"; + } + + /** + * @tc.name: HyperAio_StartReadReqs_0000 + * @tc.desc: Test function of StartReadReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0000, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0000"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + result = hyperAio_->CtxInit(nullptr); + EXPECT_EQ(result, -EINVAL); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0000"; + } + + /** + * @tc.name: HyperAio_StartReadReqs_0001 + * @tc.desc: Test function of StartReadReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0001, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0001"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + ReadInfo readInfo = {0, len, 0, nullptr, userData}; + ReadReqs readReqs = {1, &readInfo}; + result = hyperAio_->StartReadReqs(&readReqs); + EXPECT_EQ(result, 0); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0001"; + } + + /** + * @tc.name: HyperAio_StartReadReqs_0002 + * @tc.desc: Test function of StartReadReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartReadReqs_0002, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0002"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + ReadInfo readInfo = {0, len, 0, nullptr, userData}; + ReadReqs readReqs = {1, &readInfo}; + result = hyperAio_->StartReadReqs(&readReqs); + EXPECT_EQ(result, -EPERM); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartReadReqs_0002"; + } + + /** + * @tc.name: HyperAio_StartCancelReqs_0000 + * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0000, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0000"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + result = hyperAio_->CtxInit(nullptr); + EXPECT_EQ(result, -EINVAL); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0000"; + } + + /** + * @tc.name: HyperAio_StartCancelReqs_0001 + * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0001, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0001"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + result = hyperAio_->CtxInit(&callBack); + EXPECT_EQ(result, 0); + CancelInfo cancelInfo = {userData, 0}; + CancelReqs cancelReqs = {1, &cancelInfo}; + result = hyperAio_->StartCancelReqs(&cancelReqs); + EXPECT_EQ(result, 0); + result = hyperAio_->DestroyCtx(); + EXPECT_EQ(result, 0); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0001"; + } + + /** + * @tc.name: HyperAio_StartCancelReqs_0002 + * @tc.desc: Test function of StartCancelReqs() interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: AR000HG8M4 + */ + HWTEST_F(HyperAioTest, HyperAio_StartCancelReqs_0002, testing::ext::TestSize.Level1) + { + GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0002"; + std::unique_ptr hyperAio_ = std::make_unique(); + int32_t result = hyperAio_->SupportIouring(); + EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); + if ((result & IOURING_APP_PERMISSION) == 0) { + return; + } + CancelInfo cancelInfo = {userData, 0}; + CancelReqs cancelReqs = {1, &cancelInfo}; + result = hyperAio_->StartCancelReqs(&cancelReqs); + EXPECT_EQ(result, -EPERM); + GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0002"; + } +} -- Gitee From 6ee1171f63e6c36779bc72509c6a5a4734a54494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 11 May 2025 17:44:43 +0800 Subject: [PATCH 06/13] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/test/unittest/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/test/unittest/BUILD.gn b/interfaces/test/unittest/BUILD.gn index 95f924b84..b14741b2d 100644 --- a/interfaces/test/unittest/BUILD.gn +++ b/interfaces/test/unittest/BUILD.gn @@ -18,5 +18,6 @@ group("unittest") { "filemgmt_libn_test:filemgmt_libn_test", "remote_uri:remote_uri_test", "task_signal:task_signal_test", + "hyperaio:hyperaio_test" ] } -- Gitee From 7734661abe197c776220e88e588d0e7bf9ede23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Mon, 12 May 2025 09:26:14 +0800 Subject: [PATCH 07/13] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/include/libhilog.h | 10 +++++----- interfaces/test/unittest/hyperaio/hyperaio_test.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interfaces/kits/hyperaio/include/libhilog.h b/interfaces/kits/hyperaio/include/libhilog.h index f4f81721d..3535112a2 100644 --- a/interfaces/kits/hyperaio/include/libhilog.h +++ b/interfaces/kits/hyperaio/include/libhilog.h @@ -57,19 +57,19 @@ namespace HyperAio { #endif #define HILOGF(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, HYPERAIO_LOG_DOMAIN, HYPERAIO_LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) #define HILOGE(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, HYPERAIO_LOG_DOMAIN, HYPERAIO_LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) #define HILOGW(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, HYPERAIO_LOG_DOMAIN, HYPERAIO_LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) #define HILOGI(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, HYPERAIO_LOG_DOMAIN, HYPERAIO_LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) #define HILOGD(fmt, ...) \ - ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, HYPERAIO_LOG_DOMAIN, LOG_TAG, \ + ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, HYPERAIO_LOG_DOMAIN, HYPERAIO_LOG_TAG, \ "[%{public}s:%{public}d->%{public}s] " fmt, FILEMGMT_FILE_NAME, __LINE__, __FUNCTION__, ##__VA_ARGS__)) } // namespace HyperAio } // namespace OHOS diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index 4ae580af6..43569a16d 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -34,7 +34,7 @@ namespace { }; std::function)> callBack = [](std::unique_ptr response) { GTEST_LOG_(INFO) << "HyperAioTest callBack"; - } + }; /** * @tc.name: HyperAio_StartOpenReqs_0000 -- Gitee From cefae4042def83eaceac7502d4c6d48ce780a341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 23 May 2025 12:11:09 +0800 Subject: [PATCH 08/13] hyperaio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/BUILD.gn | 8 +++- .../kits/hyperaio/include/hyperaio_trace.h | 37 ++++++++++++++++ interfaces/kits/hyperaio/src/hyperaio.cpp | 6 +++ .../kits/hyperaio/src/hyperaio_trace.cpp | 42 +++++++++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 interfaces/kits/hyperaio/include/hyperaio_trace.h create mode 100644 interfaces/kits/hyperaio/src/hyperaio_trace.cpp diff --git a/interfaces/kits/hyperaio/BUILD.gn b/interfaces/kits/hyperaio/BUILD.gn index 0ac7313ef..8baa592f4 100644 --- a/interfaces/kits/hyperaio/BUILD.gn +++ b/interfaces/kits/hyperaio/BUILD.gn @@ -47,7 +47,10 @@ ohos_shared_library("HyperAio") { } } - sources = [ "src/hyperaio.cpp" ] + sources = [ + "src/hyperaio.cpp", + "src/hyperaio_trace.cpp" + ] public_configs = [ ":hyperaio_config" ] @@ -58,7 +61,8 @@ ohos_shared_library("HyperAio") { "liburing:liburing", "hilog:libhilog", "ipc:ipc_core", - "access_token:libaccesstoken_sdk" + "access_token:libaccesstoken_sdk", + "hitrace:hitrace_meter", ] install_images = [ "system" ] diff --git a/interfaces/kits/hyperaio/include/hyperaio_trace.h b/interfaces/kits/hyperaio/include/hyperaio_trace.h new file mode 100644 index 000000000..77766701c --- /dev/null +++ b/interfaces/kits/hyperaio/include/hyperaio_trace.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HYPERAIO_TRACE_H +#define HYPERAIO_TRACE_H + +#include "hitrace_meter.h" +#include "libhilog.h" + +namespace OHOS { +namespace HyperAio { + +class HyperaioTrace { +public: + HyperaioTrace(const std::string& value, bool isShowLog = false); + ~HyperaioTrace(); + void End(); +private: + std::string value; + bool isFinished_{false}; +}; +} // namespace HyperAio +} // namespace OHOS + +#endif //HYPERAIO_TRACE_H \ No newline at end of file diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 95d96e87e..05df9bc88 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -18,6 +18,7 @@ #include #include #include "accesstoken_kit.h" +#include "hyperaio_trace.h" #include "libhilog.h" #include "ipc_skeleton.h" @@ -42,6 +43,7 @@ static bool HasAccessIouringPermission() uint32_t HyperAio::SupportIouring() { + HyperAioTrace trace("SupportIouring"); uint32_t flags = 0; if (HasAccessIouringPermission()) { flags |= HYERAIO_APP_PERMISSION; @@ -51,6 +53,7 @@ uint32_t HyperAio::SupportIouring() int32_t HyperAio::CtxInit(ProcessIoResultCallBack *callBack) { + HyperAioTrace trace("CtxInit"); if (callBack == nullptr) { HILOGE("callBack is null"); return -EINVAL; @@ -84,6 +87,7 @@ struct io_uring_sqe* HyperAio::GetSqeWithRetry(struct io_uring *ring) int32_t HyperAio::StartOpenReqs(OpenReqs *req) { + HyperAioTrace trace("StartOpenReqs" + std::to_string(req->reqNum)); if (req == nullptr || req->reqs == nullptr) { return -EINVAL; } @@ -125,6 +129,7 @@ int32_t HyperAio::StartOpenReqs(OpenReqs *req) int32_t HyperAio::StartReadReqs(ReadReqs *req) { + HyperAioTrace trace("StartReadReqs" + std::to_string(req->reqNum)); if (req == nullptr || req->reqs == nullptr) { return -EINVAL; } @@ -165,6 +170,7 @@ int32_t HyperAio::StartReadReqs(ReadReqs *req) int32_t HyperAio::StartCancelReqs(CancelReqs *req) { + HyperAioTrace trace("StartCancelReqs" + std::to_string(req->reqNum)); if (req == nullptr || req->reqs == nullptr) { return -EINVAL; } diff --git a/interfaces/kits/hyperaio/src/hyperaio_trace.cpp b/interfaces/kits/hyperaio/src/hyperaio_trace.cpp new file mode 100644 index 000000000..9cc501bee --- /dev/null +++ b/interfaces/kits/hyperaio/src/hyperaio_trace.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hyperaio_trace.h" + +namespace OHOS { +namespace HyperAio { + +HyperaioTrace::HyperaioTrace(const std::string& value, bool isShowLog) : value_(value) +{ + if (isShowLog) { + HILOGEI("%{public}s", value_.c_str()); + } + StartTrace(HITRACE_TAG_OHOS, "[HyperAio]" + value); +} + +void HyperaioTrace::End() +{ + if(!isFinished_) { + FinishTrace(HITRACE_TAG_OHOS); + isFinished_ = true; + } +} + +HyperaioTrace::~HyperaioTrace() +{ + End(); +} +} // namespace HyperAio +} // namespace OHOS \ No newline at end of file -- Gitee From c9fc0a21b685e676cf42c1eccdbdc6d2c89fff1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 23 May 2025 14:26:15 +0800 Subject: [PATCH 09/13] hyperaio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/include/hyperaio_trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/hyperaio/include/hyperaio_trace.h b/interfaces/kits/hyperaio/include/hyperaio_trace.h index 77766701c..0ea6dbc77 100644 --- a/interfaces/kits/hyperaio/include/hyperaio_trace.h +++ b/interfaces/kits/hyperaio/include/hyperaio_trace.h @@ -28,7 +28,7 @@ public: ~HyperaioTrace(); void End(); private: - std::string value; + std::string value_; bool isFinished_{false}; }; } // namespace HyperAio -- Gitee From f65fb355a0dfd23f5fc667e851663702371f9f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 23 May 2025 15:05:33 +0800 Subject: [PATCH 10/13] hyperaio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/src/hyperaio.cpp | 12 ++++++------ interfaces/kits/hyperaio/src/hyperaio_trace.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 05df9bc88..639fdb310 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -43,17 +43,17 @@ static bool HasAccessIouringPermission() uint32_t HyperAio::SupportIouring() { - HyperAioTrace trace("SupportIouring"); + HyperaioTrace trace("SupportIouring"); uint32_t flags = 0; if (HasAccessIouringPermission()) { - flags |= HYERAIO_APP_PERMISSION; + flags |= HYPERAIO_APP_PERMISSION; } return flags; } int32_t HyperAio::CtxInit(ProcessIoResultCallBack *callBack) { - HyperAioTrace trace("CtxInit"); + HyperaioTrace trace("CtxInit"); if (callBack == nullptr) { HILOGE("callBack is null"); return -EINVAL; @@ -87,7 +87,7 @@ struct io_uring_sqe* HyperAio::GetSqeWithRetry(struct io_uring *ring) int32_t HyperAio::StartOpenReqs(OpenReqs *req) { - HyperAioTrace trace("StartOpenReqs" + std::to_string(req->reqNum)); + HyperaioTrace trace("StartOpenReqs" + std::to_string(req->reqNum)); if (req == nullptr || req->reqs == nullptr) { return -EINVAL; } @@ -129,7 +129,7 @@ int32_t HyperAio::StartOpenReqs(OpenReqs *req) int32_t HyperAio::StartReadReqs(ReadReqs *req) { - HyperAioTrace trace("StartReadReqs" + std::to_string(req->reqNum)); + HyperaioTrace trace("StartReadReqs" + std::to_string(req->reqNum)); if (req == nullptr || req->reqs == nullptr) { return -EINVAL; } @@ -170,7 +170,7 @@ int32_t HyperAio::StartReadReqs(ReadReqs *req) int32_t HyperAio::StartCancelReqs(CancelReqs *req) { - HyperAioTrace trace("StartCancelReqs" + std::to_string(req->reqNum)); + HyperaioTrace trace("StartCancelReqs" + std::to_string(req->reqNum)); if (req == nullptr || req->reqs == nullptr) { return -EINVAL; } diff --git a/interfaces/kits/hyperaio/src/hyperaio_trace.cpp b/interfaces/kits/hyperaio/src/hyperaio_trace.cpp index 9cc501bee..b51c24b34 100644 --- a/interfaces/kits/hyperaio/src/hyperaio_trace.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio_trace.cpp @@ -21,14 +21,14 @@ namespace HyperAio { HyperaioTrace::HyperaioTrace(const std::string& value, bool isShowLog) : value_(value) { if (isShowLog) { - HILOGEI("%{public}s", value_.c_str()); + HILOGI("%{public}s", value_.c_str()); } StartTrace(HITRACE_TAG_OHOS, "[HyperAio]" + value); } void HyperaioTrace::End() { - if(!isFinished_) { + if (!isFinished_) { FinishTrace(HITRACE_TAG_OHOS); isFinished_ = true; } -- Gitee From 197a21d4ba8d8875c52d9cfb5865372e430efe29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Fri, 23 May 2025 15:57:46 +0800 Subject: [PATCH 11/13] hyperaio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- .../test/unittest/hyperaio/hyperaio_test.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index 43569a16d..343fb0d9a 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -49,8 +49,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0000"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } result = hyperAio_->CtxInit(nullptr); @@ -71,8 +71,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0001"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } result = hyperAio_->CtxInit(&callBack); @@ -99,8 +99,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartOpenReqs_0002"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } OpenInfo openInfo = {0, O_RDWR, 0, nullptr, userData}; @@ -123,8 +123,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0000"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } result = hyperAio_->CtxInit(nullptr); @@ -145,8 +145,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0001"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } result = hyperAio_->CtxInit(&callBack); @@ -173,8 +173,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartReadReqs_0002"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } ReadInfo readInfo = {0, len, 0, nullptr, userData}; @@ -197,8 +197,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0000"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } result = hyperAio_->CtxInit(nullptr); @@ -219,8 +219,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0001"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } result = hyperAio_->CtxInit(&callBack); @@ -247,8 +247,8 @@ namespace { GTEST_LOG_(INFO) << "HyperAioTest-begin HyperAio_StartCancelReqs_0002"; std::unique_ptr hyperAio_ = std::make_unique(); int32_t result = hyperAio_->SupportIouring(); - EXPECT_EQ((result & IOURING_APP_PERMISSION) == 0, true); - if ((result & IOURING_APP_PERMISSION) == 0) { + EXPECT_EQ((result & HYPERAIO_APP_PERMISSION) == 0, true); + if ((result & HYPERAIO_APP_PERMISSION) == 0) { return; } CancelInfo cancelInfo = {userData, 0}; -- Gitee From 6ca24087bcbdf3f485e54751e35147b7535f99ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 25 May 2025 14:58:24 +0800 Subject: [PATCH 12/13] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- bundle.json | 3 ++- file_api.gni | 1 + interfaces/kits/hyperaio/BUILD.gn | 15 ++++++++++----- interfaces/kits/hyperaio/include/hyperaio.h | 1 + interfaces/test/unittest/BUILD.gn | 4 +++- interfaces/test/unittest/hyperaio/BUILD.gn | 4 +++- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/bundle.json b/bundle.json index 5fdf841c8..374976e19 100644 --- a/bundle.json +++ b/bundle.json @@ -20,7 +20,8 @@ "SystemCapability.FileManagement.File.Environment.FolderObtain" ], "features": [ - "file_api_read_optimize" + "file_api_read_optimize", + "file_api_feature_inner_hyperaio" ], "adapted_system_type": [ "mini","small","standard" ], "rom": "4096KB", diff --git a/file_api.gni b/file_api.gni index 16a290623..e002ea9f6 100644 --- a/file_api.gni +++ b/file_api.gni @@ -26,4 +26,5 @@ use_mingw_win = "${current_os}_${current_cpu}" == "mingw_x86_64" declare_args() { file_api_read_optimize = false + file_api_feature_inner_hyperaio = false } diff --git a/interfaces/kits/hyperaio/BUILD.gn b/interfaces/kits/hyperaio/BUILD.gn index 8baa592f4..c4cfa01d5 100644 --- a/interfaces/kits/hyperaio/BUILD.gn +++ b/interfaces/kits/hyperaio/BUILD.gn @@ -15,9 +15,10 @@ import("//build/ohos.gni") import("//foundation/filemanagement/file_api/file_api.gni") group("group_hyperaio") { - deps = [ - ":HyperAio", - ] + deps = [ ] + if (file_api_feature_inner_hyperaio) { + deps += [ ":HyperAio" ] + } } config("hyperaio_config") { @@ -59,13 +60,17 @@ ohos_shared_library("HyperAio") { external_deps = [ "c_utils:utils", "liburing:liburing", - "hilog:libhilog", "ipc:ipc_core", "access_token:libaccesstoken_sdk", "hitrace:hitrace_meter", ] - + if (file_api_feature_inner_hyperaio) { + external_deps += [ "hilog:libhilog" ] + } install_images = [ "system" ] part_name = "file_api" subsystem_name = "filemanagement" + if (file_api_feature_inner_hyperaio) { + defines = [ "HYPERAIO_USE_LIBURING" ] + } } \ No newline at end of file diff --git a/interfaces/kits/hyperaio/include/hyperaio.h b/interfaces/kits/hyperaio/include/hyperaio.h index b950ddc86..649d4092a 100644 --- a/interfaces/kits/hyperaio/include/hyperaio.h +++ b/interfaces/kits/hyperaio/include/hyperaio.h @@ -18,6 +18,7 @@ #include #include +#ifdef HYPERAIO_USE_LIBURING #include "liburing.h" namespace OHOS { diff --git a/interfaces/test/unittest/BUILD.gn b/interfaces/test/unittest/BUILD.gn index b14741b2d..facee8dce 100644 --- a/interfaces/test/unittest/BUILD.gn +++ b/interfaces/test/unittest/BUILD.gn @@ -18,6 +18,8 @@ group("unittest") { "filemgmt_libn_test:filemgmt_libn_test", "remote_uri:remote_uri_test", "task_signal:task_signal_test", - "hyperaio:hyperaio_test" ] + if (file_api_feature_inner_hyperaio) { + deps += [ "hyperaio:hyperaio_test" ] + } } diff --git a/interfaces/test/unittest/hyperaio/BUILD.gn b/interfaces/test/unittest/hyperaio/BUILD.gn index 0a7a58c87..fafad4b90 100644 --- a/interfaces/test/unittest/hyperaio/BUILD.gn +++ b/interfaces/test/unittest/hyperaio/BUILD.gn @@ -36,6 +36,8 @@ ohos_unittest("hyperaio_test") { "c_utils:utilsbase", "ipc:ipc_core", "googletest:gtest_main", - "liburing:liburing", ] + if (file_api_feature_inner_hyperaio) { + deps += [ "liburing:liburing" ] + } } -- Gitee From e3f9c67e4f4ff12b0e255aaab76d5d945ca218d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=AB=E5=BF=B5?= Date: Sun, 25 May 2025 15:10:05 +0800 Subject: [PATCH 13/13] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 别念 --- interfaces/kits/hyperaio/include/hyperaio.h | 6 ++-- interfaces/kits/hyperaio/src/hyperaio.cpp | 28 +++++++++++++++++++ .../test/unittest/hyperaio/hyperaio_test.cpp | 6 ++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/hyperaio/include/hyperaio.h b/interfaces/kits/hyperaio/include/hyperaio.h index 649d4092a..9977b8c16 100644 --- a/interfaces/kits/hyperaio/include/hyperaio.h +++ b/interfaces/kits/hyperaio/include/hyperaio.h @@ -20,7 +20,7 @@ #include #ifdef HYPERAIO_USE_LIBURING #include "liburing.h" - +#endif namespace OHOS { namespace HyperAio { #define HYPERAIO_APP_PERMISSION (1U << 0) @@ -85,13 +85,15 @@ public: int32_t StartCancelReqs(CancelReqs *req); int32_t DestroyCtx(); private: - io_uring uring_; ProcessIoResultCallBack ioResultCallBack_ = nullptr; +#ifdef HYPERAIO_USE_LIBURING + io_uring uring_; std::thread harvestThread_; std::atomic stopThread_; std::atomic initialized_; void HarvestRes(); struct io_uring_sqe* GetSqeWithRetry(struct io_uring *ring); +#endif }; } } diff --git a/interfaces/kits/hyperaio/src/hyperaio.cpp b/interfaces/kits/hyperaio/src/hyperaio.cpp index 639fdb310..c15a62c04 100644 --- a/interfaces/kits/hyperaio/src/hyperaio.cpp +++ b/interfaces/kits/hyperaio/src/hyperaio.cpp @@ -24,6 +24,7 @@ namespace OHOS { namespace HyperAio { +#ifdef HYPERAIO_USE_LIBURING const uint32_t URING_QUEUE_SIZE = 512; const uint32_t DELAY = 20; const uint32_t BATCH_SIZE = 128; @@ -236,5 +237,32 @@ int32_t HyperAio::DestroyCtx() initialized_.store(false); return EOK; } +#else + +uint32_t HyperAio::SupportIouring() +{ + return 0; +} +int32_t HyperAio::CtxInit(ProcessIoResultCallBack *callBack) +{ + return EINVAL; +} +int32_t HyperAio::StartReadReqs(ReadReqs *req) +{ + return EINVAL; +} +int32_t HyperAio::StartOpenReqs(OpenReqs *req) +{ + return EINVAL; +} +int32_t HyperAio::StartCancelReqs(CancelReqs *req) +{ + return EINVAL; +} +int32_t HyperAio::DestroyCtx() +{ + return EINVAL; +} +#endif } } \ No newline at end of file diff --git a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp index 343fb0d9a..fd3cb8f8c 100644 --- a/interfaces/test/unittest/hyperaio/hyperaio_test.cpp +++ b/interfaces/test/unittest/hyperaio/hyperaio_test.cpp @@ -23,8 +23,6 @@ namespace { using namespace std; using namespace OHOS::HyperAio; - const uint64_t userData = 12345; - const uint32_t len = 1024; class HyperAioTest : public testing::Test { public: static void SetUpTestCase(void) {}; @@ -32,6 +30,9 @@ namespace { void SetUp() {}; void TearDown() {}; }; +#ifdef HYPERAIO_USE_LIBURING + const uint64_t userData = 12345; + const uint32_t len = 1024; std::function)> callBack = [](std::unique_ptr response) { GTEST_LOG_(INFO) << "HyperAioTest callBack"; }; @@ -257,4 +258,5 @@ namespace { EXPECT_EQ(result, -EPERM); GTEST_LOG_(INFO) << "HyperAioTest-end HyperAio_StartCancelReqs_0002"; } +#endif } -- Gitee