diff --git a/CHANGELOG.md b/CHANGELOG.md index 096bed5f..2bfe409d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to the ZSS package will be documented in this file. +## `3.1.0` +- Enhancement: module registry (#732) + ## `3.0.0` - Enhancement: if no `zowe.logDirectory` is defined in config, logging is disabled. (#726) - Bugfix: Support cross-memory server parameters longer than 128 characters (#684) diff --git a/build/build_dynamic.sh b/build/build_dynamic.sh index 4167e749..1514ac62 100755 --- a/build/build_dynamic.sh +++ b/build/build_dynamic.sh @@ -50,12 +50,15 @@ xlc -S -M -qmetal -q64 -DSUBPOOL=132 -DMETTLE=1 -DMSGPREFIX=\"ZWE\" \ -DZISDYN_REVISION="$micro" \ -DZISDYN_VERSION_DATE_STAMP="$date_stamp" \ -DZISDYN_PLUGIN_VERSION=${DYNLINK_PLUGIN_VERSION} \ + -DLPA_LOG_DEBUG_MSG_ID=\"ZWES0100I\" \ + -DMODREG_LOG_DEBUG_MSG_ID=\"ZWES0100I\" \ -qreserved_reg=r12 \ -DRCVR_CPOOL_STATES \ -DHAVE_METALIO=1 \ -Wc,langlvl\(extc99\),arch\(8\),agg,exp,list\(\),so\(\),off,xref,roconst,longname,lp64 \ -I ${COMMON}/h -I ${ZSS}/h \ -I ${ZSS}/zis-aux/include -I ${ZSS}/zis-aux/src \ + -I /usr/include/zos \ ${ZSS}/c/zis/zisdynamic.c \ ${ZSS}/c/zis/server-api.c \ ${ZSS}/c/zis/client.c \ @@ -81,6 +84,7 @@ xlc -S -M -qmetal -q64 -DSUBPOOL=132 -DMETTLE=1 -DMSGPREFIX=\"ZWE\" \ ${COMMON}/c/logging.c \ ${COMMON}/c/lpa.c \ ${COMMON}/c/metalio.c \ + ${COMMON}/c/modreg.c \ ${COMMON}/c/nametoken.c \ ${COMMON}/c/pause-element.c \ ${COMMON}/c/pc.c \ @@ -125,6 +129,7 @@ for file in \ logging \ lpa \ metalio \ + modreg \ nametoken \ pause-element \ pc \ @@ -173,6 +178,7 @@ le.o \ logging.o \ lpa.o \ metalio.o \ +modreg.o \ nametoken.o \ pause-element.o \ pc.o \ diff --git a/build/build_zis.sh b/build/build_zis.sh index 71bf1b73..70d6e468 100755 --- a/build/build_zis.sh +++ b/build/build_zis.sh @@ -56,9 +56,12 @@ xlc -S -M -qmetal -q64 -DSUBPOOL=132 -DMETTLE=1 -DMSGPREFIX=\"ZWE\" \ -DZIS_VERSION_DATE_STAMP="$date_stamp" \ -DRADMIN_XMEM_MODE \ -DRCVR_CPOOL_STATES \ + -DLPA_LOG_DEBUG_MSG_ID=\"ZWES0100I\" \ + -DMODREG_LOG_DEBUG_MSG_ID=\"ZWES0100I\" \ -qreserved_reg=r12 \ -Wc,arch\(8\),agg,exp,list\(\),so\(\),off,xref,roconst,longname,lp64 \ -I ${COMMON}/h -I ${ZSS}/h -I ${ZSS}/zis-aux/include -I ${ZSS}/zis-aux/src \ + -I /usr/include/zos \ ${COMMON}/c/alloc.c \ ${COMMON}/c/as.c \ ${COMMON}/c/cellpool.c \ @@ -70,6 +73,7 @@ xlc -S -M -qmetal -q64 -DSUBPOOL=132 -DMETTLE=1 -DMSGPREFIX=\"ZWE\" \ ${COMMON}/c/logging.c \ ${COMMON}/c/lpa.c \ ${COMMON}/c/metalio.c \ + ${COMMON}/c/modreg.c \ ${COMMON}/c/mtlskt.c \ ${COMMON}/c/nametoken.c \ ${COMMON}/c/pause-element.c \ @@ -102,7 +106,7 @@ xlc -S -M -qmetal -q64 -DSUBPOOL=132 -DMETTLE=1 -DMSGPREFIX=\"ZWE\" \ ${ZSS}/zis-aux/src/aux-host.c for file in \ - alloc as cellpool cmutils collections crossmemory isgenq le logging lpa metalio mtlskt nametoken \ + alloc as cellpool cmutils collections crossmemory isgenq le logging lpa metalio modreg mtlskt nametoken \ pause-element pc qsam radmin recovery resmgr scheduling shrmem64 stcbase timeutls utils xlate \ zos zvt \ parm plugin server server-api service \ @@ -125,6 +129,7 @@ ld -V -b ac=1 -b rent -b case=mixed -b map -b xref -b reus \ logging.o \ lpa.o \ metalio.o \ + modreg.o \ mtlskt.o \ nametoken.o \ qsam.o \ @@ -165,6 +170,7 @@ ld -V -b ac=1 -b rent -b case=mixed -b map -b xref -b reus \ logging.o \ lpa.o \ metalio.o \ + modreg.o \ mtlskt.o \ nametoken.o \ pause-element.o \ diff --git a/c/zis/server-api.c b/c/zis/server-api.c index a8d59223..2910d466 100644 --- a/c/zis/server-api.c +++ b/c/zis/server-api.c @@ -31,6 +31,10 @@ _Bool zisIsLPADevModeOn(const ZISContext *context) { return (context->cmsFlags & devFlags) || ZIS_LPA_DEV_MODE; } +_Bool zisIsModregOn(const ZISContext *context) { + return context->cmsFlags & CMS_SERVER_FLAG_USE_MODREG; +} + void zisGetServerVersion(int *major, int *minor, int *revision) { *major = -1; *minor = -1; diff --git a/c/zis/server.c b/c/zis/server.c index 31744d26..a019d3d2 100644 --- a/c/zis/server.c +++ b/c/zis/server.c @@ -32,6 +32,7 @@ #include "stcbase.h" #include "utils.h" #include "recovery.h" +#include "modreg.h" #include "zis/message.h" #include "zis/parm.h" @@ -82,6 +83,9 @@ See details in the ZSS Cross Memory Server installation guide #define ZIS_PARM_DEV_MODE_LPA CMS_PROD_ID".DEV_MODE.LPA" #define ZIS_PARM_DEV_MODE_ON "YES" +#define ZIS_PARM_MODREG CMS_PROD_ID".MODULE_REGISTRY" + #define ZIS_PARM_MODREG_OFF "NO" + #define ZIS_PARMLIB_PARM_SERVER_NAME CMS_PROD_ID".NAME" #define ZIS_DYN_LINKAGE_PLUGIN_MOD_SUFFIX "ISDL" @@ -676,18 +680,49 @@ static int relocatePluginToLPAIfNeeded(ZISContext *context, /* Check if LPA, and load if needed */ if (lpaNeeded) { + const char *status = "n/a"; + if (!lpaPresent) { EightCharString ddname = {"STEPLIB "}; - int lpaRSN = 0; - int lpaRC = lpaAdd(&anchor->moduleInfo, &ddname, &moduleName, &lpaRSN); - if (lpaRC != 0) { - zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_SEVERE, ZIS_LOG_LPA_FAILURE_MSG, - "ADD", anchor->moduleInfo.inputInfo.name, lpaRC, lpaRSN); - return RC_ZIS_ERROR; + + if (zisIsModregOn(context) && !zisIsLPADevModeOn(context)) { + uint64_t modregRSN; + int modregRC = modregRegister(ddname, moduleName, &anchor->moduleInfo, + &modregRSN); + if (modregRC == RC_MODREG_OK) { + status = "new instance added to registry"; + lpaPresent = true; + } else if (modregRC == RC_MODREG_ALREADY_REGISTERED) { + status = "existing instance reused from registry"; + lpaPresent = true; + } else if (modregRC == RC_MODREG_MARK_MISSING) { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, + ZIS_LOG_MODREG_NO_MARK_MSG, moduleName.text); + } else { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_SEVERE, + ZIS_LOG_MODREG_FAILURE_MSG, moduleName.text, + modregRC, modregRSN); + return RC_ZIS_ERROR; + } + } + + if (!lpaPresent) { + int lpaRSN = 0; + int lpaRC = lpaAdd(&anchor->moduleInfo, &ddname, &moduleName, &lpaRSN); + if (lpaRC == 0) { + status = "own instance loaded to LPA"; + } else { + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_SEVERE, + ZIS_LOG_LPA_FAILURE_MSG, + "ADD", moduleName.text, lpaRC, lpaRSN); + return RC_ZIS_ERROR; + } } anchor->flags |= ZIS_PLUGIN_ANCHOR_FLAG_LPA; + } else { + status = "previously added/loaded instance reused"; } /* Invoke EP to get relocated services */ @@ -699,6 +734,16 @@ static int relocatePluginToLPAIfNeeded(ZISContext *context, *pluginAddr = getPluginDescriptor(); + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, + ZIS_LOG_MODULE_STATUS_MSG" (%p)", moduleName.text, status, + lpaInfo->outputInfo.stuff.successInfo.loadPointAddr); + + } else { + + zowelog(NULL, LOG_COMP_ID_CMS, ZOWE_LOG_INFO, + ZIS_LOG_MODULE_STATUS_MSG, moduleName.text, + "private storage instance used"); + } return RC_ZIS_OK; @@ -1443,7 +1488,7 @@ static int loadConfig(ZISContext *context, static int getCMSConfigFlags(const ZISParmSet *zisParms) { - int flags = CMS_SERVER_FLAG_NONE; + int flags = CMS_SERVER_FLAG_USE_MODREG; const char *coldStartValue = zisGetParmValue(zisParms, ZIS_PARM_COLD_START); if (coldStartValue && strlen(coldStartValue) == 0) { @@ -1475,6 +1520,11 @@ static int getCMSConfigFlags(const ZISParmSet *zisParms) { flags |= CMS_SERVER_FLAG_RESET_LOOKUP; } + const char *modregMode = zisGetParmValue(zisParms, ZIS_PARM_MODREG); + if (modregMode && !strcmp(modregMode, ZIS_PARM_MODREG_OFF)) { + flags &= ~CMS_SERVER_FLAG_USE_MODREG; + } + return flags; } diff --git a/c/zis/stubinit.c b/c/zis/stubinit.c index ee83deb3..c8123800 100644 --- a/c/zis/stubinit.c +++ b/c/zis/stubinit.c @@ -12,6 +12,7 @@ stubVector[ZIS_STUB_ZISDYNPV] = (void*)zisdynGetPluginVersion; stubVector[ZIS_STUB_ZISGVRSN] = (void*)zisGetServerVersion; stubVector[ZIS_STUB_ZISLPADV] = (void*)zisIsLPADevModeOn; + stubVector[ZIS_STUB_ZISMDREG] = (void*)zisIsModregOn; stubVector[ZIS_STUB_ZISCSRVC] = (void*)zisCallService; stubVector[ZIS_STUB_ZISCUSVC] = (void*)zisCallServiceUnchecked; stubVector[ZIS_STUB_ZISCVSVC] = (void*)zisCallVersionedService; @@ -558,6 +559,7 @@ stubVector[ZIS_STUB_ZVTFENTR] = (void*)zvtFreeEntry; stubVector[ZIS_STUB_ZVTGXMLR] = (void*)zvtGetCMSLookupRoutineAnchor; stubVector[ZIS_STUB_ZVTSXMLR] = (void*)zvtSetCMSLookupRoutineAnchor; + stubVector[ZIS_STUB_MODRRGST] = (void*)modregRegister; /* This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies diff --git a/c/zis/zisdynamic.c b/c/zis/zisdynamic.c index 4c933f2d..600e94c1 100644 --- a/c/zis/zisdynamic.c +++ b/c/zis/zisdynamic.c @@ -31,6 +31,7 @@ #include "logging.h" #include "lpa.h" #include "metalio.h" +#include "modreg.h" #include "nametoken.h" #include "pause-element.h" #include "pc.h" @@ -423,6 +424,8 @@ static int verifyZISVersion(void) { ZISPlugin *getPluginDescriptor(void) { + MODREG_MARK_MODULE(); + if (verifyZISVersion() != 0) { return NULL; } diff --git a/deps/zowe-common-c b/deps/zowe-common-c index d5372ea3..5fc78742 160000 --- a/deps/zowe-common-c +++ b/deps/zowe-common-c @@ -1 +1 @@ -Subproject commit d5372ea381853cd5ed95a141c7a9b0b0d7cbf271 +Subproject commit 5fc7874238a2aebe6a476d628868cc03e8edb48e diff --git a/h/zis/message.h b/h/zis/message.h index 277a90f4..ebe0f2ca 100644 --- a/h/zis/message.h +++ b/h/zis/message.h @@ -116,6 +116,18 @@ #define ZIS_LOG_CXMS_MOD_NAME_FAILED_MSG_TEXT "ZSS Cross-Memory server module member name not determined, RC = %d" #define ZIS_LOG_CXMS_MOD_NAME_FAILED_MSG ZIS_LOG_CXMS_MOD_NAME_FAILED_MSG_ID" "ZIS_LOG_CXMS_MOD_NAME_FAILED_MSG_TEXT +#define ZIS_LOG_MODULE_STATUS_MSG_ID ZIS_MSG_PRFX"0022I" +#define ZIS_LOG_MODULE_STATUS_MSG_TEXT "Module %-8.8s status: %s" +#define ZIS_LOG_MODULE_STATUS_MSG ZIS_LOG_MODULE_STATUS_MSG_ID" "ZIS_LOG_MODULE_STATUS_MSG_TEXT + +#define ZIS_LOG_MODREG_NO_MARK_MSG_ID ZIS_MSG_PRFX"0023I" +#define ZIS_LOG_MODREG_NO_MARK_MSG_TEXT "Module %-8.8s not eligible for registry, proceeding with LPA ADD" +#define ZIS_LOG_MODREG_NO_MARK_MSG ZIS_LOG_MODREG_NO_MARK_MSG_ID" "ZIS_LOG_MODREG_NO_MARK_MSG_TEXT + +#define ZIS_LOG_MODREG_FAILURE_MSG_ID ZIS_MSG_PRFX"0024E" +#define ZIS_LOG_MODREG_FAILURE_MSG_TEXT "Module %-8.8s not registered, RC = %d, RSN = 0x%016llX" +#define ZIS_LOG_MODREG_FAILURE_MSG ZIS_LOG_MODREG_FAILURE_MSG_ID" "ZIS_LOG_MODREG_FAILURE_MSG_TEXT + /* ZIS AUX messages */ #define ZISAUX_LOG_STARTUP_MSG_ID ZIS_MSG_PRFX"0050I" diff --git a/h/zis/server-api.h b/h/zis/server-api.h index d0fb0749..8178dd57 100644 --- a/h/zis/server-api.h +++ b/h/zis/server-api.h @@ -18,6 +18,7 @@ #pragma map(zisGetServerVersion, "ZISGVRSN") #pragma map(zisIsLPADevModeOn, "ZISLPADV") +#pragma map(zisIsModregOn, "ZISMDREG") /** * Get the version of ZIS. In case of failure, all the results are set to -1. @@ -36,6 +37,13 @@ struct ZISContext_tag; */ _Bool zisIsLPADevModeOn(const struct ZISContext_tag *context); +/** + * Check if the module registry is enabled for ZIS. + * @param[in] context The server context. + * @return @c true if on, otherwise @c false. + */ +_Bool zisIsModregOn(const struct ZISContext_tag *context); + #endif /* ZIS_SERVER_API_H_ */ /* diff --git a/h/zis/zisstubs.h b/h/zis/zisstubs.h index 449ae7b9..9aef5819 100644 --- a/h/zis/zisstubs.h +++ b/h/zis/zisstubs.h @@ -20,7 +20,7 @@ FULL BACKWARD COMPATIBILITY MUST BE MAINTAINED */ -#define ZIS_STUBS_VERSION 4 +#define ZIS_STUBS_VERSION 5 /* How does a user check for compatibility? @@ -48,6 +48,7 @@ #define ZIS_STUB_ZISDYNPV 2 /* zisdynGetPluginVersion mapped */ #define ZIS_STUB_ZISGVRSN 3 /* zisGetServerVersion mapped */ #define ZIS_STUB_ZISLPADV 4 /* zisIsLPADevModeOn mapped */ +#define ZIS_STUB_ZISMDREG 5 /* zisIsModregOn mapped */ /* zis/client, 50-79 */ #define ZIS_STUB_ZISCSRVC 50 /* zisCallService */ @@ -693,6 +694,9 @@ #define ZIS_STUB_ZVTGXMLR 904 /* zvtGetCMSLookupRoutineAnchor mapped */ #define ZIS_STUB_ZVTSXMLR 905 /* zvtSetCMSLookupRoutineAnchor mapped */ +/* modreg, 915-920 */ +#define ZIS_STUB_MODRRGST 915 /* modregRegister mapped */ + #endif /* ZIS_ZISSTUBS_H_ */ /* diff --git a/samplib/zis/ZWESIP00 b/samplib/zis/ZWESIP00 index f1f600ca..945beda2 100644 --- a/samplib/zis/ZWESIP00 +++ b/samplib/zis/ZWESIP00 @@ -53,7 +53,13 @@ //* AT START UP. THIS MODE MUST NEVER BE USED IN PRODUCTION */ //* AS IT MAY AFFECT THE CALLERS OF THE CROSS-MEMORY SERVER. */ //* USE THIS MODE TO DECREASE THE MEMORY FOOTPRINT DURING */ -//* DEVELOPMENT. */ +//* DEVELOPMENT. ADDITIONALLY, THIS MODE WILL DISABLE THE */ +//* MODULE REGISTRY FEATURE BECAUSE ZIS CANNOT REMOVE SHARED */ +//* MODULE FROM LPA. */ +//* MODULE_REGISTRY - MODULE REGISTRY MODE. DEFAULT IS YES. IF */ +//* SET TO NO, DISABLES THE MODULE REGISTRY FEATURE, SO THAT */ +//* ZIS WILL ALWAYS USE ITS OWN INSTANCES OF LOAD MODULES IN */ +//* LPA. */ //* */ //********************************************************************/