Skip to content

Commit

Permalink
Merge pull request #732 from zowe/feature/module-registry
Browse files Browse the repository at this point in the history
Utilize the module registry
  • Loading branch information
JoeNemo authored Oct 30, 2024
2 parents 0e674cb + a7bfee6 commit 940ad1a
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions build/build_dynamic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -125,6 +129,7 @@ for file in \
logging \
lpa \
metalio \
modreg \
nametoken \
pause-element \
pc \
Expand Down Expand Up @@ -173,6 +178,7 @@ le.o \
logging.o \
lpa.o \
metalio.o \
modreg.o \
nametoken.o \
pause-element.o \
pc.o \
Expand Down
8 changes: 7 additions & 1 deletion build/build_zis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
4 changes: 4 additions & 0 deletions c/zis/server-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
64 changes: 57 additions & 7 deletions c/zis/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "stcbase.h"
#include "utils.h"
#include "recovery.h"
#include "modreg.h"

#include "zis/message.h"
#include "zis/parm.h"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions c/zis/stubinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions c/zis/zisdynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -423,6 +424,8 @@ static int verifyZISVersion(void) {

ZISPlugin *getPluginDescriptor(void) {

MODREG_MARK_MODULE();

if (verifyZISVersion() != 0) {
return NULL;
}
Expand Down
12 changes: 12 additions & 0 deletions h/zis/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions h/zis/server-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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_ */

/*
Expand Down
6 changes: 5 additions & 1 deletion h/zis/zisstubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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_ */

/*
Expand Down
8 changes: 7 additions & 1 deletion samplib/zis/ZWESIP00
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
//* */
//********************************************************************/

Expand Down

0 comments on commit 940ad1a

Please sign in to comment.