本文整理汇总了C++中EXA_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ EXA_ASSERT函数的具体用法?C++ EXA_ASSERT怎么用?C++ EXA_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EXA_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __rdev_perf_make_request
void __rdev_perf_make_request(device_t *disk_device, header_t *req_header)
{
uint64_t now_ms = os_gettimeofday_msec();
uint64_t inter_arrival;
int rw = -1;
EXA_ASSERT(NBD_REQ_TYPE_IS_VALID(req_header->request_type));
switch (req_header->request_type)
{
case NBD_REQ_TYPE_READ:
rw = __READ;
break;
case NBD_REQ_TYPE_WRITE:
rw = __WRITE;
break;
case NBD_REQ_TYPE_LOCK:
case NBD_REQ_TYPE_UNLOCK:
EXA_ASSERT(false);
/* FIXME: formerly this case was not handled */
}
/* WARNING: be careful, although the first call is taken into account
* here (for the inter-arrival time), the first exaperf log should not
* be taken into consideration for the analysis. Max and mean value
* are very big because of the history of the IOs. This happens even
* if we start/stop the cluser between two experiments. */
if (disk_device->last_req_time[rw] != 0)
{
inter_arrival = now_ms - disk_device->last_req_time[rw];
exaperf_repart_add_value(disk_device->inter_arrival_repart[rw],
inter_arrival);
}
disk_device->last_req_time[rw] = now_ms;
req_header->rdev_submit_date = now_ms;
}
示例2: algopr_send_data
int algopr_send_data(exa_nodeid_t node_id, void *buffer1, int size1,
void *buffer2, int size2)
{
payload_t *payload;
EXA_ASSERT(EXA_NODEID_VALID(node_id));
/* FIXME see comment above definition of SIZEOF_ALGOPR_MSGNETWORK_T */
EXA_ASSERT(size1 == SIZEOF_ALGOPR_MSGNETWORK_T);
/* Send is local, just forwrd it */
if (node_id == this_node_id)
{
algopr_new_msg(buffer1, size1, buffer2, size2);
return 1;
}
/* Note: All nbd lists send_list[] share the same root so here we don't
* care in which one is picked up the buffer */
payload = nbd_list_remove(ð.send_list[0].root->free, NULL, LISTWAIT);
EXA_ASSERT(payload != NULL);
memcpy(payload->payload, buffer1, size1);
payload->size1 = size1;
payload->size2 = size2;
payload->buffer = buffer2;
nbd_list_post(ð.send_list[node_id], payload, -1);
wq_wake(ð.wq_send);
return 1;
}
示例3: writewrap
static void
writewrap(exa_ringbuf_t *rng, const char *buf, size_t nbytes)
{
char *data = rng->data;
int n;
EXA_ASSERT(nbytes < rng->size);
if (rng->pWr + nbytes >= rng->size)
{
/* wrap around */
n = rng->size - rng->pWr;
memcpy(data + rng->pWr, buf, n);
nbytes -= n;
buf += n;
rng->pWr = 0;
}
/* direct write */
memcpy(data + rng->pWr, buf, nbytes);
rng->pWr += nbytes;
EXA_ASSERT(rng->pRd < rng->size);
EXA_ASSERT(rng->pWr < rng->size);
}
示例4: vrt_cmd_volume_create
/**
* Create a volume in a given group
*
* @param[in] params The parsed command array
*
* The real parameters passed in the array are:
* - UUID of the group in which the volume has to be created
* - Name of the volume to create
* - UUID of the volume to create
* - Size of the volume to create (in KB)
*
* @return 0 on success, a negative error code on failure
*/
static int
vrt_cmd_volume_create(const struct VrtVolumeCreate *cmd)
{
vrt_group_t *group;
vrt_volume_t *volume;
int ret;
EXA_ASSERT(cmd->volume_size > 0);
exalog_debug("create volume '%s': size %" PRIu64 " KB",
cmd->volume_name, cmd->volume_size);
group = vrt_get_group_from_uuid(&cmd->group_uuid);
if (group == NULL)
{
exalog_debug("Unknown group " UUID_FMT, UUID_VAL(&cmd->group_uuid));
return -VRT_ERR_UNKNOWN_GROUP_UUID;
}
/* !!! All sizes in 'cmd' are in KB and VRT internal functions want sizes in
* sectors.
*/
ret = vrt_group_create_volume(group, &volume, &cmd->volume_uuid, cmd->volume_name,
KBYTES_2_SECTORS(cmd->volume_size));
if (ret != EXA_SUCCESS)
{
exalog_error("Can't create volume '%s' in group '%s': %s(%d)",
cmd->volume_name, group->name, exa_error_msg(ret), ret);
vrt_group_unref(group);
return ret;
}
EXA_ASSERT(volume != NULL);
/* wipe the newly created volume
*
* FIXME: This code is called from all the clients while it should be done
* only once. To do so we should add a new RPC and trigger the wipping from
* admind.
*/
/* Let only one node (the first one) do the wipe */
if (vrt_node_get_upnode_id() == 0)
{
ret = vrt_group_wipe_volume(group, volume);
if (ret != EXA_SUCCESS)
{
exalog_error("Can't wipe volume '%s' in group '%s': %s(%d)",
volume->name, group->name, exa_error_msg(ret), ret);
/* Rollback volume creation */
vrt_group_delete_volume(group, volume);
vrt_group_unref(group);
return ret;
}
}
vrt_group_unref(group);
return EXA_SUCCESS;
}
示例5: storage_rdev_iterator_end
void storage_rdev_iterator_end(storage_rdev_iter_t *iter)
{
EXA_ASSERT(iter != NULL);
EXA_ASSERT(iter->storage != NULL);
iter->storage = NULL;
}
示例6: EXA_ASSERT
vrt_realdev_t *storage_rdev_iterator_get(storage_rdev_iter_t *iter)
{
const spof_group_t *spof_group;
vrt_realdev_t *rdev = NULL;
EXA_ASSERT(iter != NULL);
EXA_ASSERT(iter->storage != NULL);
if (iter->spof_group_index >= iter->storage->num_spof_groups)
return NULL;
spof_group = &iter->storage->spof_groups[iter->spof_group_index];
if (iter->realdev_index >= spof_group->nb_realdevs)
{
iter->realdev_index = 0;
iter->spof_group_index++;
return storage_rdev_iterator_get(iter);
}
rdev = spof_group->realdevs[iter->realdev_index];
iter->realdev_index++;
return rdev;
}
示例7: __serverd_perf_end_request
void __serverd_perf_end_request(header_t *req_header)
{
double now = os_gettimeofday_msec();
int rw = -1;
EXA_ASSERT(NBD_REQ_TYPE_IS_VALID(req_header->request_type));
switch (req_header->request_type)
{
case NBD_REQ_TYPE_READ:
rw = __READ;
break;
case NBD_REQ_TYPE_WRITE:
rw = __WRITE;
break;
case NBD_REQ_TYPE_LOCK:
case NBD_REQ_TYPE_UNLOCK:
EXA_ASSERT(false);
/* FIXME: formerly this case was not handled */
}
exaperf_duration_record(header_dur[rw],
(double)now - req_header->header_submit_date);
if (rw == __WRITE)
exaperf_duration_record(data_dur,
(double)now - req_header->data_submit_date);
}
示例8: storage_spof_iterator_begin
void storage_spof_iterator_begin(storage_spof_iter_t *iter, const storage_t *storage)
{
EXA_ASSERT(iter != NULL);
EXA_ASSERT(storage != NULL);
iter->storage = storage;
iter->index = 0;
}
示例9: storage_rdev_iterator_begin
void storage_rdev_iterator_begin(storage_rdev_iter_t *iter, const storage_t *storage)
{
EXA_ASSERT(iter != NULL);
EXA_ASSERT(storage != NULL);
iter->storage = storage;
iter->spof_group_index = 0;
iter->realdev_index = 0;
}
示例10: td_merge_lock
/**
* merge the lock/unlock header to the list of the locked zone of the device
* set disk_device->locking_return according to the succes (0) or error (-1)
* of the merge
* @param disk_device device
* @param header lock/unlocking to merge
*/
static void td_merge_lock(device_t *disk_device, header_t *header)
{
int i;
EXA_ASSERT(header->type = NBD_HEADER_LOCK);
EXA_ASSERT(header->lock.op == NBD_REQ_TYPE_LOCK
|| header->lock.op == NBD_REQ_TYPE_UNLOCK);
switch (header->lock.op)
{
case NBD_REQ_TYPE_LOCK:
if (disk_device->nb_locked_zone > NBMAX_DISK_LOCKED_ZONES)
{
disk_device->locking_return = -1;
return;
}
else
{
struct locked_zone *locked_zone = &disk_device->locked_zone[disk_device->nb_locked_zone];
locked_zone->sector = header->lock.sector;
locked_zone->sector_count = header->lock.sector_nb;
disk_device->nb_locked_zone++;
disk_device->locking_return = 0;
}
return;
case NBD_REQ_TYPE_UNLOCK:
for (i = 0; i < disk_device->nb_locked_zone; i++)
{
struct locked_zone *locked_zone = &disk_device->locked_zone[i];
if (locked_zone->sector == header->lock.sector
&& locked_zone->sector_count == header->lock.sector_nb)
{
disk_device->locking_return = 0;
disk_device->nb_locked_zone--;
/* The array is not sorted but need to be consolidated, thus
* when removing an element which is not at the end, we fill
* the 'hole' by moving the last element to this place. */
if (i < disk_device->nb_locked_zone) /* last zone */
disk_device->locked_zone[i] = disk_device->locked_zone[disk_device->nb_locked_zone];
return;
}
}
disk_device->locking_return = -1;
return;
}
}
示例11: sup_cluster_node
/**
* Get the node within a cluster given its id.
*
* \param cluster Cluster to get the node from
* \param[in] node_id Id of node to get
*
* \return Node if found, NULL otherwise
*/
sup_node_t *
sup_cluster_node(const sup_cluster_t *cluster, exa_nodeid_t node_id)
{
EXA_ASSERT(cluster);
EXA_ASSERT(node_id < EXA_MAX_NODES_NUMBER);
if (cluster->nodes[node_id].id == EXA_NODEID_NONE)
return NULL;
return (sup_node_t *)&cluster->nodes[node_id];
}
示例12: exa_td_process_one_request
/**
* send one request to device, it validate there is no problem with the
*
* @header IN request to do
* OUT last request done
* @return EXA_RDEV_REQUEST_END_OK new request submitted successfully and header
* contains an old request succesfully done
* EXA_RDEV_REQUEST_END_ERROR new request submitted successfully
* and header contains an old request that fail
* RDEV_REQUEST_NOT_ENOUGH_FREE_REQ not enough resources to submit a new request
*/
static int exa_td_process_one_request(header_t **header,
device_t *disk_device)
{
void * buffer;
int sector_nb;
uint64_t sector;
int retval;
header_t *req_header = *header;
/* FIXME this is a ugly hack to prevent compiler to complain about
* uninitialized variable. Actually, this is because the request type
* itself is f***ed up (no type and the funky use os bit masks...)
* Please remove this whe reworking header_t content... */
rdev_op_t op = (rdev_op_t)-1;
/* submit this new request to exa_rdev and so to the disk driver */
sector_nb = req_header->io.desc.sector_nb;
buffer = req_header->io.buf;
sector = req_header->io.desc.sector;
EXA_ASSERT(NBD_REQ_TYPE_IS_VALID(req_header->io.desc.request_type));
switch (req_header->io.desc.request_type)
{
case NBD_REQ_TYPE_READ:
EXA_ASSERT(!req_header->io.desc.flush_cache);
op = RDEV_OP_READ;
break;
case NBD_REQ_TYPE_WRITE:
if (req_header->io.desc.flush_cache)
op = RDEV_OP_WRITE_BARRIER;
else
op = RDEV_OP_WRITE;
break;
}
/* Be carefull the 'header' pointer can be modified */
retval = exa_rdev_make_request_new(op, (void *)header,
sector + RDEV_RESERVED_AREA_IN_SECTORS,
sector_nb, buffer, disk_device->handle);
if (retval == RDEV_REQUEST_NOT_ENOUGH_FREE_REQ)
return RDEV_REQUEST_NOT_ENOUGH_FREE_REQ;
if (*header != NULL)
(*header)->io.desc.result = retval == RDEV_REQUEST_END_OK ? 0 : -EIO;
if (retval < 0)
return RDEV_REQUEST_END_ERROR;
return retval;
}
示例13: storage_get_spof_group_free_chunk_count
uint64_t storage_get_spof_group_free_chunk_count(const storage_t *storage,
spof_id_t spof_id)
{
spof_group_t *sg;
EXA_ASSERT(storage != NULL);
EXA_ASSERT(SPOF_ID_IS_VALID(spof_id));
sg = storage_get_spof_group_by_id(storage, spof_id);
EXA_ASSERT(sg != NULL);
return spof_group_free_chunk_count(sg);
}
示例14: __set_peer
/* If the peer is already known, this function doesn't do anything
(apart from checking that the IP address given is identical to the one
already known). Most notably, it leaves the peer's socket alone */
static void __set_peer(exa_nodeid_t node_id, const char *ip_addr)
{
peer_t *peer;
exalog_debug("setting peer %"PRInodeid": '%s'", node_id, ip_addr);
peer = &peers[node_id];
/* ip addr of a node can't change */
EXA_ASSERT(peer->ip_addr[0] == '\0' || strcmp(peer->ip_addr, ip_addr) == 0);
EXA_ASSERT(os_strlcpy(peer->ip_addr, ip_addr, sizeof(peer->ip_addr))
< sizeof(peer->ip_addr));
}
示例15: storage_set_chunk_size
/**
* Set the storage chunk size. This must only be done once (and never change).
*
* @param[in,out] storage Storage in which we set the size
* @param[in] chunk_size Size of chunks, in Kbytes
*
* @return 0 if successful, -EINVAL if the chunk size is invalid
*/
static int storage_set_chunk_size(storage_t *storage, uint32_t chunk_size)
{
EXA_ASSERT(storage);
/* We don't allow changing the storage's chunk size once it's been set */
EXA_ASSERT(storage->chunk_size == 0 || storage->chunk_size == chunk_size);
if (chunk_size == 0)
return -EINVAL;
storage->chunk_size = chunk_size;
return 0;
}