Commit 38cdffbc authored by ml's avatar ml

Added run-time embryo for Class in Class support

parent 7ed84279
......@@ -22,11 +22,9 @@
#endif
#include "rt_ini_alias.h"
#include "rt_ini_msg.h"
/* #include "rt_load.h" */
#include "rt_lst.h"
#include "rt_errh.h"
#include "rt_syi.h"
#include "rt_load.h"
#if defined OS_VMS
# define cPrio_neth 8
......@@ -88,6 +86,7 @@ static pwr_tBoolean checkSect (pwr_tStatus*, ini_sContext*, int, int);
static gdb_sObject* oidToObject (pwr_tObjid);
static pwr_tBoolean loadSectObject (pwr_tStatus*, ini_sContext*, ivol_sVolume*);
static pwr_tBoolean loadSectRbody (pwr_tStatus*, ini_sContext*, ivol_sVolume*);
static pwr_tBoolean loadSectScObject (pwr_tStatus*, ini_sContext*, ivol_sVolume*);
static pwr_tBoolean loadSectVolume (pwr_tStatus*, ini_sContext*, ivol_sVolume*);
static pwr_tBoolean readSectFile (pwr_tStatus*, ini_sContext*);
static pwr_tBoolean readSectVolRef (pwr_tStatus*, ini_sContext*);
......@@ -284,7 +283,7 @@ readSectVolRef (
#if 0
if (fseek(cp->dbs.f, 0, SEEK_SET) != 0)
if (fseek(cp->dbs.f, cp->sect.offset, SEEK_SET) != 0)
pwr_Return(NO, sts, errno_GetStatus());
......@@ -400,7 +399,7 @@ loadSectRbody (
while (i > 0) {
fseek(cp->dbs.f, nextpos, SEEK_SET);
if (!dbs_AlignedRead(sts, &ob, sizeof(ob), &cp->dbs)) {
errh_LogFatal(&cp->log, "loadSectObjbody, fread, %m", *sts);
errh_LogFatal(&cp->log, "loadSectRbody, fread, %m", *sts);
return NO;
}
......@@ -461,11 +460,11 @@ reloadSectRbody (
while (i > 0) {
if (fseek(cp->dbs.f, nextpos, SEEK_SET) != 0) {
*sts = errno_GetStatus();
errh_LogFatal(&cp->log, "reloadSectObjbody, fseek, %m", *sts);
errh_LogFatal(&cp->log, "reloadSectRbody, fseek, %m", *sts);
break;
}
if (!dbs_AlignedRead(sts, &ob, sizeof(ob), &cp->dbs)) {
errh_LogFatal(&cp->log, "reloadSectObjbody, fread, %m", *sts);
errh_LogFatal(&cp->log, "reloadSectRbody, fread, %m", *sts);
break;
}
......@@ -616,6 +615,49 @@ reloadSectObject (
}
static pwr_tBoolean
loadSectScObject (
pwr_tStatus *status,
ini_sContext *cp,
ivol_sVolume *vp
)
{
pwr_tUInt32 i;
dbs_sScObject sc;
gdb_sScObject *scp;
PDR pdrs;
pwr_dStatus(sts, status, INI__SUCCESS);
/* Read the section header by header */
if (fseek(cp->dbs.f, cp->sect.offset, SEEK_SET) != 0)
pwr_Return(NO, sts, errno_GetStatus());
for (i = 0; i < cp->sect.size; i += dbs_dAlign(sizeof(sc))) {
if (!dbs_AlignedRead(sts, &sc, sizeof(sc), &cp->dbs)) {
errh_LogFatal(&cp->log, "loadSectScObject, fread, %m", *sts);
break;
}
if (cp->dbs.file.format.m != cp->format.m) {
pdrmem_create(&pdrs, &sc, sizeof(sc), PDR_DECODE,
cp->dbs.file.format, cp->format);
if(!pdr_dbs_sScObject(&pdrs, &sc))
pwr_Return(NO, sts, INI__XDR);
}
scp = ivol_LoadScObject(sts, vp, &sc, vol_mLinkSc_load);
if (scp == NULL) {
errh_LogError(&cp->log, "Loading object %s, parent %s\n%m",
cdh_ObjidToString(NULL, sc.oid, 0), cdh_ObjidToString(NULL, sc.poid, 0), *sts);
return NO;
}
}
return YES;
}
static pwr_tBoolean
loadSectVolume (
pwr_tStatus *status,
ini_sContext *cp,
......@@ -1295,6 +1337,10 @@ ini_LoadVolume (
loadSectRbody(sts, cp, vp);
break;
default:
case dbs_eSect_scobject:
if (checkSect(sts, cp, sects, dbs_cVersionScObject))
loadSectScObject(sts, cp, vp);
break;
*sts = INI__BADSECT; /* Successful return status; means that */
break; /* we can continue after unknown sections */
}
......@@ -1305,6 +1351,8 @@ ini_LoadVolume (
} while (cp->sect.type != dbs_eSect_rbody);
/** @todo add dbs_eSect_scobject to reqmask */
reqmask = (1<<dbs_eSect_dir) | (1<<dbs_eSect_volume) | (1<<dbs_eSect_volref)
| (1<<dbs_eSect_oid) | (1<<dbs_eSect_object) | (1<<dbs_eSect_rbody);
......
......@@ -71,6 +71,8 @@ evaluateInit (
ip->objects += ip->objects / 2;
ip->objects = MAX(ip->objects, gdb_cMin_objects);
/** @todo Get information from dbs-file */
ip->scObjects = MAX(ip->scObjects, gdb_cMin_scObjects);
/* The 'pool' pool contains object headers, subscription structures and
other gdb internal structures. Make it at least 600k to begin with,
......@@ -96,6 +98,7 @@ evaluateInit (
/** @todo Better values for cached classes and volumes to the initial pool */
errh_Info("Cached classes: %d : %d bytes", ip->cclasses, ip->cclasses * (sizeof(gdb_sCclass) + 20 * sizeof(gdb_sCattribute)));
errh_Info("Cached class volumes: %d : %d bytes", ip->ccvolumes, ip->ccvolumes * sizeof(gdb_sCclassVolume));
errh_Info("Sub class objects: %d : %d bytes", ip->scObjects, ip->scObjects * sizeof(gdb_sScObject));
ip->pool_isize =
......@@ -109,7 +112,8 @@ evaluateInit (
ip->aliasServers * sizeof(gdb_sAliasServer) +
ip->subServers * sizeof(sub_sServer) +
ip->subClients * sizeof(sub_sClient) +
ip->sanServers * sizeof(san_sServer);
ip->sanServers * sizeof(san_sServer) +
ip->scObjects * sizeof(gdb_sScObject);
ip->pool_isize = MAX(ip->pool_isize, gdb_cMin_pool_isize);
ip->pool_esize = ip->pool_isize / 8;
......@@ -206,6 +210,9 @@ mapLocalDb (
gdbroot->cclass_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.cclass_ht, &gdbroot->db->h.cclass_ht, NULL, NULL);
if (gdbroot->cclass_ht == NULL) errh_Bugcheck(*sts, "initiating cached class hash table");
gdbroot->sc_ht = hash_Create(sts, gdbroot->pool, &gdbroot->h.sc_ht, &gdbroot->db->h.sc_ht, NULL, NULL);
if (gdbroot->sc_ht == NULL) errh_Bugcheck(*sts, "initiating sub class object hash table");
if (offsetof(sub_sClient, sid) != offsetof(sub_sServer, sid))
errh_Bugcheck(GDH__WEIRD, "offset id: client - server");
......@@ -215,6 +222,11 @@ mapLocalDb (
errh_Bugcheck(GDH__WEIRD, "offset htl: client - server");
if (offsetof(sub_sClient, subc_htl) != offsetof(dl_sLink, subc_htl))
errh_Bugcheck(GDH__WEIRD, "offset htl: client - dlink");
if ((offsetof(gdb_sNobject, flags) - offsetof(gdb_sNobject, cid_ll))
!= (offsetof(gdb_sScObject, flags) - offsetof(gdb_sScObject, cid_ll)))
errh_Bugcheck(GDH__WEIRD, "offset between cid_ll and flags in gdb_sNobject and gdb_sScObject");
if (gdb_mNo_isSc != gdb_mSc_isSc)
errh_Bugcheck(GDH__WEIRD, "gdb_mNo_isSubClass != gdb_mSc_isSubClass");
return gdbroot;
}
......@@ -681,6 +693,9 @@ gdb_CreateDb (
hash_Init(&gdbroot->db->h.cclass_ht, ip->cclasses, sizeof(gdb_sCclassKey), sizeof(gdb_sCclass),
offsetof(gdb_sCclass, key), offsetof(gdb_sCclass, cclass_htl), hash_eKey_memcmp);
hash_Init(&gdbroot->db->h.sc_ht, ip->scObjects, sizeof(pwr_tObjid), sizeof(gdb_sScObject),
offsetof(gdb_sScObject, sc_htl), offsetof(gdb_sCclass, cclass_htl), hash_eKey_oid);
lp = mapLocalDb(sts);
if (lp == NULL) break;
......@@ -816,6 +831,38 @@ gdb_AddObject (
return op;
}
/* Allocate an sub class object header and
initiate it. */
gdb_sScObject *
gdb_AddScObject (
pwr_tStatus *sts,
pwr_tObjid oid,
pwr_tClassId cid,
pwr_tUInt32 size,
pwr_tObjid poid,
pwr_tUInt32 aidx,
pwr_tUInt32 elem,
gdb_mSc flags
)
{
gdb_sScObject *scp;
scp = pool_Alloc(sts, gdbroot->pool, sizeof(*scp));
if (scp == NULL) return NULL;
scp->oid = oid;
scp->cid = cid;
scp->poid = poid;
scp->aidx = aidx;
scp->elem = elem;
scp->flags.m = flags.m;
scp->flags.b.isSc = 1;
scp->size = size;
return scp;
}
/* Load a volume */
gdb_sVolume *
......@@ -904,6 +951,7 @@ gdb_LoadVolume (
if (vp->l.flags.b.isNative) {
pool_Qinit(NULL, gdbroot->pool, &vp->u.n.volmo_lh);
pool_Qinit(NULL, gdbroot->pool, &vp->u.n.sc_lh);
vp->u.n.next_oid.vid = vid;
vp->u.n.format = *format;
if (cid != pwr_eClass_DynamicVolume)
......
......@@ -102,6 +102,7 @@
/** @todo Set better initial values */
# define gdb_cMin_ccvolumes 150
# define gdb_cMin_cclasses 300
# define gdb_cMin_scObjects 300
#if defined(OS_ELN)
......@@ -363,6 +364,7 @@ typedef union {
typedef struct {
pool_sQlink volmo_lh; /**< List of 'mounted on' in this volume. */
pool_sQlink sc_lh;/**< List of sub class objects in this volume. */
gdb_mNv flags;
pwr_tObjid next_oid;
co_mFormat format;
......@@ -672,7 +674,9 @@ typedef union {
pwr_Bits( swapDelete , 1 ),
pwr_Bits( fill_1 , 7 ),,,,,,,
pwr_Bits( fill_2 , 8 ),,,,,,,,
pwr_Bits( isSc , 1 ), /* MUST be same as gdb_mSc */
pwr_Bits( hasSc , 1 ),
pwr_Bits( fill_2 , 6 ),,,,,,
pwr_Bits( bodyDecoded , 1 ),
pwr_Bits( systemCreated , 1 ),
......@@ -690,6 +694,9 @@ typedef union {
#define gdb_mNo_swapDelete pwr_Bit(8)
#define gdb_mNo_isSc pwr_Bit(16)
#define gdb_mNo_hasSc pwr_Bit(17)
#define gdb_mNo_bodyDecoded pwr_Bit(24)
#define gdb_mNo_systemCreated pwr_Bit(25)
#define gdb_mNo_ (~gdb_mNo__)
......@@ -702,6 +709,8 @@ typedef union {
typedef struct {
pool_sQlink cid_ll; /**< Next/prv object of same class */
gdb_mNo flags; /**< NOTE! Must be placed directly after cid_ll
the same position is needed in gdb_sScObject */
pool_sQlink cli_ll; /**< Mount/Alias client list. */
pool_sQlink sib_lh; /**< Head of children sibling list. */
pool_sQlink sib_ll; /**< Sibling list. */
......@@ -711,8 +720,8 @@ typedef struct {
pwr_tUInt32 subcount;
pwr_tUInt32 sancount;
gdb_sRalarm ral; /**< Remote alarm. */
gdb_mNo flags;
dbs_mFlags lflags;
pool_sQlink sc_lh; /**< Head of children sub class sibling list */
} gdb_sNobject;
typedef struct {
......@@ -733,9 +742,73 @@ typedef struct {
} u;
} gdb_sObject;
/** The Sub Class object. It's not a complete object it's just needed
* when the class list is traversed.
*/
typedef union {
pwr_tBitMask m;
pwr_32Bits (
pwr_Bits( inScList , 1 ),
pwr_Bits( inScTab , 1 ),
pwr_Bits( inSibList , 1 ),
pwr_Bits( inCidList , 1 ),
pwr_Bits( fill_0 , 4 ),,,,
pwr_Bits( fill_1 , 8 ),,,,,,,,
pwr_Bits( isSc , 1 ), /* MUST be same as gdb_mNo */
pwr_Bits( hasSc , 1 ),
pwr_Bits( isParentSc , 1 ),
pwr_Bits( isArrayElem , 1 ),
pwr_Bits( fill_2 , 4 ),,,,
pwr_Bits( fill_3 , 8 ),,,,,,,
) b;
#define gdb_mSc__ 0
#define gdb_mSc_inScList pwr_Bit(0)
#define gdb_mSc_inScTab pwr_Bit(1)
#define gdb_mSc_inSibList pwr_Bit(2)
#define gdb_mSc_inCidList pwr_Bit(3)
#define gdb_mSc_isSc pwr_Bit(16)
#define gdb_mSc_hasSc pwr_Bit(17)
#define gdb_mSc_isParentSc pwr_Bit(18)
#define gdb_mSc_isArrayElem pwr_Bit(19)
#define gdb_mSc_ (~gdb_mSc__)
} gdb_mSc;
typedef struct {
pwr_tObjid oid; /**< Object Id */
pwr_tClassId cid; /**< Class Id */
pool_sQlink sc_htl; /**< Sub Class hash table entry. */
pool_sQlink sc_ll; /**< List of sub class objects in one volume. */
pool_tRef vr; /**< Volume reference */
pool_tRef or; /**< The "real" object */
pwr_tObjid poid;
pool_tRef por; /**< Sub Class or Object Parent*/
pool_tRef cr; /**< Reference to gdb_sClass */
pwr_tUInt32 aidx; /**< Attribute index in gdb_sClass */
pwr_tUInt32 elem; /**< Index if array element, else ULONG_MAX */
pool_sQlink cid_ll; /**< Next/prv object of same class */
gdb_mSc flags; /**< NOTE! Must be placed directly after cid_ll
the same position is needed in gdb_sNobject */
dbs_mFlags lflags;
pool_sQlink sib_ll; /**< Sibling list. */
pool_sQlink sib_lh; /**< Head of children sub class sibling list */
pwr_tUInt32 offset; /**< Offset in parent body */
pwr_tUInt32 size; /**< Size of body */
pool_tRef body; /**< Address of actual body in the "real" object's
body. Must not be freed */
} gdb_sScObject;
typedef struct {
pool_tRef aor; /**< Attribute object header reference. */
pool_tRef abr; /**< Attribute object header reference. */
pool_tRef abr; /**< Attribute object body reference. */
pwr_mAdef flags;
pwr_eType type;
pwr_tUInt32 offs;
......@@ -743,6 +816,8 @@ typedef struct {
pwr_tUInt32 elem;
pwr_tUInt32 moffset; /**< Attribute maximum offset within body. */
pwr_tAix aix;
pwr_tClassId cid; /**< If class, Class Id */
pool_tRef cr; /**< If class, gdb_sClass reference */
} gdb_sAttribute;
typedef struct {
......@@ -750,21 +825,18 @@ typedef struct {
pwr_tClassId cid; /**< Class identity of class. */
pool_sQlink class_ll; /**< Entry in list of classes on node. */
pool_sQlink cid_lh; /**< Head of instance list of this class,
Template excluded. */
Template excluded. */
pool_tRef cor; /**< Class object header reference. */
pool_tRef cbr; /**< Class object body reference. */
pool_tRef bor; /**< ObjBodyDef object header reference. */
pool_tRef bbr; /**< ObjBodyDef object body reference. */
pwr_tUInt32 size; /**< Size of objects body. */
pwr_tBoolean hasSc; /**< At least one attribute is a class */
pwr_tUInt32 acount; /**< Number of attributes. */
/* Not needed ???
pool_tRef ar; */
/**< Pool reference to first attribute in gdb_sAttribute block. */
gdb_sAttribute attr[1];
} gdb_sClass;
typedef struct {
pool_sQlink volmo_ll; /**< Volume mounted on list. */
pool_sQlink nodmo_ll; /**< Node mounted on list. */
......@@ -868,6 +940,7 @@ typedef struct {
pwr_tNodeId nid; /**< Node index for this node */
pwr_tObjid nod_oid; /**< Object identifier for the node object. */
pwr_tUInt32 objects; /**< Number of */
pwr_tUInt32 scObjects; /**< Number of */
pwr_tUInt32 volumes; /**< Number of */
pwr_tUInt32 classes; /**< Number of */
pwr_tUInt32 nodes; /**< Number of */
......@@ -909,6 +982,7 @@ typedef struct {
hash_sGtable as_ht; /**< mount soid -> alias server hash table. */
hash_sGtable ccvol_ht; /**< nid + vid -> cached class volume */
hash_sGtable cclass_ht; /**< cid + cached voltime -> cached class */
hash_sGtable sc_ht; /**< oid -> Sub Class object hash table*/
} h;
qcom_sQid nethandler; /**< local nethandler */
......@@ -1001,8 +1075,9 @@ typedef struct {
hash_sTable family_ht; /**< Family (poid + name) -> object hash table. */
hash_sTable ms_ht; /**< mount soid -> mount server hash table. */
hash_sTable as_ht; /**< mount soid -> alias server hash table. */
hash_sTable ccvol_ht; /**< nid + vid -> cached class volume */
hash_sTable cclass_ht; /**< cid + cached voltime -> cached class */
hash_sTable ccvol_ht; /**< nid + vid -> cached class volume hash table*/
hash_sTable cclass_ht; /**< cid + cached voltime -> cached class hash table */
hash_sTable sc_ht; /**< oid -> sub class object hash table */
} h;
gdb_sGlobal *db; /**< Database Root, (in db_lock section) */
sect_sHead *sect; /**< Section header for global database. */
......@@ -1021,8 +1096,9 @@ typedef struct {
hash_sTable *family_ht; /**< Family table. */
hash_sTable *ms_ht; /**< mount soid -> mount server hash table. */
hash_sTable *as_ht; /**< mount soid -> alias server hash table. */
hash_sTable *ccvol_ht; /**< nid + vid -> cached class volume */
hash_sTable *cclass_ht; /**< cid + cached voltime -> cached class */
hash_sTable *ccvol_ht; /**< nid + vid -> cached class volume hash table */
hash_sTable *cclass_ht; /**< cid + cached voltime -> cached class hash table */
hash_sTable *sc_ht; /**< oid -> sub class object hash table */
gdb_sVolume *my_volume; /**< The local root volume. */
gdb_sVolume *no_volume; /**< The unknown volume with vid = 0.0.0.0. */
......@@ -1098,6 +1174,18 @@ gdb_AddObject (
pwr_tObjid soid
);
gdb_sScObject *
gdb_AddScObject (
pwr_tStatus *sts,
pwr_tObjid oid,
pwr_tClassId cid,
pwr_tUInt32 size,
pwr_tObjid poid,
pwr_tUInt32 aidx,
pwr_tUInt32 elem,
gdb_mSc flags
);
gdb_sVolume *
gdb_AddVolume (
pwr_tStatus *sts,
......
......@@ -36,6 +36,12 @@
static dvmsFctn *convFctn = NULL;
static pwr_tBoolean
buildScObjects (
pwr_tStatus *status,
gdb_sVolume *vp
);
static pwr_tBoolean
decodeObject (
pwr_tStatus *sts,
......@@ -76,6 +82,35 @@ mountVolume (
static pwr_tBoolean updateObject (ivol_sVolume*, ivol_sObject*);
/* Build ScObjects in a native volume. */
static pwr_tBoolean
buildScObjects (
pwr_tStatus *status,
gdb_sVolume *vp
)
{
pool_sQlink *scl;
gdb_sScObject *scp;
pwr_dStatus(sts, status, GDH__SUCCESS);
/* Link all sc objects. */
for (
scl = pool_Qsucc(sts, gdbroot->pool, &vp->u.n.sc_lh);
scl != &vp->u.n.sc_lh;
scl = pool_Qsucc(sts, gdbroot->pool, scl)
) {
scp = pool_Qitem(scl, gdb_sScObject, sc_ll);
vol_LinkScObject(sts, vp, scp, vol_mLinkSc_build);
pwr_Assert(ODD(*sts));
}
return YES;
}
/* Decode the body of an object. */
......@@ -289,7 +324,6 @@ updateObject (
}
op->u.n.flags.b.isMountClean = o->flags.b.isMountClean;
/* op->u.n.rbTime = o->rbody.time; */
op->u.n.time = o->time;
op->u.n.lflags.m = o->flags.m;
......@@ -398,6 +432,33 @@ ivol_BuildNode (
mvol_LinkClass(sts, cp, gdb_mAdd__);
}
/* Link Sub classes to attributes. */
for (
cl = pool_Qsucc(sts, gdbroot->pool, &gdbroot->db->class_lh);
cl != &gdbroot->db->class_lh;
) {
cp = pool_Qitem(cl, gdb_sClass, class_ll);
cl = pool_Qsucc(sts, gdbroot->pool, cl);
if (cp->hasSc)
mvol_LinkSubClassToAttribute(sts, cp);
}
/* Build ScObjects for native volumes. */
for (
vl = pool_Qsucc(sts, gdbroot->pool, &gdbroot->db->vol_lh);
vl != &gdbroot->db->vol_lh;
vl = pool_Qsucc(sts, gdbroot->pool, vl)
) {
vp = pool_Qitem(vl, gdb_sVolume, l.vol_ll);
if (vp->l.flags.b.isNative)
buildScObjects(sts, vp);
}
convFctn = dvms_GetFctns(formatp);
if (convFctn != NULL)
decodeObjects(formatp->b.bo);
......@@ -582,6 +643,42 @@ ivol_LoadObject (
return op;
}
/* Loads an object into the object database.
Used when initially populating the database, before
the nethandler is actually running. No checks are done except for
duplicate Objid. The only way to find an object is searching by
Objid. When InitialLoadDone is called, the rest of the relations
between the objects are put in place. */
gdb_sScObject *
ivol_LoadScObject (
pwr_tStatus *status,
ivol_sVolume *lv,
dbs_sScObject *sc,
pwr_tBitMask ilink
)
{
gdb_sScObject *scp;
gdb_mSc flags;
pwr_dStatus(sts, status, GDH__SUCCESS);
flags.m = 0;
flags.b.isArrayElem = sc->flags.b.isArrayElem;
flags.b.hasSc = sc->flags.b.hasSubClass;
scp = gdb_AddScObject(sts, sc->oid, sc->cid, sc->size, sc->poid, sc->aidx, sc->elem, flags);
if (scp == NULL)
return NULL;
scp->lflags.m = sc->flags.m;
if (vol_LinkScObject(sts, lv->vp, scp, ilink) == NULL)
return NULL;
// scp->flags.b.isMountClean = sc->flags.b.isMountClean;
// scp->time = sc->time;
return scp;
}
/* Loads */
gdb_sVolume *
......
......@@ -104,6 +104,7 @@ pwr_tBoolean ivol_DeleteVolume (pwr_tStatus*, gdb_sVolume*);
ivol_sBody *ivol_GetBody (pwr_tStatus*, pwr_tObjid, ivol_sBody*);
pwr_tBoolean ivol_InitiateVolumeUpdate (pwr_tStatus*, ivol_sVolume*);
gdb_sObject *ivol_LoadObject (pwr_tStatus*, ivol_sVolume*, dbs_sObject*, pwr_tBitMask);
gdb_sScObject *ivol_LoadScObject (pwr_tStatus*, ivol_sVolume*, dbs_sScObject*, pwr_tBitMask);
gdb_sVolume *ivol_LoadVolume (pwr_tStatus*, dbs_sVolume*, const co_mFormat*);
pwr_tBoolean ivol_RebuildVolume (pwr_tStatus*, ivol_sVolume*, const co_mFormat*);
......
......@@ -520,6 +520,32 @@ mvol_LinkClass (
}
gdb_sClass *
mvol_LinkSubClassToAttribute (
pwr_tStatus *sts,
gdb_sClass *cp
)
{
gdb_sClass *subcp;
int i;
if (!cp->hasSc)
pwr_Return(cp, sts, MVOL__SUCCESS);
for (i = 0; i < cp->acount; i++) {
if (cp->attr[i].flags.b.isclass) {
subcp = hash_Search(sts, gdbroot->cid_ht, &cp->attr[i].cid);
if (subcp == NULL)
errh_Bugcheck(0, "No sub class");
cp->attr[i].cr = pool_Reference(sts, gdbroot->pool, subcp);
}
}
pwr_Return(cp, sts, MVOL__SUCCESS);
}
gdb_sClass *
mvol_LinkObject (
pwr_tStatus *sts,
gdb_sVolume *vp,
......@@ -601,6 +627,29 @@ mvol_LinkObject (
}
gdb_sClass *
mvol_LinkScObject (
pwr_tStatus *sts,
gdb_sVolume *vp,
gdb_sScObject *scp
)
{
gdb_sClass *cp;
cp = gdb_AddClass(sts, scp->cid, gdb_mAdd__);
if (cp == NULL) {
errh_Bugcheck(*sts, "mvol_LinkScObject add class");
}
pwr_Assert(!scp->flags.b.inCidList);
pool_QinsertPred(sts, gdbroot->pool, &scp->cid_ll, &cp->cid_lh);
scp->flags.b.inCidList = 1;
return cp;
}
gdb_sClass *
mvol_NameToClass (
pwr_tStatus *sts,
char *name
......
......@@ -109,6 +109,12 @@ mvol_LinkClass (
pwr_tBitMask ilink
);
gdb_sClass *
mvol_LinkSubClassToAttribute (
pwr_tStatus *sts,
gdb_sClass *cp
);
gdb_sClass *
mvol_LinkObject (
pwr_tStatus *sts,
......@@ -117,6 +123,13 @@ mvol_LinkObject (
pwr_tBitMask ilink
);
gdb_sClass *
mvol_LinkScObject (
pwr_tStatus *sts,
gdb_sVolume *vp,
gdb_sScObject *scp
);
gdb_sClass *
mvol_NameToClass (
pwr_tStatus *sts,
......
......@@ -610,7 +610,8 @@ struct net_sOidToObject {
% pwr_Bits( isAliasServer , 1),
% pwr_Bits( isMountClient , 1),
% pwr_Bits( inSibList , 1),
% pwr_Bits( fill0 , 3),,,
% pwr_Bits( hasSubClass , 1),
% pwr_Bits( fill0 , 2),,
%
% pwr_Bits( fill1 , 8),,,,,,,,
% pwr_Bits( fill2 , 8),,,,,,,,
......@@ -623,6 +624,7 @@ struct net_sOidToObject {
%#define net_mGo_isAliasServer pwr_Bit(2)
%#define net_mGo_isMountClient pwr_Bit(3)
%#define net_mGo_inSibList pwr_Bit(4)
%#define net_mGo_hasSubClass pwr_Bit(5)
%
%#define net_mGo_isClient (net_mGo_isAliasClient|net_mGo_isMountClient)
%
......@@ -1025,7 +1027,7 @@ struct net_sGclass {
struct net_sGetGclass {
net_sMessage hdr;
pwr_tUInt32 ver; /**< see net_sMeassge for comment */
pwr_tUInt32 ver; /**< see net_sMessage for comment */
pwr_tClassId cid;
pwr_tUInt32 aidx; /**< Starting attribute index */
};
......@@ -1038,7 +1040,7 @@ struct net_sGetGclass {
%
%typedef struct {
% net_sMessage hdr;/**< Header */
% pwr_tUInt32 ver;/**< see net_sMeassge for comment */
% pwr_tUInt32 ver;/**< see net_sMessage for comment */
% pwr_tStatus sts;/**< Status */
%
% /* The data below is only valid if ODD(sts) */
......@@ -1142,7 +1144,7 @@ struct net_sCclass {
struct net_sGetCclass {
net_sMessage hdr;
pwr_tUInt32 ver; /**< see net_sMeassge for comment */
pwr_tUInt32 ver; /**< see net_sMessage for comment */
pwr_tClassId cid;
pwr_tTime time;
pwr_tUInt32 aidx; /**< Starting attribute index */
......@@ -1154,7 +1156,7 @@ struct net_sGetCclass {
%
%typedef struct {
% net_sMessage hdr; /**< Header */
% pwr_tUInt32 ver; /**< see net_sMeassge for comment */
% pwr_tUInt32 ver; /**< see net_sMessage for comment */
% pwr_tStatus sts; /**< Status */
% pwr_tBoolean equal; /**< The remote class is equal to the native */
%
......
......@@ -407,6 +407,124 @@ vol_LinkObject (
return op;
}
/* Link a Sub Class object. */
gdb_sScObject *
vol_LinkScObject (
pwr_tStatus *sts,
gdb_sVolume *vp,
gdb_sScObject *scp,
pwr_tBitMask ilink
)
{
pwr_tStatus lsts = 1;
gdb_sObject *pop = NULL;
gdb_sScObject *pscp = NULL;
gdb_sClass *cp;
vol_mLinkSc link;
char string[80];
gdb_AssumeLocked;
link.m = ilink;
pwr_Assert(vp->g.vid == (scp->oid.vid & 0xffffff));
if (link.b.init) {
//scp->flags.m |= (vp->l.flags.m & gdb_mLv_objectFlags);
pool_Qinit(NULL, gdbroot->pool, &scp->sc_htl);
pool_Qinit(NULL, gdbroot->pool, &scp->sc_ll);
pool_Qinit(NULL, gdbroot->pool, &scp->cid_ll);
pool_Qinit(NULL, gdbroot->pool, &scp->sib_lh);
pool_Qinit(NULL, gdbroot->pool, &scp->sib_ll);
scp->flags.b.isParentSc = ((scp->poid.vid & 0xff000000) != 0);
}
if (scp->flags.b.isParentSc) {
pscp = hash_Search(&lsts, gdbroot->sc_ht, &scp->poid);
if (pscp == NULL) {
sprintf(string, "Orphan found. Objid %s\n",
cdh_ObjidToString(NULL, scp->oid, 0));
errh_Bugcheck(lsts, string);
}
} else {
pop = hash_Search(&lsts, gdbroot->oid_ht, &scp->poid);
if (pop == NULL) {
sprintf(string, "Orphan found. Objid %s\n",
cdh_ObjidToString(NULL, scp->oid, 0));
errh_Bugcheck(lsts, string);
}
}
if (link.b.scList && !scp->flags.b.inScList) {
pool_QinsertPred(NULL, gdbroot->pool, &scp->sc_ll, &vp->u.n.sc_lh);
scp->flags.b.inScList = 1;
}
if (link.b.scTab && !scp->flags.b.inScTab) {
scp = hash_Insert(&lsts, gdbroot->sc_ht, scp);
if (scp == NULL)
pwr_Return(NULL, sts, lsts);
scp->flags.b.inScTab = 1;
}
if (link.b.parentRef && scp->por == pool_cNRef) {
if (scp->flags.b.isParentSc)
scp->por = pool_ItemReference(NULL, gdbroot->pool, pscp);
else
scp->por = pool_ItemReference(NULL, gdbroot->pool, pop);
}
if (link.b.volumeRef && scp->vr == pool_cNRef) {
scp->vr = pool_ItemReference(NULL, gdbroot->pool, vp);
}
if (link.b.classRef && scp->cr == pool_cNRef) {
cp = hash_Search(&lsts, gdbroot->cid_ht, &scp->cid);
if (cp != NULL) {
sprintf(string, "Class 0x%x not found for object, objid %s\n",
scp->cid, cdh_ObjidToString(NULL, scp->oid, 0));
errh_Bugcheck(lsts, string);
}
scp->cr = pool_ItemReference(NULL, gdbroot->pool, cp);
}
if(link.b.cidList && !scp->flags.b.inCidList)
mvol_LinkScObject(NULL, vp, scp);
if (link.b.sibList && !scp->flags.b.inSibList) {
if (scp->flags.b.isParentSc) {
pool_QinsertPred(NULL, gdbroot->pool, &scp->sib_ll, &pscp->sib_lh);
pscp->flags.b.hasSc = 1;
} else {
pool_QinsertPred(NULL, gdbroot->pool, &scp->sib_ll, &pop->u.n.sc_lh);
pop->u.n.flags.b.hasSc = 1;
}
scp->flags.b.inSibList = 1;
}
if (scp->body == pool_cNRef && scp->size > 0) {
if (scp->flags.b.isParentSc) {
pwr_Assert(pscp->body != pool_cNRef);
scp->body = pscp->body + scp->offset;
} else {
pwr_Assert(pop->u.n.body != pool_cNRef);
scp->body = pop->u.n.body + scp->offset;
}
}
return scp;
}
/* Mount a volume */
gdb_sVolume *
......
......@@ -140,6 +140,57 @@ typedef union {
} vol_mLink;
/** Link mask for sub classes */
typedef union {
pwr_tBitMask m;
pwr_32Bits (
pwr_Bits( init , 1),
pwr_Bits( scList , 1),
pwr_Bits( scTab , 1),
pwr_Bits( parentRef , 1),
pwr_Bits( volumeRef , 1),
pwr_Bits( classRef , 1),
pwr_Bits( sibList , 1),
pwr_Bits( cidList , 1),
pwr_Bits( body , 1),
pwr_Bits( fill_1 , 7),,,,,,,
pwr_Bits( fill_2 , 8),,,,,,,,
pwr_Bits( fill_3 , 8),,,,,,,
) b;
#define vol_mLinkSc__ 0
#define vol_mLinkSc_init pwr_Bit(0)
#define vol_mLinkSc_scList pwr_Bit(1)
#define vol_mLinkSc_scTab pwr_Bit(2)
#define vol_mLinkSc_parentRef pwr_Bit(3)
#define vol_mLinkSc_volumeRef pwr_Bit(4)
#define vol_mLinkSc_classRef pwr_Bit(5)
#define vol_mLinkSc_sibList pwr_Bit(6)
#define vol_mLinkSc_cidList pwr_Bit(7)
#define vol_mLinkSc_body pwr_Bit(8)
#define vol_mLinkSc_ (~vol_mLinkSc__)
#define vol_mLinkSc_load (vol_mLinkSc_init|vol_mLinkSc_scList|vol_mLinkSc_scTab\
|vol_mLinkSc_parentRef|vol_mLinkSc_volumeRef)
#define vol_mLinkSc_build (vol_mLinkSc_sibList|vol_mLinkSc_cidList\
|vol_mLinkSc_body|vol_mLinkSc_classRef)
} vol_mLinkSc;
typedef union {
pwr_tBitMask m;
pwr_32Bits (
......@@ -273,6 +324,14 @@ vol_LinkObject (
pwr_tBitMask ilink
);
gdb_sScObject *
vol_LinkScObject (
pwr_tStatus *sts,
gdb_sVolume *vp,
gdb_sScObject *op,
pwr_tBitMask ilink
);
gdb_sObject *
vol_LoadObject (
pwr_tStatus *sts,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment