示例#1
0
void
sub_UnlinkObject (
  gdb_sObject		*op
)
{
  sub_sServer		*sp;
  pool_sQlink		*sl;
  
  for (
    sl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->subs_lh);
    sl != &gdbroot->db->subs_lh;
    sl = pool_Qsucc(NULL, gdbroot->pool, sl)
  ) {
    sp = pool_Qitem(sl, sub_sServer, subs_ll);
    if (cdh_ObjidIsEqual(sp->aref.Objid, op->g.oid)) {
      sp->data	= pool_cNRef;
      sp->sts	= GDH__NOSUCHOBJ;

      if ( op->u.n.subcount > 0) /* Subscriptions on invalid offset will allocate buffer without increasing count */
	op->u.n.subcount--;
    }
  }

  pwr_Assert(op->u.n.subcount == 0);

}
示例#2
0
void cvolcm_ExternVolumeFlush(gdb_sNode* np)
{
  pool_sQlink* vl;
  gdb_sVolume* vp;
  pool_sQlink* ol;
  gdb_sObject* op;
  gdb_sMountServer* msp;
  pwr_tStatus sts;

  // Flush local node
  gdb_AssumeLocked;

  for (vl = pool_Qsucc(NULL, gdbroot->pool, &np->own_lh); vl != &np->own_lh;
       vl = pool_Qsucc(NULL, gdbroot->pool, vl)) {
    vp = pool_Qitem(vl, gdb_sVolume, l.own_ll);
    pwr_Assert(vp->l.flags.b.isCached);
    if (vp->l.flags.b.isCached) {
      for (ol = pool_Qsucc(NULL, gdbroot->pool, &vp->l.obj_lh);
           ol != &vp->l.obj_lh;
           ol = pool_Qsucc(NULL, gdbroot->pool, &vp->l.obj_lh)) {
        op = pool_Qitem(ol, gdb_sObject, l.obj_ll);
        if (op->l.flags.b.isMountServer) {
          msp = (gdb_sMountServer*)hash_Search(
              &sts, gdbroot->ms_ht, &op->g.oid);
          if (msp == NULL)
            errh_Bugcheck(sts, "mount server inconsitency");
          msp->msor = pool_cNRef;
          pool_Qremove(NULL, gdbroot->pool, &msp->nodms_ll);
          /* Todo !!! Clear alarm and blocklevel in all mount clients. */
        }
        cvol_FlushObject(op);
      }
    }
  }
}
示例#3
0
文件: rt_ivol.c 项目: Strongc/proview
pwr_tBoolean
ivol_InitiateVolumeUpdate (
  pwr_tStatus		*status,
  ivol_sVolume		*lv
)
{
  gdb_sVolume		*vp = lv->vp;
  gdb_sObject		*op;
  pool_sQlink		*ol;

  pwr_dStatus(sts, status, GDH__SUCCESS);

  for (	/* All the objects in the volume.  */
    ol = pool_Qsucc(sts, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
    ol = pool_Qsucc(sts, gdbroot->pool, ol)
  ) {
    if (ol == NULL) return NO;

    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);

    op->u.n.flags.m |= gdb_mNo_swap;
#if 0
    op->u.n.flags.b.swapDelete = 1;
#endif
  }

  return YES;
}
示例#4
0
void cvolcm_FlushNode(pwr_tStatus* sts, gdb_sNode* np)
{
  pool_sQlink* vl;
  gdb_sVolume* vp;
  gdb_sCclassVolume* cvp;
  pwr_tStatus lsts;

  gdb_AssumeLocked;
  pwr_Assert(np != gdbroot->my_node && np != gdbroot->no_node);

  for (vl = pool_Qsucc(NULL, gdbroot->pool, &np->own_lh); vl != &np->own_lh;
       vl = pool_Qsucc(NULL, gdbroot->pool, &np->own_lh)) {
    vp = pool_Qitem(vl, gdb_sVolume, l.own_ll);
    pwr_Assert(vp->l.flags.b.isCached);
    if (vp->l.flags.b.isCached)
      cvolcm_FlushVolume(NULL, vp);
  }

  for (vl = pool_Qsucc(NULL, gdbroot->pool, &np->ccvol_lh); vl != &np->ccvol_lh;
       vl = pool_Qsucc(NULL, gdbroot->pool, &np->ccvol_lh)) {
    cvp = pool_Qitem(vl, gdb_sCclassVolume, ccvol_ll);

    hash_Remove(&lsts, gdbroot->ccvol_ht, cvp);
    if (EVEN(lsts))
      errh_Bugcheck(lsts, "cached class volume inconsistency");

    pool_Qremove(NULL, gdbroot->pool, &cvp->ccvol_ll);
    pool_Free(NULL, gdbroot->pool, cvp);
  }
}
示例#5
0
文件: rt_ivol.c 项目: Strongc/proview
pwr_tBoolean
ivol_BuildVolume (
  pwr_tStatus		*status,
  gdb_sVolume		*vp
)
{
  pool_sQlink		*ol;
  gdb_sObject		*op;

  pwr_dStatus(sts, status, GDH__SUCCESS);

  /* First link the volume block.  */


  /* Now link all objects.  */

  for (
    ol = pool_Qsucc(sts, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
    ol = pool_Qsucc(sts, gdbroot->pool, ol)
  ) {
    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);

    vol_LinkObject(sts, vp, op, vol_mLink_build);
    pwr_Assert(ODD(*sts));

  }
  return YES;
}
示例#6
0
文件: rt_ivol.c 项目: Strongc/proview
static void
decodeObjects (
  co_eBO 		bo
)
{
  pwr_tStatus		lsts;
  gdb_sClass		*cp;
  pool_sQlink		*cl;
  gdb_sObject		*op;
  pool_sQlink		*ol;


  for (
    cl = pool_Qsucc(&lsts, gdbroot->pool, &gdbroot->db->class_lh);
    cl != &gdbroot->db->class_lh;
    cl = pool_Qsucc(&lsts, gdbroot->pool, cl)
  ) {
    cp = pool_Qitem(cl, gdb_sClass, class_ll);

    for (
      ol = pool_Qsucc(&lsts, gdbroot->pool, &cp->cid_lh);
      ol != &cp->cid_lh;
      ol = pool_Qsucc(&lsts, gdbroot->pool, ol)
    ) {
      op = pool_Qitem(ol, gdb_sObject, u.n.cid_ll);
      if (op->u.n.flags.b.bodyDecoded) continue;
      decodeObject(&lsts, op, cp, bo);
    }
  }
}
示例#7
0
void sansm_Check()
{
  static unsigned int idx = 0;
  gdb_sNode* np;
  pool_sQlink* nl;
  san_sServer* sp;
  pool_sQlink* sl;

  gdb_AssumeLocked;

  if (idx == gdbroot->db->al_idx)
    return;

  for (nl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->nod_lh);
       nl != &gdbroot->db->nod_lh;) {
    np = pool_Qitem(nl, gdb_sNode, nod_ll);
    nl = pool_Qsucc(NULL, gdbroot->pool, nl);

    if (!np->flags.b.connected)
      continue;

    for (sl = pool_Qsucc(NULL, gdbroot->pool, &np->sansAct_lh);
         sl != &np->sansAct_lh;) {
      sp = pool_Qitem(sl, san_sServer, sansAct_ll);
      sl = pool_Qsucc(NULL, gdbroot->pool, sl);

      checkServer(np, sp);
    }
  }

  idx = gdbroot->db->al_idx;
}
示例#8
0
文件: rt_ivol.c 项目: Strongc/proview
static pwr_tBoolean
mountClients (
  pwr_tStatus		*sts,
  gdb_sVolume		*vp
)
{
  pool_sQlink		*ol;
  gdb_sObject		*op;

  /* First link the volume block.  */


  /* Now link all objects.  */

  for (
    ol = pool_Qsucc(sts, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
    ol = pool_Qsucc(sts, gdbroot->pool, ol)
  ) {
    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);

    if (op->g.flags.b.isMountClient && op->g.oid.vid == gdbroot->db->vid) {
      /* Only root volumes can mount.  */
      mountVolume(sts, op);
      if ( *sts != GDH__NOMOUNTOBJECT)
	pwr_Assert(ODD(*sts));
    }
  }
  return YES;
}
示例#9
0
文件: rt_ivol.c 项目: Strongc/proview
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;
}
示例#10
0
文件: rt_ivol.c 项目: Strongc/proview
pwr_tBoolean
ivol_DeleteVolume (
  pwr_tStatus           *status,
  gdb_sVolume		*vp
)
{
  pool_sQlink		*ol;
  gdb_sObject		*op;

  pwr_dStatus(sts, status, GDH__SUCCESS);

#if 0
  sub_DeleteVolumeServers(sts, vp);
  san_DeleteVolumeServers(sts, vp);
#endif

  for (
    ol = pool_Qsucc(sts, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
    ol = pool_Qsucc(sts, gdbroot->pool, ol)
  ) {
    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);

    vol_UnlinkObject(sts, vp, op, vol_mLink_flush);
    vol_UnlockObject(sts, op);
  }
  return YES;
}
示例#11
0
void
cvols_Notify (
  cvol_sNotify		*nmp
)
{
  pwr_tStatus		lsts;
  pool_sQlink		*nl;
  gdb_sNode		*np;
  qcom_sQid		tgt;
  qcom_sPut		put;

  gdb_AssumeLocked;

  if (gdbroot->db->nethandler.qix == 0)
    return;

  tgt.qix = net_cProcHandler;

  gdb_Unlock;

    /* Send to all nodes that have mounted affected volume.

       NOTA BENE !!!
	  In this version we send to all known nodes. */

    for (
      nl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->nod_lh);
      nl != &gdbroot->db->nod_lh;
      nl = pool_Qsucc(NULL, gdbroot->pool, nl)
    ) {
      np = pool_Qitem(nl, gdb_sNode, nod_ll);
      if (np == gdbroot->my_node || np == gdbroot->no_node) continue;
      if (!np->flags.b.active) continue; /* Todo !!! What happens with consistency ? */

      tgt.nid = np->nid;

      if (!net_Put(&lsts, &tgt, &nmp->msg, nmp->subtype, 0, nmp->size, 0))
	errh_Warning("Notify: error %x sending subtype %s to node %s", lsts, "Notify", np->name); 
    }

    /* Submit to the NETH ACP to check if any subscriptions are affected.  */

    put.type.b	= net_cMsgClass;
    put.type.s	= nmp->subtype;
    put.reply	= qcom_cNQid;
    put.data  	= (char *)&nmp->msg;
    put.size	= nmp->size;
    nmp->msg.hdr.hdr.xdr = 0;
    nmp->msg.hdr.hdr.msn = 0;
    nmp->msg.hdr.hdr.nid = gdbroot->my_node->nid;

    qcom_Put(&lsts, &qcom_cQnacp, &put);

  gdb_Lock;

}
示例#12
0
static void lockMountServers(gdb_sNode* np)
{
  pwr_tStatus sts;
  pool_sQlink* msl;
  pool_sQlink* vl;
  gdb_sVolume* vp;
  gdb_sMountServer* msp;
  gdb_sObject* op;

  gdb_AssumeLocked;

  for (vl = pool_Qsucc(NULL, gdbroot->pool, &np->own_lh); vl != &np->own_lh;
       vl = pool_Qsucc(NULL, gdbroot->pool, vl)) {
    vp = pool_Qitem(vl, gdb_sVolume, l.own_ll);

    if (vl->self == vl->flink) {
      /* Connection lost and volume removed from own list */
      errh_Error("Volume not owned any more, %s", vp->g.name.orig);
      return;
    }
    if (!vp->l.flags.b.isConnected) {
      /* !!! Todo !!! How do we make this known ?  */
      errh_Error("Volume not connected, %s", vp->g.name.orig);
      continue;
    }

    for (msl = pool_Qsucc(NULL, gdbroot->pool, &vp->l.volms_lh);
         msl != &vp->l.volms_lh; msl = pool_Qsucc(NULL, gdbroot->pool, msl)) {
      msp = pool_Qitem(msl, gdb_sMountServer, volms_ll);
      op = hash_Search(&sts, gdbroot->oid_ht, &msp->oid);
      if (op == NULL) {
        op = cvolc_OidToObject(
            &sts, vp, msp->oid, vol_mTrans_none, cvol_eHint_none);
        if (op == NULL) {
          errh_Error("Can't fetch the mount server's object, %s",
              cdh_ObjidToString(msp->oid, 0));
          /* !!! Todo !!! How do we make this error known ?  */
          continue;
        }
      }
      msp->msor = pool_ItemReference(NULL, gdbroot->pool, op);
      op->l.flags.b.isMountServer = 1;
      if (msp->nodms_ll.self == msp->nodms_ll.flink
          && msp->nodms_ll.self == msp->nodms_ll.blink)
        pool_QinsertPred(NULL, gdbroot->pool, &msp->nodms_ll, &np->nodms_lh);

      /* if (0)
        errh_Info("Locking object %s", op->g.f.name.orig); */
      cvolc_LockObject(&sts, op);
    }
  }
}
示例#13
0
void
subs_UnlinkObject (
    gdb_sObject		*op
)
{
    sub_sServer		*sp;
    pool_sQlink		*sl;

    gdb_AssumeLocked;

    for (
        sl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->subs_lh);
        sl != &gdbroot->db->subs_lh;
    ) {
        sp = pool_Qitem(sl, sub_sServer, subs_ll);
        if (cdh_ObjidIsEqual(sp->aref.Objid, op->g.oid)) {
            sp->data	= pool_cNRef;
            sp->sts	= GDH__NOSUCHOBJ;

            op->u.n.subcount--;
        }
    }

    pwr_Assert(op->u.n.subcount == 0);

}
示例#14
0
void
subc_CancelUser (
    pid_t			subscriber
)
{
    sub_sClient		*cp;
    pool_sQlink		*cl;
    gdb_sNode		*np;
    pool_sQlink		*nl;
    pool_sQlink		*lh;

    /* Allocate a temporary root */

    gdb_AssumeLocked;

    lh = pool_Qalloc(NULL, gdbroot->pool);

    /* Build a list with all clients to cancel */

    for (
        nl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->nod_lh);
        nl != &gdbroot->db->nod_lh;
        nl = pool_Qsucc(NULL, gdbroot->pool, nl)
    ) {
        np = pool_Qitem(nl, gdb_sNode, nod_ll);

        for (cl = pool_Qsucc(NULL, gdbroot->pool, &np->subc_lh); cl != &np->subc_lh; ) {
            cp = pool_Qitem(cl, sub_sClient, subc_ll);
            cl = pool_Qsucc(NULL, gdbroot->pool, cl);

            if (cp->subscriber == subscriber) {
                pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll);
                pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, lh);
            }
        } /* For all clients of that node. */
    } /* For all nodes */

    /* Now cancel them all! */

    subc_CancelList(lh);

    /* Return the root to the pool */

    pool_Free(NULL, gdbroot->pool, lh);

}
示例#15
0
文件: rt_tmon.c 项目: Strongc/proview
static void
sansCheck (
  sTimer	*tp
)
{
  static time_tClock	cycle;
  static pwr_tBoolean   first = 1;
  gdb_sNode		*np;
  pool_sQlink		*nl;
  
  if (first) {
#ifdef OS_LINUX
    cycle = 2 * sysconf(_SC_CLK_TCK);
#else
    cycle = 2 * CLK_TCK;
#endif
    setInterval(&cycle, gdbroot->db->sans_chk_int);
    first = 0;
  }

  if (gdbroot->db->log.b.tmon)
    errh_Info("sansCheck: %u", tp->clock);

  sansm_Check();

  for (
    nl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->nod_lh);
    nl != &gdbroot->db->nod_lh;
  ) {
    np = pool_Qitem(nl, gdb_sNode, nod_ll);
    nl = pool_Qsucc(NULL, gdbroot->pool, nl);

    if (!np->flags.b.active
        || np == gdbroot->my_node
	|| np == gdbroot->no_node
    ) continue;

    sansm_Update(np);
  }


  setTimer(tp, cycle);

  insertTimer(tp);
}
示例#16
0
void
cvolcm_FlushVolume (
  pwr_tStatus		*sts,
  gdb_sVolume		*vp 
)
{
  pool_sQlink		*ol;
  gdb_sObject		*op;
  gdb_sMountServer	*msp;

  gdb_AssumeLocked;

  for (
    ol = pool_Qsucc(NULL, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
    ol = pool_Qsucc(NULL, gdbroot->pool, &vp->l.obj_lh)
  ) {
    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);
    if (op->l.flags.b.isMountServer) {
      msp = hash_Search(sts, gdbroot->ms_ht, &op->g.oid);
      if (msp == NULL) errh_Bugcheck(*sts, "mount server inconsitency");
      msp->msor = pool_cNRef;
      pool_Qremove(NULL, gdbroot->pool, &msp->nodms_ll);
      /* Todo !!! Clear alarm and blocklevel in all mount clients. */
    }
    cvol_FlushObject(op);
  }
  
  pwr_Assert(vp->l.flags.b.inOwnList);
  pool_Qremove(NULL, gdbroot->pool, &vp->l.own_ll);
  vp->l.flags.b.inOwnList = 0;
  vp->g.nid = pwr_cNNodeId;

  pwr_Assert(pool_QisEmpty(NULL, gdbroot->pool, &vp->u.c.cacheLock.lh));
  pwr_Assert(vp->u.c.cacheLock.lc == 0);
  pwr_Assert(pool_QisEmpty(NULL, gdbroot->pool, &vp->u.c.cacheVol.lh));
  pwr_Assert(vp->u.c.cacheVol.lc == 0);

  vp->l.flags.b.isConnected = 0;
  vp->l.flags.b.isCached = 0;
  vp->l.flags.b.netCached = 0;
  vp->l.flags.b.remote = 0;
}
示例#17
0
void
cvolsm_FlushNode (
  pwr_tStatus		*sts,
  gdb_sNode		*np
)
{
  pool_sQlink		*mol;
  gdb_sMountedOn	*mop;

  gdb_AssumeLocked;

  for (
    mol = pool_Qsucc(NULL, gdbroot->pool, &np->nodmo_lh);
    mol != &np->nodmo_lh;
    mol = pool_Qsucc(NULL, gdbroot->pool, &np->nodmo_lh)
  ) {
    mop = pool_Qitem(mol, gdb_sMountedOn, nodmo_ll);
    cvolsm_RemoveMountedOn(NULL, mop);
  }
}
示例#18
0
void sansm_FlushNode(pwr_tStatus* sts, gdb_sNode* np)
{
  san_sServer* sp;
  pool_sQlink* sl;

  gdb_AssumeLocked;

  for (sl = pool_Qsucc(NULL, gdbroot->pool, &np->sansAct_lh);
       sl != &np->sansAct_lh;) {
    sp = pool_Qitem(sl, san_sServer, sansAct_ll);
    sl = pool_Qsucc(NULL, gdbroot->pool, sl);

    removeServer(np, sp);
  }

  if (sts != NULL)
    *sts = 1;

  return;
}
示例#19
0
文件: rt_dl.c 项目: hfuhuang/proview
void
dl_CancelUser (
  pid_t			user
)
{
  pool_sQlink		*dl;
  dl_sLink		*dp;

  gdb_AssumeLocked;

  for (
    dl = pool_Qsucc(NULL, gdbroot->pool, &gdbroot->db->dl_lh);
    dl != &gdbroot->db->dl_lh;
  ) {
    dp = pool_Qitem(dl, dl_sLink, dl_ll);
    dl = pool_Qsucc(NULL, gdbroot->pool, dl);

    if (dp->user == user)
      dl_Cancel(NULL, dp->dlid);
  }
}
示例#20
0
void
sancm_MoveExpired (
    pwr_tStatus		*status,
    gdb_sNode		*np
)
{
    pool_sQlink		*ol;
    gdb_sObject		*op;

    if (status != NULL) *status = 1;

    gdb_AssumeLocked;

    if (np->sancAct_lc == 0) return;

    for (
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAct_lh);
        ol != &np->sancAct_lh;
    ) {
        op = pool_Qitem(ol, gdb_sObject, u.c.sanc_ll);
        ol = pool_Qsucc(NULL, gdbroot->pool, ol);

        pwr_Assert(op->u.c.flags.b.sancAct);

        if (op->u.c.sanexp) {
            pool_Qremove(NULL, gdbroot->pool, &op->u.c.sanc_ll);
            op->u.c.flags.b.sancAct = 0;
            pwr_Assert((op->u.c.flags.m & gdb_mCo_inSancList) == 0);
            pwr_Assert(np->sancAct_lc != 0);
            np->sancAct_lc--;

            pool_QinsertPred(NULL, gdbroot->pool, &op->u.c.sanc_ll, &np->sancRem_lh);
            op->u.c.flags.b.sancRem = 1;
            np->sancRem_lc++;
            op->u.c.sanexp = 0;
        } else if (!op->l.flags.b.isMountServer)
            op->u.c.sanexp = 1;
    }
}
示例#21
0
文件: rt_sanc.c 项目: siamect/proview
void sanc_SubscribeMountServers(pwr_tStatus* status, gdb_sNode* np)
{
  gdb_sMountServer* msp;
  pool_sQlink* msl;
  gdb_sObject* op;

  pwr_dStatus(sts, status, 1);

  gdb_AssumeLocked;

  for (msl = pool_Qsucc(NULL, gdbroot->pool, &np->nodms_lh);
       msl != &np->nodms_lh; msl = pool_Qsucc(NULL, gdbroot->pool, msl)) {
    msp = pool_Qitem(msl, gdb_sMountServer, nodms_ll);

    op = pool_Address(sts, gdbroot->pool, msp->msor);
    if (op == NULL)
      continue;

    sanc_Subscribe(sts, op);
  }

  *sts = 1;
}
示例#22
0
文件: rt_ivol.c 项目: Strongc/proview
pwr_tBoolean
ivol_RebuildVolume (
  pwr_tStatus		*status,
  ivol_sVolume		*lv,
  const co_mFormat	*format
)
{
  gdb_sVolume		*vp = lv->vp;
  ivol_sObject		*iop;
  lst_sEntry		*iol;
  pool_sQlink		*ol;
  gdb_sObject		*op;

  pwr_dStatus(sts, status, GDH__SUCCESS);

  gdb_AssumeExcled;
  gdb_AssumeLocked;

#if 0
  // if (!vp->modified) continue;
#endif

  for (
    ol = pool_Qsucc(sts, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
  ) {
    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);
    ol = pool_Qsucc(sts, gdbroot->pool, ol);

    if (op->u.n.flags.b.swapDelete && !op->u.n.flags.b.systemCreated) {
      vol_SetAlarmLevel(sts, op, 0);/* !!! TODO Remeber to take care of move also in dvol delete and move */
      vol_SetBlockLevel(sts, op, 0);/* !!! TODO Remeber to take care of move also in dvol delete and move */
    }
  }

  /* Unlink all modified objects.  */
  for (iop = lst_Succ(NULL, &lv->upd_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    if (!(iop->flags.m & gdb_mChange_head)) continue;
    vol_UnlinkObject(sts, vp, iop->op, iop->unlink.m);
    updateObject(lv, iop);
  }
  for (iop = lst_Succ(NULL, &lv->upd_io_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    if (!(iop->flags.m & gdb_mChange_head)) continue;
    vol_UnlinkObject(sts, vp, iop->op, iop->unlink.m);
    updateObject(lv, iop);
  }

  for (iop = lst_Succ(NULL, &lv->cre_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    vol_LinkObject(sts, vp, iop->op, vol_mLink_loOidTab);
  }

  for (
    ol = pool_Qsucc(sts, gdbroot->pool, &vp->l.obj_lh);
    ol != &vp->l.obj_lh;
  ) {
    op = pool_Qitem(ol, gdb_sObject, l.obj_ll);
    ol = pool_Qsucc(sts, gdbroot->pool, ol);

    if (op->u.n.flags.b.swapDelete && !op->u.n.flags.b.systemCreated) {
      vol_UnlinkObject(sts, vp, op, vol_mLink_swapDelete);
    }
  }

  /* Relink all new and modified objects.  */

  for (iop = lst_Succ(NULL, &lv->upd_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    if (!(iop->flags.m & gdb_mChange_head)) continue;
    vol_LinkObject(sts, vp, iop->op, iop->link.m);
  }
  for (iop = lst_Succ(NULL, &lv->upd_io_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    if (!(iop->flags.m & gdb_mChange_head)) continue;
    vol_LinkObject(sts, vp, iop->op, iop->link.m);
  }

  convFctn = dvms_GetFctns(format);

  for (iop = lst_Succ(NULL, &lv->cre_lh, &iol); iop != NULL; iop = lst_Succ(NULL, iol, &iol)) {
    vol_LinkObject(sts, vp, iop->op, vol_mLink_swapBuild);
    if (convFctn != NULL)
      decodeObject(NULL, iop->op, iop->cp, format->b.bo);
  }

  convFctn = NULL;
  

#if 0
  san_DeleteVolumeServers(sts, vp);
#endif

  return YES;
}
示例#23
0
void
subc_CancelList (
    pool_sQlink		*lh
)
{
    qcom_sQid		tgt;
#if 0
    tree_sTable		*remove;
    sRemove		*rep;
    gdb_sNode		*np;
#endif
    pwr_tNodeId		nid;
    pwr_tSubid		sid;
    sub_sClient		*cp;
    pool_sQlink		*cl;

    gdb_AssumeLocked;

    tgt.qix = net_cProcHandler;

#if 0
    remove = tree_CreateTable(sizeof(pwr_tNodeId), offsetof(sRemove, nid),
                              sizeof(sRemove), 10, tree_eComp_nid, NULL);
#endif

    for (cl = pool_Qsucc(NULL, gdbroot->pool, lh); cl != lh;) {
        cp = pool_Qitem(cl, sub_sClient, subc_ll);
        cl = pool_Qsucc(NULL, gdbroot->pool, cl);

        cancelTimeoutWatch(cp);

        /* Get rid of the client, make it invalid for other references
           that might happen when we are unlocked
           But first: save nid and sid which we need further down.  */

        nid = cp->nid;
        sid = cp->sid;
        deleteClient(cp);

#if 0
        if (nid != pwr_cNNodeId) {
            rep = tree_Insert(remove, &nid);
            if (rep == NULL) errh_Bugcheck(GDH__WEIRD, "");

            if (rep->msg == NULL) {
                np = hash_Search(NULL, gdbroot->nid_ht, &nid);
                if (np == NULL) errh_Bugcheck(GDH__WEIRD, "");
                rep->cnt = net_cSubMaxRemove;
                rep->msg = malloc(sizeof(net_sSubRemove) + sizeof(rep->msg->sid[0]) * rep->cnt);
                rep->msg->count = 0;
            }

            rep->msg->sid[rep->msg->count++] = sid;

            if (rep->msg->count >= net_cSubMaxRemove) {
                tgt.nid = rep->nid;

                gdb_Unlock;

                net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);

                gdb_Lock;

                rep->msg->count = 0;

            }
        } /* Remote */
#endif
    } /* For all clients in list */

#if 0
    /* Now send all unsent messages.  */

    gdb_Unlock;

    for (rep = tree_Minimum(remove); rep != NULL; rep = tree_Successor(remove, rep)) {
        if (rep->msg != NULL) {
            if (rep->msg->count > 0) {
                tgt.nid = rep->nid;
                net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0);
            }
            free(rep->msg);
        }
    }

    gdb_Lock;

    tree_DeleteTable(remove);
#endif
}
示例#24
0
文件: rt_ivol.c 项目: Strongc/proview
void
ivol_BuildNode (
  pwr_tStatus		*status,
  ivol_sNode		*lnp,
  const co_mFormat      *formatp
)
{
  gdb_sVolume		*vp;
  pwr_sMountObject	*MountObject;
  cdh_uVolumeId		sys_vid;
  pwr_tObjid		sys_oid;
  pwr_tObjid		oid;
  gdb_sObject		*op;
  gdb_sObject		*vop;
  gdb_sObject		*mop;
  pool_sQlink		*vl;
  gdb_sClass		*cp;
  pool_sQlink		*cl;
  co_mFormat            fm;
  pwr_tTime		time;
  
  
  pwr_dStatus(sts, status, GDH__SUCCESS);

  /* Fill in remaining node information.  */

  gdbroot->db->nod_oid = lnp->nod_oid;

  gdbroot->my_node->nod_oid = gdbroot->db->nod_oid;
  gdbroot->my_node->vol_oid = gdbroot->db->vol_oid;

  /* Create the system volume and mount it in the root voulme.  */

  sys_vid.pwr	  = gdbroot->db->vid;
  sys_vid.v.vid_3 = cdh_eVid3_local;
  sys_oid.vid	  = sys_vid.pwr;
  sys_oid.oix	  = pwr_cNObjectIx;
  time_GetTime(&time);

  vp = gdb_LoadVolume(sts, sys_vid.pwr, "", pwr_eClass_SystemVolume, gdbroot->db->nid, 
                      time, gdb_mLoad_build, co_GetOwnFormat(&fm));
  if (vp == NULL) errh_Bugcheck(*sts, "");

  /* Create the volume object.  */

  vop = loadObject(sts, vp, vp->g.name.orig, sys_oid, pwr_eClass_SystemVolume,
    sizeof(pwr_sSystemVolume), pwr_cNObjid, net_mGo__, pwr_cNObjid); 
  if (vop == NULL) errh_Bugcheck(*sts, "");
  vop->u.n.flags.b.bodyDecoded = 1;

  /* Create the 'pwrNode' object.  */

  oid = vol_Oid(sts, vp, pwr_eClass_NodeHier);
  op = loadObject(sts, vp, "pwrNode", oid, pwr_eClass_NodeHier,
    sizeof(pwr_sNodeHier), sys_oid, net_mGo__, pwr_cNObjid); 
  if (op == NULL) errh_Bugcheck(*sts, "");
  op->u.n.flags.b.bodyDecoded = 1;

  errh_Info("Created pwrNode, oid: %s", cdh_ObjidToString(NULL, oid, 1));
  /* Create a mount object in the root volume, to mount the 'pwrNode' object.  */

  pwr_Assert(gdbroot->my_volume != NULL);

  oid = vol_Oid(sts, gdbroot->my_volume, pwr_eClass_MountObject);
  mop = loadObject(sts, gdbroot->my_volume, "pwrNode", oid, pwr_eClass_MountObject,
    sizeof(pwr_sMountObject), gdbroot->db->vol_oid, net_mGo_isMountClient, op->g.oid); 
  if (mop == NULL) errh_Bugcheck(*sts, "");
  mop->u.n.flags.b.bodyDecoded = 1;
  
  MountObject = pool_Address(NULL, gdbroot->rtdb, mop->u.n.body);
  strcpy(MountObject->Description, "Mounts the system volume object pwr_Node.");
  MountObject->Object = op->g.oid;

  /* Build all 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) ivol_BuildVolume(sts, vp);
  }

  /* Link class definitions.  */

  for (
    cl = pool_Qsucc(sts, gdbroot->pool, &gdbroot->db->class_lh);
    cl != &gdbroot->db->class_lh;
  ) {
    cp = pool_Qitem(cl, gdb_sClass, class_ll);
    /* NOTA BENE !! mvol_LinkClass will change the linkage.  */
    cl = pool_Qsucc(sts, gdbroot->pool, cl);

    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);
  }


  /* Build class attribute tree */
  mvol_BuildCatt(sts);


  convFctn = dvms_GetFctns(formatp);
  if (convFctn != NULL)
    decodeObjects(formatp->b.bo);
  convFctn = NULL;

  mountClients(sts, gdbroot->my_volume);
}
示例#25
0
static pool_sQlink *
findEntry (
  pwr_tStatus		*sts,
  pool_sQlink		**bp,		/* Return pointer to bucket.  */
  hash_sTable		*htp,
  const void		*keyp
)
{
  pwr_tUInt32		key;		/* key transformation value */
  pwr_tBoolean		found;
  pwr_tUInt32		depth;
  hash_sGtable		*ghtp;
  pool_sQlink		*lh;
  pool_sQlink		*il;
  char			*ip;

  ghtp = htp->ghtp;
  
  switch (ghtp->key_type) {
  case hash_eKey_oid:
    {
      pwr_tObjid *valp = (pwr_tObjid *) keyp;

      key = (valp->oix + ((valp->vid * 127) ^ (valp->vid * 131))) % ghtp->size;
    }
    break;
  case hash_eKey_int32:
    {
      pwr_tUInt32 val = *(pwr_tUInt32 *) keyp;
      key = ((val * 127) ^ (val * 131)) % ghtp->size;
    }
    break;
  case hash_eKey_family:
    {
      pwr_tUInt32 val = ((cdh_sFamily *) keyp)->name.pack.key;
      pwr_tObjid *valp = &(((cdh_sFamily *) keyp)->poid);
      key = (((val * 127) ^ (val * 131)) ^
	     ((valp->oix * 127) ^ (valp->oix * 131)) ^
	     ((valp->vid * 127) ^ (valp->vid * 131))) % ghtp->size;
    }
    break;
  case hash_eKey_objName:
    {
      pwr_tUInt32 val = ((cdh_sObjName *) keyp)->pack.key;
      key = ((val * 127) ^ (val * 131)) % ghtp->size;
    }
    break;
  case hash_eKey_memcmp:
    {
      const char *s = keyp;
      pwr_tUInt32 val = 0;
      int i = ghtp->key_size;

      for (s = keyp; i > 0; s++, i--)
	val += val*3 + *s;
      key = val % ghtp->size;
    }
    break;
  case hash_eKey_strncmp:
    {
      const char *s = keyp;
      pwr_tUInt32 val = 0;
      int i = ghtp->key_size;

      for (s = keyp; *s != '\0' && i > 0; s++, i--)
	val += val*3 + *s;
      key = val % ghtp->size;
    }
    break;
  case hash_eKey_uint16:
    {
      pwr_tUInt32 val = *(pwr_tUInt16 *) keyp;
      key = ((val * 127) ^ (val * 131)) % ghtp->size;
    }
    break;
  case hash_eKey_user:
    if (htp->xform_f != NULL)
      key = htp->xform_f(keyp, ghtp->size);
    else
      errh_Bugcheck(HASH__BUGCHECK, "");
    break;
  default:
    errh_Bugcheck(HASH__BUGCHECK, "");
  }

  ghtp->xforms++;

  /* Walk the chain starting in this pht entry */

  found = NO;
  lh = htp->tp + key; /* NOTE: Pointer arithmetic */
  depth = 0;
  for (il = pool_Qsucc(sts, htp->php, lh); il != lh; il =  pool_Qsucc(sts, htp->php, il)) {
    ip = (char *) il - ghtp->link_offset;
    depth++;
    ghtp->comps++;

    switch (ghtp->key_type) {
    case hash_eKey_oid:
      {
	pwr_tObjid *xkey = (pwr_tObjid *) (ip + ghtp->key_offset);
	pwr_tObjid *ykey = (pwr_tObjid *) keyp;
	found = (xkey->oix == ykey->oix && xkey->vid == ykey->vid);
      }
      break;
    case hash_eKey_int32:
      {
	pwr_tUInt32 *xkey = (pwr_tUInt32 *) (ip + ghtp->key_offset);
	pwr_tUInt32 *ykey = (pwr_tUInt32 *) keyp;
	found = *xkey == *ykey;
      }
      break;
    case hash_eKey_family:
      {
	cdh_sFamily *xkey = (cdh_sFamily *) (ip + ghtp->key_offset);
	cdh_sFamily *ykey = (cdh_sFamily *) keyp;
	found = (xkey->name.pack.key == ykey->name.pack.key &&
	  xkey->poid.oix == ykey->poid.oix && xkey->poid.vid == ykey->poid.vid &&
	  strcmp(xkey->name.norm, ykey->name.norm) == 0);
      }
      break;
    case hash_eKey_objName:
      {
	cdh_sObjName *xkey = (cdh_sObjName *) (ip + ghtp->key_offset);
	cdh_sObjName *ykey = (cdh_sObjName *) keyp;
	found = (xkey->pack.key == ykey->pack.key && strcmp(xkey->norm, ykey->norm) == 0);
      }
      break;
    case hash_eKey_memcmp:
      found = memcmp(ip + ghtp->key_offset, keyp, ghtp->key_size) == 0;
      break;
    case hash_eKey_strncmp:
      found = strncmp(ip + ghtp->key_offset, keyp, ghtp->key_size) == 0;
      break;
    case hash_eKey_uint16:
      {
	pwr_tUInt16 *xkey = (pwr_tUInt16 *) (ip + ghtp->key_offset);
	pwr_tUInt16 *ykey = (pwr_tUInt16 *) keyp;
	found = *xkey == *ykey;
      }
    case hash_eKey_user:
      if (htp->comp_f != NULL)
	found = htp->comp_f(keyp, ip);
      else
	errh_Bugcheck(HASH__BUGCHECK, "");
      break;
    default:
      errh_Bugcheck(HASH__BUGCHECK, "");
    }
    if (found) break;
  }

  if (depth > ghtp->max_depth) ghtp->max_depth = depth;

  if (bp != NULL) *bp = (void *)(lh);

  if (!found) {
    ghtp->no_finds++;
    pwr_Return(NULL, sts, HASH__NOTFOUND);
  }

  ghtp->finds++;
  pwr_Return(il, sts, HASH__SUCCESS);
}
示例#26
0
void
sancm_FlushNode (
    pwr_tStatus		*status,
    gdb_sNode		*np
)
{
    pool_sQlink		*ol;
    gdb_sObject		*op;

    if (status != NULL) *status = 1;

    gdb_AssumeLocked;

    for (
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAdd_lh);
        ol != &np->sancAdd_lh;
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAdd_lh)
    ) {
        op = pool_Qitem(ol, gdb_sObject, u.c.sanc_ll);

        pwr_Assert(op->u.c.flags.b.sancAdd);
        pool_Qremove(NULL, gdbroot->pool, &op->u.c.sanc_ll);
        op->u.c.flags.b.sancAdd = 0;
        pwr_Assert((op->u.c.flags.m & gdb_mCo_inSancList) == 0);
        pwr_Assert(np->sancAdd_lc != 0);
        np->sancAdd_lc--;
    }
    pwr_Assert(np->sancAdd_lc == 0);

    for (
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAct_lh);
        ol != &np->sancAct_lh;
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAct_lh)
    ) {
        op = pool_Qitem(ol, gdb_sObject, u.c.sanc_ll);

        pwr_Assert(op->u.c.flags.b.sancAct);
        pool_Qremove(NULL, gdbroot->pool, &op->u.c.sanc_ll);
        op->u.c.flags.b.sancAct = 0;
        pwr_Assert((op->u.c.flags.m & gdb_mCo_inSancList) == 0);
        pwr_Assert(np->sancAct_lc != 0);
        np->sancAct_lc--;
    }
    pwr_Assert(np->sancAct_lc == 0);

    for (
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancRem_lh);
        ol != &np->sancRem_lh;
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancRem_lh)
    ) {
        op = pool_Qitem(ol, gdb_sObject, u.c.sanc_ll);

        pwr_Assert(op->u.c.flags.b.sancRem);
        pool_Qremove(NULL, gdbroot->pool, &op->u.c.sanc_ll);
        op->u.c.flags.b.sancRem = 0;
        pwr_Assert((op->u.c.flags.m & gdb_mCo_inSancList) == 0);
        pwr_Assert(np->sancRem_lc != 0);
        np->sancRem_lc--;
    }
    pwr_Assert(np->sancRem_lc == 0);

    return;
}
示例#27
0
void
sancm_Add (
    pwr_tStatus		*status,
    gdb_sNode		*np
)
{
    net_sSanAdd		*ap;
    pool_sQlink		*ol;
    gdb_sObject		*op;
    int			count;
    int			i;
    qcom_sQid		tgt;

    if (status != NULL) *status = 1;

    gdb_AssumeLocked;

    if (np->sancAdd_lc == 0) return;
    count = MIN(np->sancAdd_lc, net_cSanMaxAdd);
    ap = malloc(sizeof(net_sSanAdd) + (count - 1) * sizeof(ap->sane[0]));
    if (ap == NULL) return;

    tgt.nid = np->nid;
    tgt.qix = net_cProcHandler;

    for (
        i = 0, ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAdd_lh);
        ol != &np->sancAdd_lh;
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancAdd_lh)
    ) {
        op = pool_Qitem(ol, gdb_sObject, u.c.sanc_ll);

        ap->sane[i].oid = op->g.oid;
        ap->sane[i].sid = op->u.c.sanid;
        i++;
        pwr_Assert(op->u.c.flags.b.sancAdd);
        pool_Qremove(NULL, gdbroot->pool, &op->u.c.sanc_ll);
        op->u.c.flags.b.sancAdd = 0;
        pwr_Assert((op->u.c.flags.m & gdb_mCo_inSancList) == 0);
        pwr_Assert(np->sancAdd_lc != 0);
        np->sancAdd_lc--;
        pwr_Assert(!op->u.c.flags.b.sancAct);
        pool_QinsertPred(NULL, gdbroot->pool, &op->u.c.sanc_ll, &np->sancAct_lh);
        op->u.c.flags.b.sancAct = 1;
        np->sancAct_lc++;
        if (i >= count) {
            ap->count = count;
            gdb_Unlock;
            net_Put(NULL, &tgt, ap, net_eMsg_sanAdd, 0, pwr_Offset(ap, sane[i]), 0);
            gdb_Lock;
            i = 0;
        }
    }

    pwr_Assert(np->sancAdd_lc == 0);

    /* Send remaining san entries.  */

    if (i > 0) {
        ap->count = i;
        gdb_Unlock;
        net_Put(NULL, &tgt, ap, net_eMsg_sanAdd, 0, pwr_Offset(ap, sane[i]), 0);
        gdb_Lock;
    }

    free(ap);
}
示例#28
0
void
sancm_Remove (
    pwr_tStatus		*status,
    gdb_sNode		*np
)
{
    net_sSanRemove	*rp;
    pool_sQlink		*ol;
    gdb_sObject		*op;
    int			count;
    int			i;
    qcom_sQid		tgt;

    if (status != NULL) *status = 1;

    gdb_AssumeLocked;

    if (np->sancRem_lc == 0) return;

    count = MIN(np->sancRem_lc, net_cSanMaxRemove);
    rp = malloc(sizeof(net_sSanRemove) + (count - 1) * sizeof(rp->sid[0]));
    if (rp == NULL) return;

    tgt.nid = np->nid;
    tgt.qix = net_cProcHandler;

    for (
        i = 0, ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancRem_lh);
        ol != &np->sancRem_lh;
        ol = pool_Qsucc(NULL, gdbroot->pool, &np->sancRem_lh)
    ) {
        op = pool_Qitem(ol, gdb_sObject, u.c.sanc_ll);

        rp->sid[i] = op->u.c.sanid;
        i++;
        pwr_Assert(op->u.c.flags.b.sancRem);
        pool_Qremove(NULL, gdbroot->pool, &op->u.c.sanc_ll);
        op->u.c.flags.b.sancRem = 0;
        pwr_Assert((op->u.c.flags.m & gdb_mCo_inSancList) == 0);
        pwr_Assert(np->sancRem_lc != 0);
        np->sancRem_lc--;
#if 0
        cvolc_TrimObject(op);
#endif
        if (i >= count) {
            rp->count = count;
            gdb_Unlock;
            net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, pwr_Offset(rp, sid[i]), 0);
            gdb_Lock;
            i = 0;
        }
    }

    pwr_Assert(np->sancRem_lc == 0);

    /* Send remaining san removes.  */

    if (i > 0) {
        rp->count = count;
        gdb_Unlock;
        net_Put(NULL, &tgt, rp, net_eMsg_sanRemove, 0, pwr_Offset(rp, sid[i]), 0);
        gdb_Lock;
    }

    free(rp);
}
示例#29
0
static void
respondObject (
  qcom_sGet		*get,
  gdb_sObject		*op,
  pwr_tInt32		lcount,
  pwr_tInt32		rcount
)
{
  pwr_tStatus		sts;
  qcom_sPut		put;
  gdb_sObject		*pop;
  net_sObjectR		*rsp;
  net_sGobject		*gop;
  net_sGobject		*go[net_cObjectMaxCount];
  pwr_tUInt32		count;
  pwr_tUInt32		pcount;
  pwr_tUInt32		size;
  pwr_tInt32		i;
  pool_sQlink		*sol;
  gdb_sObject		*sop;
      
  gdb_AssumeLocked;

  /* The parents must be first in the message, so the receiver can link
     the cache objects. They must be in top-down-order. */

  pop = op;
  pcount = 0;
  count = 0;
  while (pop->g.oid.oix != pwr_cNObjectIx && count < net_cObjectMaxCount - 1) {
    pop = pool_Address(NULL, gdbroot->pool, pop->l.por);
    go[count++] = &pop->g;
  }

  pcount = count;
  pop = pool_Address(NULL, gdbroot->pool, op->l.por);

  if (pop != NULL) {
    /* Left siblings. (At most lcount of them.) */

    for (
      i = 0, sol = pool_Qpred(NULL, gdbroot->pool, &op->u.n.sib_ll);
      i < lcount && sol != &pop->u.n.sib_lh && count < net_cObjectMaxCount - 1;
      i++, sol = pool_Qpred(NULL, gdbroot->pool, sol)
    ) {
      sop = pool_Qitem(sol, gdb_sObject, u.n.sib_ll);
      go[count++] = &sop->g;
    }

    /* Right siblings. (At most rcount of them.) */

    for (
      i = 0, sol = pool_Qsucc(NULL, gdbroot->pool, &op->u.n.sib_ll);
      i < rcount && sol != &pop->u.n.sib_lh && count < net_cObjectMaxCount - 1;
      i++, sol = pool_Qsucc(NULL, gdbroot->pool, sol)
    ) {
      sop = pool_Qitem(sol, gdb_sObject, u.n.sib_ll);
      go[count++] = &sop->g;
    }
  }

  /* Build response message.  */

  size = sizeof(net_sObjectR) + count * sizeof(net_sGobject);
  rsp = net_Alloc(&sts, &put, size, net_eMsg_objectR);
  if (rsp == NULL) {
    printf("NETH: could not allocate pams buffer for Cache send response, sts: %d\n", sts);
    respondError(get, op->g.oid, sts);
    return;
  }
  gop = &rsp->g[0];

  /* Copy parent objects.  */
  for (i = pcount - 1; i >= 0; i--)
    *gop++ = *(go[i]);

  /* Copy target object.  */
  *gop++ = op->g;

  /* Copy sibling objects.  */
  for (i = pcount; i < count; i++)
    *gop++ = *(go[i]);

  rsp->sts    = sts;
  rsp->oid    = op->g.oid;
  rsp->count  = count + 1;

  if (!net_Reply(&sts, get, &put, 0))
    errh_Bugcheck(sts, "net_Reply");
}
示例#30
0
pwr_tUInt32 sansm_Update(gdb_sNode* np)
{
  static net_sSanUpdate* up = NULL;
  static san_sServer** spl = NULL;
  int i;
  pwr_tStatus sts;
  pwr_tUInt32 gen;
  pool_sQlink* sl;
  san_sServer* sp;
  qcom_sQid tgt;

  gdb_AssumeLocked;

  if (pool_QisEmpty(NULL, gdbroot->pool, &np->sansUpd_lh))
    return 0;

  if (up == NULL) {
    up = malloc(sizeof(*up) + (net_cSanMaxUpdate - 1) * sizeof(up->data[0]));
    spl = malloc(sizeof(san_sServer*) * net_cSanMaxUpdate);
  }

  for (i = 0, sl = pool_Qsucc(NULL, gdbroot->pool, &np->sansUpd_lh);
       sl != &np->sansUpd_lh && i < net_cSanMaxUpdate; i++) {
    sp = pool_Qitem(sl, san_sServer, sansUpd_ll);
    sl = pool_Qsucc(NULL, gdbroot->pool, sl);

    pwr_Assert(sp->flags.b.sansUpd);

    up->data[i].al = sp->al;
    up->data[i].sane = sp->sane;
    spl[i] = sp;
  }

  up->count = i;

  tgt.nid = np->nid;
  tgt.qix = net_cProcHandler;

  gen = np->sans_gen;

  gdb_Unlock;
  net_Put(&sts, &tgt, up, net_eMsg_sanUpdate, 0, pwr_Offset(up, data[i]), 0);
  gdb_Lock;

  if (EVEN(sts))
    return 0;

  if (gen == np->sans_gen) {
    for (i = 0; i < up->count; i++) {
      sp = spl[i];
      pwr_Assert(sp->flags.b.sansUpd);
      pool_Qremove(NULL, gdbroot->pool, &sp->sansUpd_ll);
      sp->flags.b.sansUpd = 0;
    }

  } else {
    for (i = 0; i < up->count; i++) {
      sp = hash_Search(NULL, gdbroot->sans_ht, &up->data[i].sane.sid);
      if (sp != NULL) {
        pwr_Assert(sp->flags.b.sansUpd);
        pool_Qremove(NULL, gdbroot->pool, &sp->sansUpd_ll);
        sp->flags.b.sansUpd = 0;
      }
    }
  }

  return up->count;
}