From 328f84eebd762bab57b96edcba0c2f711f7740fb Mon Sep 17 00:00:00 2001 From: 15722902552 Date: Tue, 14 Feb 2023 15:20:33 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E9=9A=90=E6=82=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/dss_volume.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/dss_volume.c b/src/common/dss_volume.c index 683f885..51035ec 100644 --- a/src/common/dss_volume.c +++ b/src/common/dss_volume.c @@ -553,6 +553,7 @@ status_t dss_read_volume(dss_volume_t *volume, int64 offset, void *buf, int32 si total_size = 0; do { + curr_size = 0; #ifdef WIN32 ret = dss_try_read_volume(volume, (char *)buf + total_size, size - total_size, &curr_size); #else @@ -565,6 +566,12 @@ status_t dss_read_volume(dss_volume_t *volume, int64 offset, void *buf, int32 si return CM_ERROR; } + if ((curr_size == 0) && (total_size < size)) { + LOG_RUN_ERR("Read volume %s size error, begin:%d, volume id:%u, size:%d, offset:%lld.", volume->name_p, + total_size, volume->id, size - total_size, offset); + return CM_ERROR; + } + total_size += curr_size; } while (total_size < size); -- Gitee From 0d6039762dee9f50125274026887506a4ec5edfc Mon Sep 17 00:00:00 2001 From: jihanyu <1136733867@qq.com> Date: Sat, 11 Feb 2023 14:32:22 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=8E=8B=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 5 ++++- build/linux/opengauss/build.sh | 3 +++ src/cmd/CMakeLists.txt | 9 +++++---- src/common/dss_log.c | 2 ++ src/interface/CMakeLists.txt | 5 +++-- src/interface/dss_api.c | 6 ++++++ src/service/CMakeLists.txt | 5 +++-- src/service/dssserver.c | 1 + 8 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0e95d8..2f47601 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,11 +135,13 @@ set(DSS_SECUREC_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/huawei_secu set(DSS_OPENSSL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/openssl/include") set(DSS_CBB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/cbb/include") set(LIBAIO_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/libaio/include") +set(ZLIB_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/zlib/include") ## lib set(SECUREC_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/huawei_security/lib") set(OPENSSL_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/openssl/lib") set(CBB_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/cbb/lib") +set(ZLIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/library/zlib/lib") ## output path set (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/output/lib) @@ -158,7 +160,7 @@ IF (ENABLE_GLOBAL_CACHE STREQUAL "ON") ENDIF() ## add source -link_directories(${LIBRARY_OUTPUT_PATH} ${SECUREC_LIB_PATH} ${CBB_LIB_PATH}) +link_directories(${LIBRARY_OUTPUT_PATH} ${SECUREC_LIB_PATH} ${ZLIB_PATH} ${CBB_LIB_PATH}) IF (ENABLE_FUZZASAN) link_directories(${DSS_FUZZ_LIB_PATH}) set(fuzz_lib "libSecodefuzz.a") @@ -166,6 +168,7 @@ ENDIF() set(vpp_libsecurec "libsecurec.a") set(3rd_libccb "libcbb.a") +set(zlib "libz.a") if (ENABLE_GLOBAL_CACHE STREQUAL "ON") set(vpp_libipsi_crypto "") diff --git a/build/linux/opengauss/build.sh b/build/linux/opengauss/build.sh index fb84cea..b6cec00 100644 --- a/build/linux/opengauss/build.sh +++ b/build/linux/opengauss/build.sh @@ -118,6 +118,7 @@ export DSS_LIBRARYS=$(pwd)/../../../library [ -d "${DSS_LIBRARYS}" ] && rm -rf ${DSS_LIBRARYS} mkdir -p $DSS_LIBRARYS/huawei_security mkdir -p $DSS_LIBRARYS/openssl +mkdir -p $DSS_LIBRARYS/zlib mkdir -p $DSS_LIBRARYS/libaio/include mkdir -p $DSS_LIBRARYS/cbb @@ -127,9 +128,11 @@ COPT_LIB_PATH=${binarylib_dir}/kernel/component cp -r $P_LIB_PATH/Huawei_Secure_C/comm/lib $DSS_LIBRARYS/huawei_security/lib cp -r $LIB_PATH/openssl/comm/lib $DSS_LIBRARYS/openssl/lib +cp -r $LIB_PATH/zlib1.2.11/comm/lib $DSS_LIBRARYS/zlib/lib cp -r $P_LIB_PATH/Huawei_Secure_C/comm/include $DSS_LIBRARYS/huawei_security/include cp -r $LIB_PATH/openssl/comm/include $DSS_LIBRARYS/openssl/include +cp -r $LIB_PATH/zlib1.2.11/comm/include $DSS_LIBRARYS/zlib/include if [ -f "/usr/include/libaio.h" ];then echo "begin cp libaio.h from /usr/include/" diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 9134ce8..eb33e4c 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -12,6 +12,7 @@ endif (ENABLE_FUZZASAN) ## other dependency include include_directories(${DSS_SECUREC_INC_PATH}) include_directories(${DSS_OPENSSL_PATH}) +include_directories(${ZLIB_INC_PATH}) include_directories(${DSS_CBB_PATH}) aux_source_directory(${DSS_COMMON_PATH} COMMON_SRC) @@ -34,17 +35,17 @@ set(COMMON_ALL_SRC ADD_EXECUTABLE(dsscmd ${COMMON_ALL_SRC}) if (ENABLE_FUZZASAN) - target_link_libraries(dsscmd dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${3rd_libccb} ${vpp_libipsi_crypto} ${fuzz_lib} -Wl,--no-whole-archive) + target_link_libraries(dsscmd dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${zlib} ${3rd_libccb} ${vpp_libipsi_crypto} ${fuzz_lib} -Wl,--no-whole-archive) else() - target_link_libraries(dsscmd dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${3rd_libccb} ${vpp_libipsi_crypto} -Wl,--no-whole-archive) + target_link_libraries(dsscmd dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${zlib} ${3rd_libccb} ${vpp_libipsi_crypto} -Wl,--no-whole-archive) endif(ENABLE_FUZZASAN) if (ENABLE_DSSTEST) add_library(dsscmd_test SHARED ${COMMON_ALL_SRC}) if (ENABLE_FUZZASAN) - target_link_libraries(dsscmd_dest dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${3rd_libccb} ${vpp_libipsi_crypto} ${fuzz_lib} -Wl,--no-whole-archive) + target_link_libraries(dsscmd_dest dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${zlib} ${3rd_libccb} ${vpp_libipsi_crypto} ${fuzz_lib} -Wl,--no-whole-archive) else() - target_link_libraries(dsscmd_test dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${3rd_libccb} ${vpp_libipsi_crypto} -Wl,--no-whole-archive) + target_link_libraries(dsscmd_test dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${zlib} ${3rd_libccb} ${vpp_libipsi_crypto} -Wl,--no-whole-archive) endif(ENABLE_FUZZASAN) endif(ENABLE_DSSTEST) diff --git a/src/common/dss_log.c b/src/common/dss_log.c index b5294c7..2514842 100644 --- a/src/common/dss_log.c +++ b/src/common/dss_log.c @@ -228,6 +228,7 @@ status_t dss_init_loggers(dss_config_t *inst_cfg, dss_log_def_t *log_def, uint32 char file_name[CM_MAX_PATH_LEN]; log_param_t *log_param = cm_log_param_instance(); log_param->log_level = 0; + log_param->log_compressed = DSS_TRUE; if (dss_init_log_home(inst_cfg, log_param) != CM_SUCCESS) { return CM_ERROR; @@ -249,6 +250,7 @@ status_t dss_init_loggers(dss_config_t *inst_cfg, dss_log_def_t *log_def, uint32 if (cm_log_init(log_def[i].log_id, file_name) != CM_SUCCESS) { return CM_ERROR; } + cm_log_open_compress(log_def[i].log_id, DSS_TRUE); } log_param->log_instance_startup = CM_TRUE; cm_init_error_handler(cm_set_log_error); diff --git a/src/interface/CMakeLists.txt b/src/interface/CMakeLists.txt index 8f9c5d1..92d85eb 100644 --- a/src/interface/CMakeLists.txt +++ b/src/interface/CMakeLists.txt @@ -12,6 +12,7 @@ endif(ENABLE_FUZZASAN) ## other dependency include include_directories(${DSS_SECUREC_INC_PATH}) include_directories(${DSS_OPENSSL_PATH}) +include_directories(${ZLIB_INC_PATH}) include_directories(${LIBAIO_INC_PATH}) include_directories(${DSS_CBB_PATH}) @@ -39,8 +40,8 @@ set(COMMON_ALL_SRC add_library(dssapi SHARED ${COMMON_ALL_SRC}) if (ENABLE_FUZZASAN) - target_link_libraries(dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${fuzz_lib} -Wl,-Bstatic ${3rd_libccb} -Wl,-Bdynamic ${vpp_libipsi_crypto} -Wl,--no-whole-archive) + target_link_libraries(dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${zlib} ${fuzz_lib} -Wl,-Bstatic ${3rd_libccb} -Wl,-Bdynamic ${vpp_libipsi_crypto} -Wl,--no-whole-archive) else() - target_link_libraries(dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} -Wl,-Bstatic ${3rd_libccb} -Wl,-Bdynamic ${vpp_libipsi_crypto} -Wl,--no-whole-archive) + target_link_libraries(dssapi pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${zlib} -Wl,-Bstatic ${3rd_libccb} -Wl,-Bdynamic ${vpp_libipsi_crypto} -Wl,--no-whole-archive) endif(ENABLE_FUZZASAN) diff --git a/src/interface/dss_api.c b/src/interface/dss_api.c index 3890e7c..1936546 100644 --- a/src/interface/dss_api.c +++ b/src/interface/dss_api.c @@ -727,6 +727,7 @@ static int32 init_single_logger(log_param_t *log_param, log_type_t log_id) char file_name[CM_FILE_NAME_BUFFER_SIZE] = {'\0'}; CM_RETURN_IFERR(init_single_logger_core(log_param, log_id, file_name, CM_FILE_NAME_BUFFER_SIZE)); (void)cm_log_init(log_id, (const char *)file_name); + cm_log_open_compress(log_id, DSS_TRUE); return DSS_SUCCESS; } @@ -763,6 +764,11 @@ int32 dss_init_logger(char *log_home, unsigned int log_level, unsigned int log_b log_param->audit_backup_file_count = log_backup_file_count; log_param->max_log_file_size = log_max_file_size; log_param->max_audit_file_size = log_max_file_size; + log_param->log_compressed = DSS_TRUE; + log_param->log_compress_buf = malloc(CM_LOG_COMPRESS_BUFSIZE); + if (log_param->log_compress_buf == NULL) { + return ERR_DSS_INIT_LOGGER_FAILED; + } cm_log_set_file_permissions(600); cm_log_set_path_permissions(700); (void)cm_set_log_module_name("DSS", sizeof("DSS")); diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt index 449a657..facee20 100644 --- a/src/service/CMakeLists.txt +++ b/src/service/CMakeLists.txt @@ -12,6 +12,7 @@ endif(ENABLE_FUZZASAN) include_directories(${DSS_SECUREC_INC_PATH}) include_directories(${DSS_OPENSSL_PATH}) include_directories(${DSS_CBB_PATH}) +include_directories(${ZLIB_INC_PATH}) aux_source_directory(${DSS_COMMON_PATH} COMMON_SRC) aux_source_directory(${DSS_SER_PATH} SER_SRC) @@ -29,7 +30,7 @@ set(COMMON_ALL_SRC ADD_EXECUTABLE(dssserver ${COMMON_ALL_SRC}) if (ENABLE_FUZZASAN) - target_link_libraries(dssserver pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${3rd_libccb} ${vpp_libipsi_crypto} ${fuzz_lib} -Wl,--no-whole-archive) + target_link_libraries(dssserver pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${3rd_libccb} ${zlib} ${vpp_libipsi_crypto} ${fuzz_lib} -Wl,--no-whole-archive) else() - target_link_libraries(dssserver pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${3rd_libccb} ${vpp_libipsi_crypto} -Wl,--no-whole-archive) + target_link_libraries(dssserver pthread dl rt -Wl,--whole-archive ${vpp_libsecurec} ${3rd_libssl} ${3rd_libccb} ${zlib} ${vpp_libipsi_crypto} -Wl,--no-whole-archive) endif(ENABLE_FUZZASAN) diff --git a/src/service/dssserver.c b/src/service/dssserver.c index 474ab80..35750e0 100644 --- a/src/service/dssserver.c +++ b/src/service/dssserver.c @@ -103,6 +103,7 @@ static void dss_clean_server() (void)cm_unlock_fd(g_dss_instance.lock_fd); cm_close_file(g_dss_instance.lock_fd); } + CM_FREE_PTR(cm_log_param_instance()->log_compress_buf); } static void handle_main_wait(void) -- Gitee From b1b6d3da28ef114c14e6b0a04a5e3475da67cc05 Mon Sep 17 00:00:00 2001 From: xiaoxiao <1761856293@qq.com> Date: Thu, 16 Feb 2023 19:36:43 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9reg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cmd/dsscmd_inq.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cmd/dsscmd_inq.c b/src/cmd/dsscmd_inq.c index 0714951..63ba4eb 100644 --- a/src/cmd/dsscmd_inq.c +++ b/src/cmd/dsscmd_inq.c @@ -32,7 +32,7 @@ extern "C" { static void print_dev_info(ptlist_t *devs) { - printf("%-20s%-20s%-20s%-20s%-15s%-20s\n", "Dev", "Vendor", "Model", "ArraySN", "LUNID", "LUNWWN"); + printf("%-20s %-20s %-20s %-20s %-15s %-20s\n", "Dev", "Vendor", "Model", "ArraySN", "LUNID", "LUNWWN"); uint32 i; dev_info_t *dev_info = NULL; @@ -48,7 +48,7 @@ static void print_dev_info(ptlist_t *devs) cm_str2text(dev_info->data.vendor_info.product, &text); cm_trim_text(&text); DSS_RETURN_DRIECT_IFERR(cm_text2str(&text, dev_info->data.vendor_info.product, CM_MAX_PRODUCT_LEN)); - printf("%-20s%-20s%-20s%-20s%-15d%-20s\n", dev_info->dev, dev_info->data.vendor_info.vendor, + printf("%-20s %-20s %-20s %-20s %-15d %-20s\n", dev_info->dev, dev_info->data.vendor_info.vendor, dev_info->data.vendor_info.product, dev_info->data.array_info.array_sn, dev_info->data.lun_info.lun_id, dev_info->data.lun_info.lun_wwn); } @@ -59,9 +59,9 @@ static void print_dev_info(ptlist_t *devs) static void print_reg_info_rely_resk(int64 resk) { if (resk > 0) { - printf("%-20lld", resk - 1); + printf("%-20lld ", resk - 1); } else { - printf("%-20c", '-'); + printf("%-20c ", '-'); } } @@ -75,7 +75,7 @@ static void print_reg_info_rely_key_count(iof_reg_in_t *reg_info) (void)memset_s(buff, sizeof(buff), 0, sizeof(buff)); text.len = 0; for (int32 j = 0; j < reg_info->key_count; j++) { - cm_concat_int32(&text, DSS_MAX_REKEY_BUFF, (uint32)(reg_info->reg_keys[j] - 1)); + cm_concat_int32(&text, DSS_MAX_REKEY_BUFF, (int32)(reg_info->reg_keys[j] - 1)); if (j + 1 < reg_info->key_count) { (void)cm_concat_string(&text, DSS_MAX_REKEY_BUFF, ","); } @@ -88,7 +88,7 @@ static void print_reg_info_rely_key_count(iof_reg_in_t *reg_info) static void print_reg_info(ptlist_t *regs) { - printf("%-20s%-20s%-20s%-20s\n", "Dev", "Generation", "RESKEY", "REGKEY"); + printf("%-20s %-20s %-20s %-20s\n", "Dev", "Generation", "RESKEY", "REGKEY"); uint32 i; iof_reg_in_t *reg_info = NULL; @@ -96,7 +96,7 @@ static void print_reg_info(ptlist_t *regs) for (i = 0; i < regs->count; i++) { reg_info = (iof_reg_in_t *)cm_ptlist_get(regs, i); if (reg_info != NULL) { - printf("%-20s%-20u", reg_info->dev, reg_info->generation); + printf("%-20s %-20u ", reg_info->dev, reg_info->generation); print_reg_info_rely_resk(reg_info->resk); print_reg_info_rely_key_count(reg_info); } @@ -142,6 +142,9 @@ status_t inq_regs(void) bool32 is_register(iof_reg_in_t *reg, int64 host_id, int64 *iofence_key) { for (int32 i = 0; i < reg->key_count; i++) { + if (reg->reg_keys[i] < 1 || reg->reg_keys[i] > CM_MAX_INSTANCES) { + continue; + } iofence_key[reg->reg_keys[i] - 1]++; } for (int32 i = 0; i < reg->key_count; i++) { -- Gitee From a99685ad6c0337e9ee72b4bfc901fd6f7e502ff6 Mon Sep 17 00:00:00 2001 From: zhaodu <545211984@qq.com> Date: Tue, 21 Feb 2023 10:46:08 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fix=20bug:failover=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=EF=BC=8Cdss=E8=8E=B7=E5=8F=96=E4=B8=BB=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E4=B8=BA=E6=97=A0=E6=95=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/dss_mes.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/service/dss_mes.c b/src/service/dss_mes.c index 95901e1..bb169cf 100644 --- a/src/service/dss_mes.c +++ b/src/service/dss_mes.c @@ -784,29 +784,24 @@ static status_t dss_rec_msgs(dss_session_t *session, void *buf, int32 size) lastctrl.seq = 0; lastctrl.cursize = 0; big_packets_ctrl_t ctrl; - do { status_t ret = mes_allocbuf_and_recv_data((uint16)session->id, &msg, DSS_MES_WAIT_TIMEOUT); if (ret != CM_SUCCESS) { LOG_RUN_ERR("dss server receive msg from remote node failed, result:%d.", ret); - dss_set_master_id(DSS_INVALID_ID32); return ret; } if (msg.head->size < (sizeof(mes_message_head_t) + sizeof(big_packets_ctrl_t))) { LOG_RUN_ERR("dss server load disk from remote node failed, msg len(%d) error.", msg.head->size); - dss_set_master_id(DSS_INVALID_ID32); mes_release_message_buf(&msg); return CM_ERROR; } - ctrl = *(big_packets_ctrl_t *)(msg.buffer + sizeof(mes_message_head_t)); if (dss_packets_verify(bfirst, &lastctrl, &ctrl) == CM_FALSE) { mes_release_message_buf(&msg); LOG_RUN_ERR("dss server receive msg verify failed."); return CM_ERROR; } - errno_t errcode = memcpy_s((char *)buf + ctrl.offset, ctrl.cursize, msg.buffer + sizeof(mes_message_head_t) + sizeof(big_packets_ctrl_t), ctrl.cursize); mes_release_message_buf(&msg); @@ -853,7 +848,6 @@ status_t dss_read_volume_remote(const char *vg_name, dss_volume_t *volume, int64 LOG_RUN_ERR( "The dssserver fails to send messages to the remote node, src node (%u), dst node(%u).", currid, remoteid); dss_destroy_session(session); - dss_set_master_id(DSS_INVALID_ID32); return ret; } // 3. receive msg from remote -- Gitee From 63f43009ece6887134a3d15ee85f9e3145e089a8 Mon Sep 17 00:00:00 2001 From: 15722902552 Date: Tue, 28 Feb 2023 16:06:10 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=85=83=E6=95=B0=E6=8D=AE=E6=8C=89=E9=9C=80=E5=81=9Achecksum?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/dss_alloc_unit.c | 6 +++--- src/common/dss_diskgroup.c | 18 ++++++++++-------- src/common/dss_file.c | 2 +- src/common/dss_meta_buf.c | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/common/dss_alloc_unit.c b/src/common/dss_alloc_unit.c index bad3c67..d47a823 100644 --- a/src/common/dss_alloc_unit.c +++ b/src/common/dss_alloc_unit.c @@ -301,14 +301,14 @@ status_t dss_get_core_version(dss_vg_info_item_t *item, uint64 *version) // shoud lock in caller status_t dss_load_core_ctrl(dss_vg_info_item_t *item, dss_core_ctrl_t *core) { - bool32 remote = CM_FALSE; + bool32 remote_chksum = CM_TRUE; status_t status = - dss_load_vg_ctrl_part(item, (int64)DSS_CTRL_CORE_OFFSET, core, (int32)DSS_CORE_CTRL_SIZE, &remote); + dss_load_vg_ctrl_part(item, (int64)DSS_CTRL_CORE_OFFSET, core, (int32)DSS_CORE_CTRL_SIZE, &remote_chksum); if (status != CM_SUCCESS) { return status; } - if (remote == CM_FALSE) { + if (remote_chksum == CM_FALSE) { uint32 checksum = dss_get_checksum(core, DSS_CORE_CTRL_SIZE); dss_check_checksum(checksum, core->checksum); } diff --git a/src/common/dss_diskgroup.c b/src/common/dss_diskgroup.c index e2dedf9..321f2d2 100644 --- a/src/common/dss_diskgroup.c +++ b/src/common/dss_diskgroup.c @@ -1327,7 +1327,7 @@ uint64 dss_get_vg_latch_shm_offset(dss_vg_info_item_t *vg_item) // shoud lock in caller status_t dss_load_volume_ctrl(dss_vg_info_item_t *vg_item, dss_volume_ctrl_t *volume_ctrl) { - bool32 remote = CM_FALSE; + bool32 remote = CM_TRUE; status_t status = dss_load_vg_ctrl_part( vg_item, (int64)DSS_CTRL_VOLUME_OFFSET, volume_ctrl, (int32)DSS_VOLUME_CTRL_SIZE, &remote); if (status != CM_SUCCESS) { @@ -1547,10 +1547,9 @@ bool32 dss_need_exec_local() } status_t dss_read_volume_inst( - dss_vg_info_item_t *vg_item, dss_volume_t *volume, int64 offset, void *buf, int32 size, bool32 *remote) + dss_vg_info_item_t *vg_item, dss_volume_t *volume, int64 offset, void *buf, int32 size, bool32 *remote_chksum) { status_t status = CM_ERROR; - *remote = CM_FALSE; CM_ASSERT(offset % DSS_DISK_UNIT_SIZE == 0); CM_ASSERT(size % DSS_DISK_UNIT_SIZE == 0); CM_ASSERT(((uint64)buf) % DSS_DISK_UNIT_SIZE == 0); @@ -1558,7 +1557,7 @@ status_t dss_read_volume_inst( while (dss_need_load_remote(size) == CM_TRUE && status != CM_SUCCESS) { status = remote_read_proc(vg_item->vg_name, volume, offset, buf, size); if (status != CM_SUCCESS) { - LOG_RUN_ERR("Failed to load disk(%s) data from the active node, result:%d", volume->name_p, status); + LOG_RUN_WAR("Failed to load disk(%s) data from the active node, result:%d", volume->name_p, status); if (dss_need_exec_local()) { break; } @@ -1566,14 +1565,17 @@ status_t dss_read_volume_inst( continue; } - if (dss_read_remote_checksum(buf, size) != CM_TRUE) { - LOG_RUN_ERR("Failed to load disk(%s) data from the active node, checksum error", volume->name_p); - continue; + if (*remote_chksum == CM_TRUE) { + if (dss_read_remote_checksum(buf, size) != CM_TRUE) { + LOG_RUN_WAR("Failed to load disk(%s) data from the active node, checksum error", volume->name_p); + status = CM_ERROR; + continue; + } } - *remote = CM_TRUE; return status; } + *remote_chksum = CM_FALSE; status = dss_read_volume(volume, offset, buf, size); if (status != CM_SUCCESS) { LOG_RUN_ERR("Failed to load disk(%s) data, result:%d", volume->name_p, status); diff --git a/src/common/dss_file.c b/src/common/dss_file.c index c5b78aa..c72a0ba 100644 --- a/src/common/dss_file.c +++ b/src/common/dss_file.c @@ -2154,7 +2154,7 @@ status_t dss_refresh_root_ft(dss_vg_info_item_t *vg_item, bool32 check_version, if (dss_is_readwrite() && !active_refresh) { return CM_SUCCESS; } - bool32 remote = CM_FALSE; + bool32 remote = CM_TRUE; dss_ctrl_t *dss_ctrl = vg_item->dss_ctrl; char *root = dss_ctrl->root; dss_root_ft_block_t *ft_block = (dss_root_ft_block_t *)(root); diff --git a/src/common/dss_meta_buf.c b/src/common/dss_meta_buf.c index d79f025..7e3a449 100644 --- a/src/common/dss_meta_buf.c +++ b/src/common/dss_meta_buf.c @@ -125,7 +125,7 @@ void dss_unregister_buffer_cache(dss_vg_info_item_t *vg_item, dss_block_id_t blo status_t dss_get_block_from_disk( dss_vg_info_item_t *vg_item, dss_block_id_t block_id, char *buf, int64_t offset, int32 size, bool32 calc_checksum) { - bool32 remote = CM_FALSE; + bool32 remote = calc_checksum; CM_ASSERT(block_id.volume < DSS_MAX_VOLUMES); status_t status = dss_check_read_volume(vg_item, (uint32)block_id.volume, offset, buf, size, &remote); if (status != CM_SUCCESS) { -- Gitee From 7e4840453eea16ecc5c797fbdc4cf1667faead13 Mon Sep 17 00:00:00 2001 From: zhaodu <545211984@qq.com> Date: Fri, 3 Mar 2023 10:52:54 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E8=A7=A6=E5=8F=91=E4=BA=8C=E7=BA=A7fs=5Fbl?= =?UTF-8?q?ock=E7=9A=84=E6=89=A9=E5=AE=B9=E6=97=B6=E7=9A=84=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/dss_file.c | 3 +++ src/common/dss_log.c | 1 + src/common_api/dss_api_impl.c | 19 +++++++++++++++++-- src/interface/dss_errno.h | 1 + src/service/dss_service.c | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/common/dss_file.c b/src/common/dss_file.c index c72a0ba..facf04d 100644 --- a/src/common/dss_file.c +++ b/src/common/dss_file.c @@ -3064,6 +3064,9 @@ static status_t dss_refresh_file_core(dss_vg_info_item_t *vg_item, uint64 fid, f if (node->fid != fid) { DSS_RETURN_IFERR2(CM_ERROR, LOG_DEBUG_ERR("Fid is not match,(%llu,%llu).", node->fid, fid)); } + LOG_DEBUG_INF( + "Apply refresh file:%s, curr size:%llu, refresh ft id:%llu, refresh entry id:%llu, refresh block id:%llu.", + node->name, node->size, *(uint64 *)&ftid, *(uint64 *)&(node->entry), *(uint64 *)&blockid); // check the entry and load char *block = dss_find_block_in_shm(vg_item, node->entry, DSS_BLOCK_TYPE_FS, CM_TRUE, NULL, CM_FALSE); if (!block) { diff --git a/src/common/dss_log.c b/src/common/dss_log.c index 2514842..1164ec9 100644 --- a/src/common/dss_log.c +++ b/src/common/dss_log.c @@ -98,6 +98,7 @@ const char *g_dss_error_desc[DSS_ERROR_COUNT] = { Eg:server_locator=\"UDS:UNIX_emserver.domain\"", [ERR_DSS_RECV_MSG_FAILED] = "Recv msg failed, errcode:%d, inst:%u.", [ERR_DSS_LINK_NOT_EXIST] = "The link %s of %s does not exist.", + [ERR_DSS_INVALID_ID] = "Invalid %s id : %llu.", }; static status_t dss_init_log_file(log_param_t *log_param, dss_config_t *inst_cfg) diff --git a/src/common_api/dss_api_impl.c b/src/common_api/dss_api_impl.c index 61f5cc8..5696a8b 100644 --- a/src/common_api/dss_api_impl.c +++ b/src/common_api/dss_api_impl.c @@ -109,6 +109,10 @@ status_t dss_apply_refresh_file(dss_conn_t *conn, dss_file_context_t *context, d send_pack->head->cmd = DSS_CMD_REFRESH_FILE; send_pack->head->flags = 0; + LOG_DEBUG_INF( + "Apply refresh file:%s, curr size:%llu, refresh ft id:%llu, refresh entry id:%llu, refresh block id:%llu.", + context->node->name, context->node->size, *(uint64 *)&ftid, *(uint64 *)&(context->node->entry), + *(uint64 *)&blockid); // 1. fid CM_RETURN_IFERR(dss_put_int64(send_pack, fid)); // 2. ftid @@ -1401,8 +1405,17 @@ static status_t dss_alloc_block_core( vg_item, second_block_id, DSS_BLOCK_TYPE_FS, DSS_FALSE, NULL, CM_FALSE); if ((*second_block) == NULL) { DSS_UNLOCK_VG_META_S(context->vg_item, conn->session); - LOG_RUN_ERR("Failed to find block:%llu in mem.", DSS_ID_TO_U64(second_block_id)); - return CM_ERROR; + status = dss_apply_refresh_file(conn, context, second_block_id); + DSS_RETURN_IFERR2(status, LOG_RUN_ERR("Failed to refresh second fs block.")); + DSS_LOCK_VG_META_S_RETURN_ERROR(context->vg_item, conn->session, NULL); + *second_block = (dss_fs_block_t *)dss_find_block_in_shm( + vg_item, second_block_id, DSS_BLOCK_TYPE_FS, DSS_FALSE, NULL, CM_FALSE); + if ((*second_block) == NULL) { + DSS_UNLOCK_VG_META_S(context->vg_item, conn->session); + DSS_THROW_ERROR(ERR_DSS_INVALID_ID, "fs_block", *(uint64 *)&second_block_id); + LOG_RUN_ERR("Failed to find block:%llu in mem.", DSS_ID_TO_U64(second_block_id)); + return CM_ERROR; + } } } else { *second_block = (dss_fs_block_t *)dss_find_block_in_shm( @@ -1622,6 +1635,7 @@ status_t dss_read_write_file_core(dss_rw_param_t *param, void *buf, int32 size, return CM_SUCCESS; } DSS_UNLOCK_VG_META_S(context->vg_item, conn->session); + DSS_THROW_ERROR(ERR_DSS_INVALID_ID, "au", *(uint64 *)&auid); LOG_DEBUG_ERR("Auid is invalid, volume:%u, fname:%s, fsize:%llu, written_size:%llu.", (uint32)auid.volume, node->name, node->size, node->written_size); return CM_ERROR; @@ -2406,6 +2420,7 @@ static status_t get_fd(dss_rw_param_t *param, int32 size, bool32 is_read, int *f if (auid.volume >= DSS_MAX_VOLUMES) { DSS_UNLOCK_VG_META_S(context->vg_item, conn->session); + DSS_THROW_ERROR(ERR_DSS_INVALID_ID, "au", *(uint64 *)&auid); LOG_DEBUG_ERR("Auid is invalid, volume:%u, fname:%s, fsize:%llu, written_size:%llu.", (uint32)auid.volume, node->name, node->size, node->written_size); return CM_ERROR; diff --git a/src/interface/dss_errno.h b/src/interface/dss_errno.h index 71b02ad..e8956b5 100644 --- a/src/interface/dss_errno.h +++ b/src/interface/dss_errno.h @@ -119,6 +119,7 @@ extern "C" { #define ERR_DSS_RECV_MSG_FAILED 2412 #define ERR_DSS_LINK_NOT_EXIST 2413 #define ERR_DSS_INIT_LOGGER_FAILED 2414 +#define ERR_DSS_INVALID_ID 2416 #define ERR_DSS_CEIL 2500 #ifdef __cplusplus diff --git a/src/service/dss_service.c b/src/service/dss_service.c index ad9700d..706d16c 100644 --- a/src/service/dss_service.c +++ b/src/service/dss_service.c @@ -470,7 +470,7 @@ static status_t dss_process_truncate_file(dss_session_t *session) DSS_RETURN_IF_ERROR(dss_get_int32(&session->recv_pack, (int32 *)&vgid)); DSS_RETURN_IF_ERROR(dss_set_audit_resource(session->audit_info.resource, DSS_AUDIT_MODIFY, "vg_name:%s, fid:%llu, ftid:%llu", vg_name, fid, *(uint64 *)&ftid)); - + LOG_DEBUG_INF("Truncate file ft id:%llu, offset:%lld, length:%llu", *(uint64 *)&ftid, offset, length); return dss_truncate(session, fid, ftid, offset, length, vg_name); } -- Gitee From 2a797098680a7556f04bee488e53a191d396ca1c Mon Sep 17 00:00:00 2001 From: xiaoxiao <1761856293@qq.com> Date: Sat, 4 Mar 2023 19:15:30 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=A4=BE=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cmd/dsscmd.c | 59 +++++++++++++++++++++++--------------- src/cmd/dsscmd_inq.c | 13 +++++---- src/cmd/dsscmd_inq.h | 4 +-- src/common/dss_defs.c | 5 ++++ src/common/dss_diskgroup.c | 4 --- src/common/dss_protocol.c | 2 +- src/common/dss_protocol.h | 4 +-- 7 files changed, 53 insertions(+), 38 deletions(-) diff --git a/src/cmd/dsscmd.c b/src/cmd/dsscmd.c index adc049c..00e97b7 100644 --- a/src/cmd/dsscmd.c +++ b/src/cmd/dsscmd.c @@ -194,9 +194,16 @@ static status_t cmd_check_au_size(const char *au_size_str) { uint32 min_multiple = DSS_MIN_AU_SIZE / SIZE_K(1); uint32 max_multiple = DSS_MAX_AU_SIZE / SIZE_K(1); - int64 au_size = atol(au_size_str); - if (au_size != 0 && ((au_size < min_multiple) || au_size > max_multiple)) { - DSS_PRINT_ERROR("au_size %lld is error, au_size must greater than 2MB, smaller than 64MB!\n", au_size); + uint32 au_size; + status_t ret = cm_str2uint32(au_size_str, &au_size); + if (ret != CM_SUCCESS) { + DSS_PRINT_ERROR("au_size %s is error\n", au_size_str); + return CM_ERROR; + } + + if (au_size == 0 || au_size < min_multiple || au_size > max_multiple) { + DSS_PRINT_ERROR( + "au_size %u is error, au_size cannot be 0, au_size must greater than 2MB, smaller than 64MB!\n", au_size); return CM_ERROR; } return CM_SUCCESS; @@ -332,11 +339,16 @@ static status_t cmd_check_measure_type(const char *measure) static status_t cmd_check_inst_id(const char *inst_str) { - int64 inst_id = atoll(inst_str); - if (inst_id < DSS_MIN_INST_ID || inst_id >= DSS_MAX_INST_ID) { + uint32 inst_id; + status_t ret = cm_str2uint32(inst_str, &inst_id); + if (ret != CM_SUCCESS) { DSS_PRINT_ERROR("The value of inst_id is invalid.\n"); return CM_ERROR; } + if (inst_id < DSS_MIN_INST_ID || inst_id >= DSS_MAX_INST_ID) { + DSS_PRINT_ERROR("The value of inst_id should be in [%u, %u).\n", DSS_MIN_INST_ID, DSS_MAX_INST_ID); + return CM_ERROR; + } return CM_SUCCESS; } @@ -1677,7 +1689,6 @@ static status_t kickh_proc(void) } static dss_args_t cmd_reghl_args[] = { - {'i', "inst_id", CM_TRUE, CM_TRUE, cmd_check_inst_id, NULL, NULL, 0, NULL, NULL, 0}, {'D', "DSS_HOME", CM_FALSE, CM_TRUE, cmd_check_dss_home, cmd_check_convert_dss_home, cmd_clean_check_convert, 0, NULL, NULL, 0}, }; @@ -1689,31 +1700,28 @@ static dss_args_set_t cmd_reghl_args_set = { static void reghl_help(char *prog_name) { - (void)printf("\nUsage:%s reghl <-i inst_id> [-D DSS_HOME]\n", prog_name); + (void)printf("\nUsage:%s reghl [-D DSS_HOME]\n", prog_name); (void)printf("[manage command] register host to array\n"); - (void)printf("-i/--inst_id , , the id of the host to be registered\n"); (void)printf("-D/--DSS_HOME , [optional], the run path of dssserver, default value is $DSS_HOME\n"); } static status_t reghl_proc(void) { - int64 host_id = atoll(cmd_reghl_args[DSS_ARG_IDX_0].input_args); - char *home = cmd_reghl_args[DSS_ARG_IDX_1].input_args != NULL ? cmd_reghl_args[DSS_ARG_IDX_1].input_args : NULL; + char *home = cmd_reghl_args[DSS_ARG_IDX_0].input_args != NULL ? cmd_reghl_args[DSS_ARG_IDX_0].input_args : NULL; dss_vg_info_t vg_info; errno_t errcode = memset_s(&vg_info, sizeof(vg_info), 0, sizeof(vg_info)); securec_check_ret(errcode); - status_t status = dss_reghl_core(home, host_id, &vg_info); + status_t status = dss_reghl_core(home, &vg_info); if (status != CM_SUCCESS) { - DSS_PRINT_ERROR("Failed to register host %s.\n", cmd_reghl_args[DSS_ARG_IDX_0].input_args); + DSS_PRINT_ERROR("Failed to register.\n"); } else { - DSS_PRINT_INF("Succeed to register host %s.\n", cmd_reghl_args[DSS_ARG_IDX_0].input_args); + DSS_PRINT_INF("Succeed to register.\n"); } return status; } static dss_args_t cmd_unreghl_args[] = { - {'i', "inst_id", CM_TRUE, CM_TRUE, cmd_check_inst_id, NULL, NULL, 0, NULL, NULL, 0}, {'t', "type", CM_FALSE, CM_TRUE, NULL, NULL, NULL, 0, NULL, NULL, 0}, {'D', "DSS_HOME", CM_FALSE, CM_TRUE, cmd_check_dss_home, cmd_check_convert_dss_home, cmd_clean_check_convert, 0, NULL, NULL, 0}, @@ -1726,28 +1734,33 @@ static dss_args_set_t cmd_unreghl_args_set = { static void unreghl_help(char *prog_name) { - (void)printf("\nUsage:%s unreghl <-i inst_id> [-t type] [-D DSS_HOME]\n", prog_name); + (void)printf("\nUsage:%s unreghl [-t type] [-D DSS_HOME]\n", prog_name); (void)printf("[manage command] unregister host from array\n"); - (void)printf("-i/--inst_id , , the id of the host need to unregister\n"); (void)printf("-t/--type , [optional], value is int, 0 without lock, otherwise with lock\n"); (void)printf("-D/--DSS_HOME , [optional], the run path of dssserver, default value is $DSS_HOME\n"); } static status_t unreghl_proc(void) { - int64 host_id = atoll(cmd_unreghl_args[DSS_ARG_IDX_0].input_args); - int64 type = - cmd_unreghl_args[DSS_ARG_IDX_1].input_args != NULL ? atoll(cmd_unreghl_args[DSS_ARG_IDX_1].input_args) : 1; - char *home = cmd_unreghl_args[DSS_ARG_IDX_2].input_args != NULL ? cmd_unreghl_args[DSS_ARG_IDX_2].input_args : NULL; + int32 type = 1; + status_t status; + if (cmd_unreghl_args[DSS_ARG_IDX_0].input_args != NULL) { + status = cm_str2int(cmd_unreghl_args[DSS_ARG_IDX_0].input_args, &type); + if (status != CM_SUCCESS) { + DSS_PRINT_ERROR("The value of type is invalid.\n"); + return CM_ERROR; + } + } + char *home = cmd_unreghl_args[DSS_ARG_IDX_1].input_args != NULL ? cmd_unreghl_args[DSS_ARG_IDX_1].input_args : NULL; dss_vg_info_t vg_info; errno_t errcode = memset_s(&vg_info, sizeof(vg_info), 0, sizeof(vg_info)); securec_check_ret(errcode); - status_t status = dss_unreghl_core(home, host_id, &vg_info, (type == 0) ? CM_FALSE : CM_TRUE); + status = dss_unreghl_core(home, &vg_info, (type == 0) ? CM_FALSE : CM_TRUE); if (status != CM_SUCCESS) { - DSS_PRINT_ERROR("Failed to unregister host %s.\n", cmd_unreghl_args[DSS_ARG_IDX_0].input_args); + DSS_PRINT_ERROR("Failed to unregister.\n"); } else { - DSS_PRINT_INF("Succeed to unregister host %s.\n", cmd_unreghl_args[DSS_ARG_IDX_0].input_args); + DSS_PRINT_INF("Succeed to unregister.\n"); } return status; } diff --git a/src/cmd/dsscmd_inq.c b/src/cmd/dsscmd_inq.c index 63ba4eb..d8bace2 100644 --- a/src/cmd/dsscmd_inq.c +++ b/src/cmd/dsscmd_inq.c @@ -286,7 +286,7 @@ static void dss_printf_iofence_key(int64 *iofence_key) * 3. get vg non entry info * 4. register vg non entry disk */ -status_t dss_reghl_core(const char *home, int64 host_id, dss_vg_info_t *vg_info) +status_t dss_reghl_core(const char *home, dss_vg_info_t *vg_info) { #ifndef WIN32 dss_config_t inst_cfg; @@ -294,7 +294,7 @@ status_t dss_reghl_core(const char *home, int64 host_id, dss_vg_info_t *vg_info) DSS_RETURN_IFERR2(status, DSS_PRINT_ERROR("Failed to get vg entry info when reghl, errcode is %d.\n", status)); for (uint32 i = 0; i < vg_info->group_num; i++) { - status = dss_iof_register_single(host_id, vg_info->volume_group[i].entry_path); + status = dss_iof_register_single(inst_cfg.params.inst_id, vg_info->volume_group[i].entry_path); if (status != CM_SUCCESS) { DSS_FREE_POINT(vg_info->volume_group[0].buffer_cache); DSS_PRINT_ERROR("Failed to register vg entry disk when reghl, errcode is %d.\n", status); @@ -306,7 +306,7 @@ status_t dss_reghl_core(const char *home, int64 host_id, dss_vg_info_t *vg_info) DSS_PRINT_ERROR("Failed to get vg non entry info when reghl, errcode is %d.\n", status); return status; } - status = dss_reghl_inner(&vg_info->volume_group[i], host_id); + status = dss_reghl_inner(&vg_info->volume_group[i], inst_cfg.params.inst_id); if (status != CM_SUCCESS) { DSS_FREE_POINT(vg_info->volume_group[0].buffer_cache); DSS_PRINT_ERROR("Failed to reghl, errcode is %d.\n", status); @@ -336,7 +336,7 @@ static status_t dss_unreghl_inner(dss_vg_info_item_t *item, int64 host_id) * 4. unregister vg non entry disk * 5. unregister vg entry disk */ -status_t dss_unreghl_core(const char *home, int64 host_id, dss_vg_info_t *vg_info, bool32 is_lock) +status_t dss_unreghl_core(const char *home, dss_vg_info_t *vg_info, bool32 is_lock) { #ifndef WIN32 bool32 is_reg; @@ -346,7 +346,8 @@ status_t dss_unreghl_core(const char *home, int64 host_id, dss_vg_info_t *vg_inf DSS_RETURN_IFERR2(status, DSS_PRINT_ERROR("Failed to get vg entry info, errcode is %d.\n", status)); for (uint32 i = 0; i < vg_info->group_num; i++) { - status = dss_check_volume_register(vg_info->volume_group[i].entry_path, host_id, &is_reg, iofence_key); + status = dss_check_volume_register( + vg_info->volume_group[i].entry_path, inst_cfg.params.inst_id, &is_reg, iofence_key); if (status != CM_SUCCESS) { DSS_FREE_POINT(vg_info->volume_group[0].buffer_cache); DSS_PRINT_ERROR("Failed to check volume register when unreghl, errcode is %d.\n", status); @@ -361,7 +362,7 @@ status_t dss_unreghl_core(const char *home, int64 host_id, dss_vg_info_t *vg_inf DSS_PRINT_ERROR("Failed to get vg entry info when unreghl, errcode is %d.\n", status); return status; } - status = dss_unreghl_inner(&vg_info->volume_group[i], host_id); + status = dss_unreghl_inner(&vg_info->volume_group[i], inst_cfg.params.inst_id); if (status != CM_SUCCESS) { DSS_FREE_POINT(vg_info->volume_group[0].buffer_cache); DSS_PRINT_ERROR("Failed to unreghl, errcode is %d.\n", status); diff --git a/src/cmd/dsscmd_inq.h b/src/cmd/dsscmd_inq.h index 48e4d77..5e16ec6 100644 --- a/src/cmd/dsscmd_inq.h +++ b/src/cmd/dsscmd_inq.h @@ -34,8 +34,8 @@ extern "C" { status_t inq_lun(void); status_t inq_regs(void); status_t dss_check_volume_register(char *entry_path, int64 host_id, bool32 *is_reg, int64 *iofence_key); -status_t dss_unreghl_core(const char *home, int64 host_id, dss_vg_info_t *vg_info, bool32 is_lock); -status_t dss_reghl_core(const char *home, int64 host_id, dss_vg_info_t *vg_info); +status_t dss_unreghl_core(const char *home, dss_vg_info_t *vg_info, bool32 is_lock); +status_t dss_reghl_core(const char *home, dss_vg_info_t *vg_info); status_t dss_inq_reg_core(const char *home, int64 host_id, dss_vg_info_t *vg_info); bool32 is_register(iof_reg_in_t *reg, int64 host_id, int64 *iofence_key); status_t dss_clean_vg_lock(const char *home, int64 inst_id); diff --git a/src/common/dss_defs.c b/src/common/dss_defs.c index a36bfbb..9635304 100644 --- a/src/common/dss_defs.c +++ b/src/common/dss_defs.c @@ -266,6 +266,11 @@ status_t cm_str2size(const char *str, int64 *value) status_t cm_str2int(const char *str, int32 *value) { char *err = NULL; + int ret = cm_check_is_number(str); + if (ret != CM_SUCCESS) { + CM_THROW_ERROR_EX(ERR_VALUE_ERROR, "Convert int failed, the text is not number, text = %s", str); + return CM_ERROR; + } int64 val_int64 = strtol(str, &err, CM_DEFAULT_DIGIT_RADIX); if (dss_is_err(err)) { CM_THROW_ERROR_EX(ERR_VALUE_ERROR, "Convert int failed, text = %s", str); diff --git a/src/common/dss_diskgroup.c b/src/common/dss_diskgroup.c index 00e6e43..1ce7428 100644 --- a/src/common/dss_diskgroup.c +++ b/src/common/dss_diskgroup.c @@ -1206,10 +1206,6 @@ static status_t dss_remove_volume_impl_core( if (dss_read_volume(&vg_item->volume_handle[id], 0, vol_head, (int32)DSS_ALIGN_SIZE) != CM_SUCCESS) { break; } - if (vol_head->valid_flag != DSS_CTRL_VALID_FLAG) { - DSS_THROW_ERROR(ERR_DSS_VOLUME_REMOVE_NOEXIST, volume_name, vg_item->vg_name); - break; - } vol_head->valid_flag = 0; vol_head->software_version = 0; diff --git a/src/common/dss_protocol.c b/src/common/dss_protocol.c index ccae8a9..6f24c8c 100644 --- a/src/common/dss_protocol.c +++ b/src/common/dss_protocol.c @@ -129,7 +129,7 @@ status_t dss_put_str_with_cutoff(dss_packet_t *pack, const char *str) status_t dss_write_packet(cs_pipe_t *pipe, dss_packet_t *pack) { if (pack->head->size > DSS_MAX_PACKET_SIZE) { - DSS_RETURN_IFERR2(CM_ERROR, CM_THROW_ERROR(ERR_BUFFER_OVERFLOW, "PACKET BUFFER OVERFLOW")); + DSS_RETURN_IFERR2(CM_ERROR, CM_THROW_ERROR(ERR_BUFFER_OVERFLOW, pack->head->size, DSS_MAX_PACKET_SIZE)); } status_t status = VIO_SEND_TIMED(pipe, pack->buf, pack->head->size, DSS_DEFAULT_NULL_VALUE); DSS_RETURN_IFERR2( diff --git a/src/common/dss_protocol.h b/src/common/dss_protocol.h index 9c74d47..b66c461 100644 --- a/src/common/dss_protocol.h +++ b/src/common/dss_protocol.h @@ -133,7 +133,7 @@ static inline status_t dss_put_str(dss_packet_t *pack, const char *str) size = (uint32)strlen(str); addr = DSS_WRITE_ADDR(pack); if (size >= DSS_REMAIN_SIZE(pack)) { - CM_THROW_ERROR(ERR_BUFFER_OVERFLOW, "PACKET OVERFLOW"); + CM_THROW_ERROR(ERR_BUFFER_OVERFLOW, size, DSS_REMAIN_SIZE(pack) - 1); return CM_ERROR; } if (size != 0) { @@ -182,7 +182,7 @@ static inline status_t dss_put_int32(dss_packet_t *pack, uint32 value) static inline status_t dss_pack_check_len(dss_packet_t *pack, uint32 inc) { if ((pack->offset + inc) > pack->head->size) { - CM_THROW_ERROR(ERR_BUFFER_OVERFLOW, "PACKET OVERFLOW"); + CM_THROW_ERROR(ERR_BUFFER_OVERFLOW, (pack->offset + inc), pack->head->size); return CM_ERROR; } -- Gitee