コード例 #1
0
ファイル: arp_exist.c プロジェクト: ychtiger/capiflash
// if successful returns length of value
int ark_exist_start(_ARK *_arkp, int tid, tcb_t *tcbp)
{
  scb_t            *scbp     = &(_arkp->poolthreads[tid]);
  rcb_t            *rcbp     = &(_arkp->rcbs[tcbp->rtag]);
  ark_io_list_t    *bl_array = NULL;
  int32_t           rc       = 0;
  int32_t           state    = ARK_CMD_DONE;

  // Now that we have the hash entry, get the block
  // that holds the control information for the entry.
  tcbp->hblk = HASH_LBA(HASH_GET(_arkp->ht, rcbp->pos));

  // If there is no control block for this hash
  // entry, then the key is not present in the hash.
  // Set the error
  if ( tcbp->hblk == 0 )
  {
    KV_TRC_FFDC(pAT, "rc = ENOENT key %p, klen %"PRIu64"",
                 rcbp->key, rcbp->klen);
    rcbp->res   = -1;
    rcbp->rc = ENOENT;
    state = ARK_CMD_DONE;
    goto ark_exist_start_err;
  }

  // Set up the in-buffer to read in the hash bucket
  // that contains the key
  tcbp->blen = bl_len(_arkp->bl, tcbp->hblk);
  rc = bt_growif(&(tcbp->inb), &(tcbp->inb_orig), &(tcbp->inblen), 
                  (tcbp->blen * _arkp->bsize));
  if (rc != 0)
  {
    rcbp->res = -1;
    rcbp->rc = rc;
    state = ARK_CMD_DONE;
    goto ark_exist_start_err;
  }

  // Create a chain of blocks to be passed to be read
  bl_array = bl_chain(_arkp->bl, tcbp->hblk, tcbp->blen);
  if (bl_array == NULL)
  {
    rcbp->rc = ENOMEM;
    rcbp->res = -1;
    state = ARK_CMD_DONE;
    goto ark_exist_start_err;
  }

  scbp->poolstats.io_cnt += tcbp->blen;

  rc = ea_async_io_mod(_arkp, ARK_EA_READ, (void *)tcbp->inb, bl_array, 
                   tcbp->blen, 0, tcbp->ttag, ARK_EXIST_FINISH);
  if (rc < 0)
  {
    rcbp->rc = -rc;
    rcbp->res = -1;
    state = ARK_CMD_DONE;
    goto ark_exist_start_err;
  }
  else if (rc == 0)
  {
    state = ARK_IO_HARVEST;
  }
  else
  {
    state = ark_exist_finish(_arkp, tid, tcbp);
  }

ark_exist_start_err:

  return state;
}
コード例 #2
0
ファイル: arp_exist.c プロジェクト: bedrisendir/capiflash
// if successful returns length of value
void ark_exist_start(_ARK *_arkp, int tid, tcb_t *tcbp)
{
  scb_t         *scbp     = &(_arkp->poolthreads[tid]);
  rcb_t         *rcbp     = &(_arkp->rcbs[tcbp->rtag]);
  tcb_t         *iotcbp   = &(_arkp->tcbs[rcbp->ttag]);
  iocb_t        *iocbp    = &(_arkp->iocbs[rcbp->ttag]);
  ark_io_list_t *bl_array = NULL;
  int32_t        rc       = 0;

  // Now that we have the hash entry, get the block
  // that holds the control information for the entry.
  tcbp->hblk = HASH_LBA(HASH_GET(_arkp->ht, rcbp->pos));

  // If there is no control block for this hash
  // entry, then the key is not present in the hash.
  // Set the error
  if ( tcbp->hblk == 0 )
  {
    KV_TRC_FFDC(pAT, "rc = ENOENT key %p, klen %"PRIu64" ttag:%d",
                 rcbp->key, rcbp->klen, tcbp->ttag);
    rcbp->res   = -1;
    rcbp->rc = ENOENT;
    tcbp->state = ARK_CMD_DONE;
    goto ark_exist_start_err;
  }

  // Set up the in-buffer to read in the hash bucket
  // that contains the key
  tcbp->blen = bl_len(_arkp->bl, tcbp->hblk);
  rc = bt_growif(&(tcbp->inb), &(tcbp->inb_orig), &(tcbp->inblen), 
                  (tcbp->blen * _arkp->bsize));
  if (rc != 0)
  {
    KV_TRC_FFDC(pAT, "bt_growif failed tcbp:%p ttag:%d", tcbp, tcbp->ttag);
    rcbp->res = -1;
    rcbp->rc = rc;
    tcbp->state = ARK_CMD_DONE;
    goto ark_exist_start_err;
  }

  // Create a chain of blocks to be passed to be read
  bl_array = bl_chain(_arkp->bl, tcbp->hblk, tcbp->blen);
  if (bl_array == NULL)
  {
    KV_TRC_FFDC(pAT, "bl_chain failed tcbp:%p ttag:%d", tcbp, tcbp->ttag);
    rcbp->rc = ENOMEM;
    rcbp->res = -1;
    tcbp->state = ARK_CMD_DONE;
    goto ark_exist_start_err;
  }

  scbp->poolstats.io_cnt += tcbp->blen;

  KV_TRC_IO(pAT, "read hash entry ttag:%d", tcbp->ttag);
  ea_async_io_init(_arkp, ARK_EA_READ, (void *)tcbp->inb, bl_array,
                   tcbp->blen, 0, tcbp->ttag, ARK_EXIST_FINISH);
  if (ea_async_io_schedule(_arkp, tid, iotcbp, iocbp) &&
      ea_async_io_harvest (_arkp, tid, iotcbp, iocbp, rcbp))
  {
      ark_exist_finish(_arkp, tid, tcbp);
  }

ark_exist_start_err:

  return;
}