Beispiel #1
0
/**
 * Adds a remote class volume.
 */
void cvolcm_AddClassVolume(
    pwr_tStatus* sts, gdb_sNode* np, const net_sGvolume* vp)
{
  gdb_sCclassVolume *ccvp, *rp;
  gdb_sVolume* cvp;

  gdb_AssumeLocked;
  pwr_Assert(vp != NULL);

  ccvp = pool_Alloc(sts, gdbroot->pool, sizeof(*ccvp));
  if (ccvp == NULL)
    return;

  ccvp->key.nid = vp->nid;
  ccvp->key.vid = vp->vid;
  ccvp->time = net_NetTimeToTime(&vp->time);

  cvp = hash_Search(sts, gdbroot->vid_ht, &vp->vid);
  if (cvp == NULL) /* This volume doesn't exist locally, but we may create it
                      later on */
    ccvp->equalClasses = 0;
  else {
    pwr_tTime t = net_NetTimeToTime(&cvp->g.time);
    ccvp->equalClasses = time_Acomp(&ccvp->time, &t) == 0 ? 1 : 0;
  }

  rp = hash_Insert(sts, gdbroot->ccvol_ht, ccvp);
  if (rp == NULL) { /* This was previously a bugcheck but obviously can occur */
    pool_Free(NULL, gdbroot->pool, ccvp);
    return;
  }

  pool_QinsertPred(NULL, gdbroot->pool, &ccvp->ccvol_ll, &np->ccvol_lh);
}
Beispiel #2
0
static san_sServer* addServer(
    pwr_tStatus* sts, gdb_sNode* np, gdb_sObject* op, net_sSanEntry* ep)
{
  san_sServer* sp;

  sp = hash_Search(NULL, gdbroot->sans_ht, &ep->sid);
  if (sp != NULL)
    return sp;

  sp = pool_Alloc(sts, gdbroot->pool, sizeof(san_sServer));
  if (sp == NULL)
    return NULL;

  sp->sane = *ep;
  sp = hash_Insert(sts, gdbroot->sans_ht, sp);
  if (sp == NULL)
    return NULL;
  /* To do !!!! This is a pool leak !!!!!! */

  if (gdbroot->is_tmon)
    sp->op = op;
  pool_QinsertPred(NULL, gdbroot->pool, &sp->sansAct_ll, &np->sansAct_lh);
  sp->flags.b.sansAct = 1;
  np->sansAct_lc++;
  np->sans_gen++;

  return checkServer(np, sp);
}
Beispiel #3
0
gdb_sNode *
gdb_AddNode (
  pwr_tStatus		*sts,
  pwr_tNodeId		nid,  
  pwr_tBitMask		flags
)
{
  gdb_sNode		*np;

  gdb_AssumeLocked;

  np = hash_Search(sts, gdbroot->nid_ht, &nid);
  if (np != NULL) return np;
  if (np != NULL) {
    if (flags & gdb_mAdd_failIfAdded)
      pwr_Return(NULL, sts, GDB__DUPLADD);
    else
      pwr_Return(np, sts, GDB__ALRADD);
  }

  np = pool_Alloc(sts, gdbroot->pool, sizeof(*np));
  if (np == NULL) return NULL;

  np->nid = nid;
  np->buf_id = 1; /* Next available buffer id */

  pool_Qinit(NULL, gdbroot->pool, &np->nid_htl);
  pool_Qinit(NULL, gdbroot->pool, &np->nod_ll);
  pool_Qinit(NULL, gdbroot->pool, &np->own_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->ccvol_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->nodms_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->nodmo_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->subc_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->nodsubs_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->nodsubb_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sansAct_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sansUpd_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sancAdd_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sancRem_lh);
  pool_Qinit(NULL, gdbroot->pool, &np->sancAct_lh);

  pool_Qinit(NULL, gdbroot->pool, &np->cacheNode.lh);
#if defined OS_ELN
  np->cacheNode.lc_max = 100;
#else
  np->cacheNode.lc_max = 200;
#endif

  np->cacheNode.flags.b.cacheNode = 1;
  np->cacheNode.next = pool_Reference(NULL, gdbroot->pool, &gdbroot->db->cacheCom);

  np = hash_Insert(sts, gdbroot->nid_ht, np);
  if (np == NULL) errh_Bugcheck(GDH__WEIRD, "adding new node");

  pool_QinsertPred(NULL, gdbroot->pool, &np->nod_ll, &gdbroot->db->nod_lh);

  return np;
}
Beispiel #4
0
sub_sClient *
subc_Create (
    char			*name,			/* Input or NULL */
    pwr_sAttrRef		*arp,			/* Input or NULL */
    pool_sQlink		*lh			/* List header. */
)
{
    sub_sClient		*cp;
    sub_sClient		*rcp;
    pwr_tInt32		s;
    pwr_tStatus		sts;

    gdb_AssumeLocked;

    s = sizeof(*cp) + (name == NULL ? 0 : strlen (name));
    cp = pool_Alloc(NULL, gdbroot->pool, s);

    cp->sub_by_name = (name != NULL);
    if (cp->sub_by_name)
        strcpy(cp->name, name);
    else
        cp->aref = *arp;

    cp->subscriber  = gdbroot->my_pid;
    cp->dt	  = default_dt;
    cp->tmo	  = default_tmo;
    cp->old	  = TRUE;	/* No data yet */

    /* The client is always counted in a np->subc_lc quota
       and must always be in a pool_sQlink list.  */

    pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, lh);
    gdbroot->no_node->subc_lc++;

    do {
        gdbroot->db->subcid.rix++;
        cp->sid = gdbroot->db->subcid;

        rcp = hash_Insert(&sts, gdbroot->subc_ht, cp);
        if (rcp != cp && sts != HASH__DUPLICATE)
            errh_Bugcheck(sts, "hash_Insert");
    } while (rcp != cp);

    return cp;
}
Beispiel #5
0
dl_sLink *
dl_Create (
  pwr_tStatus		*sts,
  mvol_sAttribute	*ap,
  pwr_sAttrRef		*arp
)
{
  pwr_tStatus		lsts;
  dl_sLink		*dp;
  dl_sLink		*rdp;

  gdb_AssumeLocked;

  pwr_Assert(ap != NULL);
  pwr_Assert(ap->op != NULL);
  pwr_Assert(arp != NULL);

  dp = pool_Alloc(NULL, gdbroot->pool, sizeof(dl_sLink));

  do {
    gdbroot->db->dlid.rix++;
    dp->dlid = gdbroot->db->dlid;

    rdp = hash_Insert(&lsts, gdbroot->subc_ht, dp);
    if (rdp != dp && lsts != HASH__DUPLICATE)
      errh_Bugcheck(lsts, "hash_Insert");
  } while (rdp != dp);

  dp->user = gdbroot->my_pid;
  dp->aref = *arp;
  dp->opr   = pool_ItemReference(NULL, gdbroot->pool, ap->op);


  /* Lock the object */

  gdb_LockObject(sts, ap->op);

  /* Insert in list of direct links */

  pool_QinsertSucc(NULL, gdbroot->pool, &dp->dl_ll, &gdbroot->db->dl_lh);
  gdbroot->db->dl_lc++;

  return dp;
}
Beispiel #6
0
gdb_sAliasServer *
gdb_AddAliasServer (
  pwr_tStatus		*sts,
  pwr_tObjid		soid,
  pwr_tBitMask		flags
)
{
  gdb_sAliasServer	*asp;
  gdb_sObject		*op = NULL;

  gdb_AssumeLocked;

  pwr_Assert(cdh_ObjidIsNotNull(soid));

  asp = hash_Search(sts, gdbroot->as_ht, &soid);
  if (asp != NULL) {
    if (flags & gdb_mAdd_failIfAdded) 
      pwr_Return(NULL, sts, GDB__DUPLADD);
    else
      pwr_Return(asp, sts, GDB__ALRADD);
  }

  asp = pool_Alloc(sts, gdbroot->pool, sizeof(*asp));
  if (asp == NULL) return NULL;

  asp->oid = soid;

  pool_Qinit(NULL, gdbroot->pool, &asp->as_htl);
  pool_Qinit(NULL, gdbroot->pool, &asp->as_ll);
  pool_Qinit(NULL, gdbroot->pool, &asp->cli_lh);

  asp = hash_Insert(sts, gdbroot->as_ht, asp);
  if (asp == NULL) errh_Bugcheck(GDH__WEIRD, "adding new alias server");

  pool_QinsertPred(NULL, gdbroot->pool, &asp->as_ll, &gdbroot->db->as_lh);

  op = hash_Search(sts, gdbroot->oid_ht, &soid);
  if (op == NULL) errh_Bugcheck(GDH__WEIRD, "getting alias server object");
  
  op->g.flags.b.isAliasServer = 1;

  return asp;
}
Beispiel #7
0
gdb_sVolume *
gdb_AddVolume (
  pwr_tStatus		*sts,
  pwr_tVolumeId		vid,
  pwr_tBitMask		flags
)
{
  gdb_sVolume		*vp;

  gdb_AssumeLocked;

  vp = hash_Search(sts, gdbroot->vid_ht, &vid);
  if (vp != NULL) {
    if (flags & gdb_mAdd_failIfAdded)
      pwr_Return(NULL, sts, GDB__DUPLADD);
    else
      pwr_Return(vp, sts, GDB__ALRADD);
  }

  vp = pool_Alloc(sts, gdbroot->pool, sizeof(*vp));
  if (vp == NULL) return NULL;

  vp->g.vid	= vid;
  vp->g.oid.vid	= vid;

  pool_Qinit(NULL, gdbroot->pool, &vp->l.vid_htl);
  pool_Qinit(NULL, gdbroot->pool, &vp->l.vn_htl);
  pool_Qinit(NULL, gdbroot->pool, &vp->l.vol_ll);
  pool_Qinit(NULL, gdbroot->pool, &vp->l.own_ll);
  pool_Qinit(NULL, gdbroot->pool, &vp->l.obj_lh);
  pool_Qinit(NULL, gdbroot->pool, &vp->l.volms_lh);

  hash_Insert(sts, gdbroot->vid_ht, vp);
  vp->l.flags.b.inVidTable = 1;

  pool_QinsertPred(sts, gdbroot->pool, &vp->l.vol_ll, &gdbroot->db->vol_lh);
  vp->l.flags.b.inVolList = 1;
  
  return vp;
}
Beispiel #8
0
gdb_sMountServer *
gdb_AddMountServer (
  pwr_tStatus		*sts,
  pwr_tObjid		soid,
  pwr_tBitMask		flags
)
{
  gdb_sMountServer	*msp;

  gdb_AssumeLocked;

  // pwr_Assert(cdh_ObjidIsNotNull(soid));
  if (cdh_ObjidIsNull(soid)) return NULL;

  msp = hash_Search(sts, gdbroot->ms_ht, &soid);
  if (msp != NULL) {
    if (flags & gdb_mAdd_failIfAdded)
      pwr_Return(NULL, sts, GDB__DUPLADD);
    else
      pwr_Return(msp, sts, GDB__ALRADD);
  }

  msp = pool_Alloc(sts, gdbroot->pool, sizeof(*msp));
  if (msp == NULL) return NULL;

  msp->oid = soid;

  pool_Qinit(NULL, gdbroot->pool, &msp->ms_htl);
  pool_Qinit(NULL, gdbroot->pool, &msp->ms_ll);
  pool_Qinit(NULL, gdbroot->pool, &msp->nodms_ll);
  pool_Qinit(NULL, gdbroot->pool, &msp->volms_ll);
  pool_Qinit(NULL, gdbroot->pool, &msp->cli_lh);

  msp = hash_Insert(sts, gdbroot->ms_ht, msp);
  if (msp == NULL) errh_Bugcheck(GDH__WEIRD, "adding new mount server");

  pool_QinsertPred(NULL, gdbroot->pool, &msp->ms_ll, &gdbroot->db->ms_lh);

  return msp;
}
Beispiel #9
0
gdb_sClass *
gdb_AddClass (
  pwr_tStatus		*sts,
  pwr_tClassId		cid,
  pwr_tBitMask		flags
)
{
  gdb_sClass		*cp;

#if 0
  pwr_Assert(cid != pwr_cNClassId);
#endif

  gdb_AssumeLocked;

  cp = hash_Search(sts, gdbroot->cid_ht, &cid);
  if (cp != NULL) {
    if (flags & gdb_mAdd_failIfAdded)
      pwr_Return(NULL, sts, GDB__DUPLADD);
    else
      pwr_Return(cp, sts, GDB__ALRADD);
  }

  cp = pool_Alloc(sts, gdbroot->pool, sizeof(*cp));
  if (cp == NULL) return NULL;

  cp->cid = cid;

  pool_Qinit(NULL, gdbroot->pool, &cp->cid_htl);
  pool_Qinit(NULL, gdbroot->pool, &cp->cid_lh);
  pool_Qinit(NULL, gdbroot->pool, &cp->class_ll);

  cp = hash_Insert(sts, gdbroot->cid_ht, cp);
  if (cp == NULL) errh_Bugcheck(GDH__WEIRD, "adding new class");

  pool_QinsertPred(NULL, gdbroot->pool, &cp->class_ll, &gdbroot->db->class_lh);

  return cp;
}
Beispiel #10
0
gdb_sObject *
dvol_RenameObject (
  pwr_tStatus		*sts,
  pwr_tObjid		oid,
  cdh_sParseName	*pn
)
{
  static cvol_sNotify	rm;		/* Cannot be on the stack for VAXELN */

  gdb_sObject		*op;
  gdb_sObject		*tmp_op;

  gdb_AssumeLocked;

  op = hash_Search(sts, gdbroot->oid_ht, &oid);
  if (op == NULL) return NULL;

  if (!op->l.flags.b.dynamic)
    pwr_Return(NULL, sts, GDH__STATICVOL);

  tmp_op = vol_FamilyToObject(sts, pn->object[0].name.orig, op->g.f.poid);
  if (tmp_op != NULL && tmp_op != op)
    pwr_Return(NULL, sts, GDH__DUPLNAME);

  hash_Remove(sts, gdbroot->family_ht, op);

  op->g.f.name = pn->object[0].name;

  hash_Insert(sts, gdbroot->family_ht, op);

  cvols_InitNotify(op, &rm, net_eMsg_renameObject);

  rm.msg.r.f.name = op->g.f.name;

  cvols_Notify(&rm);

  pwr_Return(op, sts, GDH__SUCCESS);
}
Beispiel #11
0
/**
 * Adds a remote class volume.
 */
void 
cvolcm_AddClassVolume(
  pwr_tStatus		*sts,
  gdb_sNode		*np,
  const net_sGvolume	*vp
)
{
  gdb_sCclassVolume	*ccvp;
  gdb_sVolume		*cvp;
  

  gdb_AssumeLocked;
  pwr_Assert(vp != NULL);



  ccvp = pool_Alloc(sts, gdbroot->pool, sizeof(*ccvp));
  if (ccvp == NULL) return;

  ccvp->key.nid = vp->nid;
  ccvp->key.vid = vp->vid;
  ccvp->time = net_NetTimeToTime(&vp->time);
  
  cvp = hash_Search(sts, gdbroot->vid_ht, &vp->vid);
  if (cvp == NULL) /* This volume doesn't exist locally, but we may create it later on */
    ccvp->equalClasses = 0;
  else {
    pwr_tTime t = net_NetTimeToTime( &cvp->g.time);
    ccvp->equalClasses = time_Acomp(&ccvp->time, &t) == 0 ? 1 : 0;
  }
  
  ccvp = hash_Insert(sts, gdbroot->ccvol_ht, ccvp);
  if (ccvp == NULL) errh_Bugcheck(GDH__WEIRD, "adding cached class volume");
  
  pool_QinsertPred(NULL, gdbroot->pool, &ccvp->ccvol_ll, &np->ccvol_lh);

}
Beispiel #12
0
gdb_sVolume *
cvolcm_ConnectVolume (
  pwr_tStatus		*sts,
  gdb_sVolume		*vp,
  net_sGvolume		*gvp,
  gdb_sNode		*np
)
{
  gdb_sTouchQ		*tqp;
  gdb_sVolume		*ovp;

  gdb_AssumeLocked;

  if (vp->g.nid != pwr_cNNodeId && vp->g.nid != np->nid) {
    errh_Error("Volume %s (%s) is loaded from another node.\nCurrent: %s, new: %s",
      vp->g.name.orig, cdh_VolumeIdToString(NULL, vp->g.vid, 1, 0),
      cdh_NodeIdToString(NULL, vp->g.nid, 1, 0),
      cdh_NodeIdToString(NULL, np->nid, 1, 0));
    return NULL;
  }

  vp->g = *gvp;

  pwr_Assert(vp->g.nid != pwr_cNNodeId);

  vp->l.nr = pool_Reference(NULL, gdbroot->pool, np);

  /* Add volume name to hash table.  */

  ovp = hash_Search(NULL, gdbroot->vn_ht, &vp->g.name);
  if (ovp != NULL) {
    if (ovp != vp) {
      errh_Warning("Volume name allready exist: %s, vid: %x\n", vp->g.name.orig, vp->g.vid);
      hash_Remove(NULL, gdbroot->vn_ht, ovp);
      ovp = hash_Insert(sts, gdbroot->vn_ht, vp);
      pwr_Assert(ovp == vp);  
    }
  } else {
    ovp = hash_Insert(sts, gdbroot->vn_ht, vp);
    pwr_Assert(ovp == vp);  
  }
  vp->l.flags.b.inVnTable = 1;

  pwr_Assert(!vp->l.flags.b.inOwnList);  
  pool_QinsertPred(sts, gdbroot->pool, &vp->l.own_ll, &np->own_lh);
  vp->l.flags.b.inOwnList = 1;

  /* Initiate touch queues.  */

  tqp = &vp->u.c.cacheLock;
  pool_Qinit(NULL, gdbroot->pool, &tqp->lh);
  tqp->lc_max = 0;
  tqp->flags.b.cacheLock = 1;
  tqp->next = pool_cNRef;

  tqp = &vp->u.c.cacheVol;
  pool_Qinit(NULL, gdbroot->pool, &tqp->lh);
#if defined OS_ELN
  tqp->lc_max = 100;
#else
  tqp->lc_max = 200;
#endif
  tqp->flags.b.cacheVol = 1;
  tqp->next = pool_Reference(NULL, gdbroot->pool, &np->cacheNode);

  vp->l.flags.b.isConnected = 1;
  vp->l.flags.b.isCached = 1;
  vp->l.flags.b.netCached = 1;
  vp->l.flags.b.remote = 1;
  
  return vp;
}
Beispiel #13
0
static gdb_sObject *
adoptObject (
  pwr_tStatus		*sts,
  gdb_sObject		*op,
  gdb_sObject		*pop,
  cvol_sNotify		*nmp
)
{

  gdb_AssumeLocked;

  vol_InsertSiblist(sts, op, pop);

  /* Connect to parent.  */

  op->g.f.poid = pop->g.oid;

  pwr_Assert(!op->l.flags.b.inFamilyTab);
  hash_Insert(sts, gdbroot->family_ht, op);
  op->l.flags.b.inFamilyTab = 1;

  if (nmp != NULL) {
    switch (nmp->subtype) {
    case net_eMsg_createObject:
      {
	net_sCreateObject *cp = &nmp->msg.c;

	cp->sib.flink    = op->g.sib.flink;
	cp->sib.newblink = op->g.oid.oix;

	cp->sib.blink    = op->g.sib.blink;
	cp->sib.newflink = op->g.oid.oix;

	cp->par.oid  = pop->g.oid;
	cp->par.soid = pop->g.soid;

	break;
      }
    case net_eMsg_moveObject:
      {
	net_sMoveObject *mp = &nmp->msg.m;

	mp->sib = op->g.sib;

	mp->nsib.flink    = op->g.sib.flink;
	mp->nsib.newblink = op->g.oid.oix;

	mp->nsib.blink    = op->g.sib.blink;
	mp->nsib.newflink = op->g.oid.oix;

	mp->npar.oid  = pop->g.oid;
	mp->npar.soid = pop->g.soid;
	break;

      }
    default:
      errh_Bugcheck(2, "");
    }
  }

#if 0 /* !!! To do!!!*/
  malvl = MAX(op->g.alvl, op->g.malvl);
  mblvl = MAX(op->g.blvl, op->g.mblvl);
  if (malvl > pop->g.malvl || mblvl > op->g.mblvl) {
    op->o.ablvl_idx = ++gdbroot->db->ablvl_idx;
    vol_PropagateAlarmLevel(sts, op, 0, malvl, NO);
    vol_PropagateBlockLevel(sts, op, 0, mblvl, NO);
  }
#endif

  return op;
}