示例#1
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_merge_alloc_gop(ibp_context_t *ic, ibp_cap_t *mcap, ibp_cap_t *ccap, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    char hoststr[MAX_HOST_SIZE];
    char host[MAX_HOST_SIZE];
    char chost[MAX_HOST_SIZE];
    ibp_op_merge_alloc_t *cmd;
    int port, cport;

    log_printf(15, "set_ibp_merge_op: start. ic=%p\n", op->ic);

    init_ibp_base_op(op, "rename", timeout, op->ic->other_new_command, NULL, 1, IBP_RENAME, IBP_NOP);

    cmd = &(op->ops.merge_op);

    parse_cap(op->ic, mcap, host, &port, cmd->mkey, cmd->mtypekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[IBP_MERGE_ALLOCATE]));
    op->dop.cmd.hostport = strdup(hoststr);

    parse_cap(op->ic, ccap, chost, &cport, cmd->ckey, cmd->ctypekey);

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = merge_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = status_get_recv;

    return(ibp_get_gop(op));
}
示例#2
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_alloc_gop(ibp_context_t *ic, ibp_capset_t *caps, ibp_off_t size, ibp_depot_t *depot, ibp_attributes_t *attr,
                               int disk_cs_type, ibp_off_t disk_blocksize, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);

    char hoststr[MAX_HOST_SIZE];
    char pchost[MAX_HOST_SIZE];
    ibp_op_alloc_t *cmd;

    ibppc_form_host(op->ic, pchost, sizeof(pchost), depot->host, depot->rid);
    set_hostport(hoststr, sizeof(hoststr), pchost, depot->port, &(op->ic->cc[IBP_ALLOCATE]));

    init_ibp_base_op(op, "alloc", timeout, op->ic->other_new_command, strdup(hoststr), 1, IBP_ALLOCATE, IBP_NOP);

    cmd = &(op->ops.alloc_op);
    cmd->caps = caps;
    cmd->depot = depot;
    cmd->attr = attr;

    cmd->duration = cmd->attr->duration - time(NULL);  //** This is in sec NOT APR time
    if (cmd->duration < 0) cmd->duration = cmd->attr->duration;

    cmd->size = size;
    cmd->disk_chksum_type = disk_cs_type;
    cmd->disk_blocksize = disk_blocksize;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = allocate_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = allocate_recv;
    
    return(ibp_get_gop(op));
}
示例#3
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_query_resources_gop(ibp_context_t *ic, ibp_depot_t *depot, ibp_ridlist_t *rlist, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    if (op == NULL) return(NULL);
    
    char hoststr[MAX_HOST_SIZE];
    char pchoststr[MAX_HOST_SIZE];
    ibp_op_rid_inq_t *cmd = &(op->ops.rid_op);

    ibppc_form_host(op->ic, pchoststr, sizeof(pchoststr), depot->host, depot->rid);
    set_hostport(hoststr, sizeof(hoststr), pchoststr, depot->port, &(op->ic->cc[IBP_STATUS]));

    init_ibp_base_op(op, "query_resources", timeout, op->ic->other_new_command, strdup(hoststr),
                        op->ic->other_new_command, IBP_STATUS, IBP_ST_RES);

    cmd->depot = depot;
    cmd->rlist = rlist;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = query_res_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = query_res_recv;
    
    return(ibp_get_gop(op));
}
示例#4
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_depot_inq_gop(ibp_context_t *ic, ibp_depot_t *depot, char *password, ibp_depotinfo_t *di, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    if (op == NULL) return(NULL);

    char hoststr[MAX_HOST_SIZE];
    char pchost[MAX_HOST_SIZE];
    ibp_op_depot_inq_t *cmd = &(op->ops.depot_inq_op);

    ibppc_form_host(op->ic, pchost, sizeof(pchost), depot->host, depot->rid);
    set_hostport(hoststr, sizeof(hoststr), pchost, depot->port, &(op->ic->cc[IBP_STATUS]));

    init_ibp_base_op(op, "depot_inq", timeout, op->ic->other_new_command, strdup(hoststr),
                     op->ic->other_new_command, IBP_STATUS, IBP_ST_INQ);

    cmd->depot = depot;
    cmd->password = password;
    cmd->di = di;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = depot_inq_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = depot_inq_recv;

    return(ibp_get_gop(op));
}
示例#5
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_version_gop(ibp_context_t *ic, ibp_depot_t *depot, char *buffer, int buffer_size, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    if (op == NULL) return(NULL);

    char hoststr[MAX_HOST_SIZE];
    char pchoststr[MAX_HOST_SIZE];
    ibp_op_version_t *cmd = &(op->ops.ver_op);

    ibppc_form_host(op->ic, pchoststr, sizeof(pchoststr), depot->host, depot->rid);
    set_hostport(hoststr, sizeof(hoststr), pchoststr, depot->port, &(op->ic->cc[IBP_STATUS]));

    init_ibp_base_op(op, "depot_version", timeout, op->ic->other_new_command, strdup(hoststr),
                     op->ic->other_new_command, IBP_STATUS, IBP_ST_VERSION);

    cmd->depot = depot;
    cmd->buffer = buffer;
    cmd->buffer_size = buffer_size;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = depot_version_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = depot_version_recv;

    return(ibp_get_gop(op));
}
示例#6
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_truncate_gop(ibp_context_t *ic, ibp_cap_t *cap, ibp_off_t size, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    char hoststr[MAX_HOST_SIZE];
    int port;
    char host[MAX_HOST_SIZE];
    ibp_op_modify_alloc_t *cmd;

    init_ibp_base_op(op, "truncate_alloc", timeout, op->ic->other_new_command, NULL, 1, IBP_MANAGE, IBP_CHNG);

    cmd = &(op->ops.mod_alloc_op);

    parse_cap(op->ic, cap, host, &port, cmd->key, cmd->typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[IBP_MANAGE]));
    op->dop.cmd.hostport = strdup(hoststr);

    cmd->cap = cap;
    cmd->size = size;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = truncate_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = status_get_recv;

    return(ibp_get_gop(op));
}
示例#7
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_proxy_probe_gop(ibp_context_t *ic, ibp_cap_t *cap, ibp_proxy_capstatus_t *probe, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    char hoststr[MAX_HOST_SIZE];
    int port;
    char host[MAX_HOST_SIZE];
    ibp_op_probe_t *cmd;

    init_ibp_base_op(op, "proxy_probe", timeout, op->ic->other_new_command, NULL, 1, IBP_PROXY_MANAGE, IBP_PROBE);

    cmd = &(op->ops.probe_op);

    parse_cap(op->ic, cap, host, &port, cmd->key, cmd->typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[IBP_PROXY_MANAGE]));
    op->dop.cmd.hostport = strdup(hoststr);

    cmd->cap = cap;
    cmd->proxy_probe = probe;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = proxy_probe_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = proxy_probe_recv;

    return(ibp_get_gop(op));
}
示例#8
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_validate_chksum_gop(ibp_context_t *ic, ibp_cap_t *mcap, int correct_errors, int *n_bad_blocks,
        int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    char hoststr[MAX_HOST_SIZE];
    char host[MAX_HOST_SIZE];
    ibp_op_validate_chksum_t *cmd;
    int port;

    init_ibp_base_op(op, "validate_chksum", timeout, op->ic->other_new_command, NULL, 1, IBP_VALIDATE_CHKSUM, IBP_NOP);
    gop_op_generic_t *gop = ibp_get_gop(op);

    cmd = &(op->ops.validate_op);

    parse_cap(op->ic, mcap, host, &port, cmd->key, cmd->typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[IBP_VALIDATE_CHKSUM]));
    op->dop.cmd.hostport = strdup(hoststr);

    cmd = &(op->ops.validate_op);
    cmd->correct_errors = correct_errors;
    cmd->n_bad_blocks = n_bad_blocks;

    gop->op->cmd.send_command = validate_chksum_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = validate_chksum_recv;

    return(ibp_get_gop(op));
}
示例#9
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_copy_gop(ibp_context_t *ic, int mode, int ns_type,
                              char *path, ibp_cap_t *srccap, ibp_cap_t *destcap,
                              ibp_off_t src_offset, ibp_off_t dest_offset,
                              ibp_off_t size, int src_timeout,
                              int dest_timeout, int dest_client_timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    if (op == NULL) return(NULL);
    
    char hoststr[MAX_HOST_SIZE];
    int port;
    char host[MAX_HOST_SIZE];
    ibp_op_copy_t *cmd;

    init_ibp_base_op(op, "copy", src_timeout, op->ic->rw_new_command + size, NULL, size, IBP_SEND, IBP_NOP);

    cmd = &(op->ops.copy_op);

    parse_cap(op->ic, srccap, host, &port, cmd->src_key, cmd->src_typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[IBP_SEND]));
    op->dop.cmd.hostport = strdup(hoststr);

    cmd->ibp_command = mode;
    if (ns_type == NS_TYPE_PHOEBUS) {
        cmd->ctype = IBP_PHOEBUS;
        cmd->path = path;
        if (cmd->path == NULL) cmd->path = "auto";  //** If NULL default to auto
    } else {    //** All other ns types don't use the path
        cmd->ctype = IBP_TCP;
        cmd->path = "\0";
    }

    //** Want chksumming so tweak the command
    if (tbx_ns_chksum_is_valid(&(op->ncs)) == 1) {
        if (cmd->ibp_command == IBP_PUSH) {
            cmd->ibp_command = IBP_PUSH_CHKSUM;
        } else {
            cmd->ibp_command = IBP_PULL_CHKSUM;
        }
    }

    cmd->srccap = srccap;
    cmd->destcap = destcap;
    cmd->len = size;
    cmd->src_offset = src_offset;
    cmd->dest_offset = dest_offset;
    cmd->dest_timeout = dest_timeout;
    cmd->dest_client_timeout = dest_client_timeout;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = pushpull_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = copy_recv;

    return(ibp_get_gop(op));
}
示例#10
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_vec_write_gop(ibp_context_t *ic, ibp_cap_t *cap, int n_iovec, ibp_tbx_iovec_t *iovec, tbx_tbuf_t *buffer, ibp_off_t bpos, ibp_off_t len, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    if (op == NULL) return(NULL);
    gop_op_generic_t *gop = ibp_get_gop(op);

    set_ibp_rw_gop(op, IBP_WRITE, cap, 0, buffer, bpos, len, timeout);
    op->ops.rw_op.n_ops = 1;
    op->ops.rw_op.n_tbx_iovec_total = n_iovec;
    op->ops.rw_op.buf_single.n_iovec = n_iovec;
    op->ops.rw_op.buf_single.iovec = iovec;

    gop->op->cmd.send_command = vec_write_command;

    return(ibp_get_gop(op));
}
示例#11
0
int ibp_sync_command(ibp_op_t *iop)
{
    op_generic_t *gop = ibp_get_gop(iop);
    op_status_t status;

//** Submit if for execution
// gop->base.started_execution = 1;  //** Mark it as being submitted
// submit_hportal_sync(gop->op->pc, gop);

    gop_set_exec_mode(gop, OP_EXEC_DIRECT);
    gop_start_execution(gop);

//** and Wait for completion
    gop_waitany(gop);
    status = gop_get_status(gop);
    IBP_errno = status.error_code;

    if (gop->op->cmd.hostport != NULL) {
        free(gop->op->cmd.hostport);
        gop->op->cmd.hostport = NULL;
    }

    log_printf(10, "ibp_sync_command: IBP_errno=%d\n", IBP_errno); //tbx_log_flush();

    return(IBP_errno);
}
示例#12
0
ibp_depotinfo_t *IBP_status(ibp_depot_t *depot, int cmd, ibp_timer_t *timer, char *password,
                            unsigned long int  hard, unsigned long int soft, long duration)
{
    int err;
    ibp_op_t op;
    ibp_depotinfo_t *di = NULL;

    make_ibp_sync_context();

    init_ibp_op(_ibp_sync, &op);

    if (cmd == IBP_ST_INQ) {
        di = (ibp_depotinfo_t *)malloc(sizeof(ibp_depotinfo_t));
        assert(di != NULL);
        set_ibp_depot_inq_op(&op, depot, password, di, timer->ClientTimeout);
    } else {
        set_ibp_depot_modify_op(&op, depot, password, hard, soft, duration, timer->ClientTimeout);
    }

    err = ibp_sync_command(&op);
    gop_free(ibp_get_gop(&op), OP_FINALIZE);

    if (err != IBP_OK) {
        free(di);
        return(NULL);
    }
    return(di);
}
示例#13
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_proxy_modify_count_gop(ibp_context_t *ic, ibp_cap_t *cap, ibp_cap_t *mcap, int mode, int captype, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);

    set_ibp_generic_modify_count_op(IBP_PROXY_MANAGE, op, cap, mcap, mode, captype, timeout);

    return(ibp_get_gop(op));
}
示例#14
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_rw_gop(ibp_context_t *ic, int rw_type, ibp_cap_t *cap, ibp_off_t offset, tbx_tbuf_t *buffer, ibp_off_t bpos, ibp_off_t len, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    if (op == NULL) return(NULL);

    set_ibp_rw_gop(op, rw_type, cap, offset, buffer, bpos, len, timeout);

    return(ibp_get_gop(op));
}
示例#15
0
文件: op.c 项目: accre/lstore
void set_ibp_rw_gop(ibp_op_t *op, int rw_type, ibp_cap_t *cap, ibp_off_t offset, tbx_tbuf_t *buffer, ibp_off_t bpos, ibp_off_t len, int timeout)
{
    char hoststr[MAX_HOST_SIZE];
    int port;
    char host[MAX_HOST_SIZE];
    ibp_op_rw_t *cmd;
    ibp_rw_buf_t *rwbuf;

    cmd = &(op->ops.rw_op);

    init_ibp_base_op(op, "rw", timeout, op->ic->rw_new_command + len, NULL, len, rw_type, IBP_NOP);
    gop_op_generic_t *gop = ibp_get_gop(op);


    parse_cap(op->ic, cap, host, &port, cmd->key, cmd->typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[rw_type]));
    op->dop.cmd.hostport = strdup(hoststr);

    cmd->cap = cap;
    cmd->size = len; //** This is the total size

    rwbuf = &(cmd->buf_single);
    cmd->bs_ptr = rwbuf;
    cmd->rwbuf = &(cmd->bs_ptr);
    cmd->n_ops = 1;
    cmd->n_tbx_iovec_total = 1;
    cmd->rw_mode = rw_type;

    rwbuf->iovec = &(rwbuf->iovec_single);

    rwbuf->n_iovec = 1;
    rwbuf->iovec->offset = offset;
    rwbuf->iovec->len = len;
    rwbuf->buffer = buffer;
    rwbuf->boff = bpos;
    rwbuf->size = len;

    if (rw_type == IBP_WRITE) {
        gop->op->cmd.send_command = write_command;
        gop->op->cmd.send_phase = write_send;
        gop->op->cmd.recv_phase = write_recv;
        gop->op->cmd.on_submit = ibp_rw_submit_coalesce;
        gop->op->cmd.before_exec = ibp_rw_coalesce;
    } else {
        gop->op->cmd.send_command = read_command;
        gop->op->cmd.send_phase = NULL;
        gop->op->cmd.recv_phase = read_recv;
        gop->op->cmd.on_submit = ibp_rw_submit_coalesce;
        gop->op->cmd.before_exec = ibp_rw_coalesce;
    }

    op->ncs = op->ic->ncs;  //** Copy the default network chksum
}
示例#16
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_proxy_alloc_gop(ibp_context_t *ic, ibp_capset_t *caps, ibp_cap_t *mcap, ibp_off_t offset, ibp_off_t size,
                                     int duration, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    char hoststr[MAX_HOST_SIZE];
    char host[MAX_HOST_SIZE];
    ibp_op_alloc_t *cmd;
    int port;

    log_printf(15, "set_ibp_proxy_alloc_gop: start. ic=%p\n", op->ic);

    init_ibp_base_op(op, "rename", timeout, op->ic->other_new_command, NULL, 1, IBP_PROXY_ALLOCATE, IBP_NOP);

    cmd = &(op->ops.alloc_op);

    parse_cap(op->ic, mcap, host, &port, cmd->key, cmd->typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[IBP_PROXY_ALLOCATE]));
    op->dop.cmd.hostport = strdup(hoststr);

    cmd->offset = offset;
    cmd->size = size;
    if (duration == 0) {
        cmd->duration = 0;
    } else {
        cmd->duration = duration - time(NULL); //** This is in sec NOT APR time
    }


    cmd->caps = caps;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = proxy_allocate_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = allocate_recv;

    return(ibp_get_gop(op));
}
示例#17
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_depot_modify_gop(ibp_context_t *ic, ibp_depot_t *depot, char *password, ibp_off_t hard, ibp_off_t soft,
                                      int duration, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    if (op == NULL) return(NULL);

    ibp_op_depot_modify_t *cmd = &(op->ops.depot_modify_op);

    init_ibp_base_op(op, "depot_modify", timeout, op->ic->other_new_command, NULL,
                     op->ic->other_new_command, IBP_STATUS, IBP_ST_CHANGE);

    cmd->depot = depot;
    cmd->password = password;
    cmd->max_hard = hard;
    cmd->max_soft = soft;
    cmd->max_duration = duration;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = depot_modify_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = status_get_recv;

    return(ibp_get_gop(op));
}
示例#18
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_split_alloc_gop(ibp_context_t *ic, ibp_cap_t *mcap, ibp_capset_t *caps, ibp_off_t size,
                                     ibp_attributes_t *attr, int disk_cs_type, ibp_off_t disk_blocksize, int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);

    char hoststr[MAX_HOST_SIZE];
    char host[MAX_HOST_SIZE];
    ibp_op_alloc_t *cmd;
    int port;

    init_ibp_base_op(op, "split_allocate", timeout, op->ic->other_new_command, NULL, 1, IBP_SPLIT_ALLOCATE, IBP_NOP);

    cmd = &(op->ops.alloc_op);

    parse_cap(op->ic, mcap, host, &port, cmd->key, cmd->typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[IBP_SPLIT_ALLOCATE]));
    op->dop.cmd.hostport = strdup(hoststr);

    cmd = &(op->ops.alloc_op);
    cmd->caps = caps;
    cmd->attr = attr;

    cmd->duration = cmd->attr->duration - time(NULL);  //** This is in sec NOT APR time
    if (cmd->duration < 0) cmd->duration = cmd->attr->duration;

    cmd->size = size;
    cmd->disk_chksum_type = disk_cs_type;
    cmd->disk_blocksize = disk_blocksize;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = split_allocate_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = allocate_recv;

    return(ibp_get_gop(op));
}
示例#19
0
文件: op.c 项目: accre/lstore
gop_op_generic_t *ibp_context_chksum_get_gop(ibp_context_t *ic, ibp_cap_t *mcap,
        int chksum_info_only, int *cs_type, int *cs_size, ibp_off_t *blocksize,
        ibp_off_t *nblocks, ibp_off_t *nbytes, char *buffer, ibp_off_t bufsize,
        int timeout)
{
    ibp_op_t *op = new_ibp_op(ic);
    
    char hoststr[MAX_HOST_SIZE];
    char host[MAX_HOST_SIZE];
    ibp_op_get_chksum_t *cmd;
    int port;

    init_ibp_base_op(op, "get_chksum", timeout, op->ic->other_new_command, NULL, 1, IBP_VALIDATE_CHKSUM, IBP_NOP);
    gop_op_generic_t *gop = ibp_get_gop(op);

    cmd = &(op->ops.get_chksum_op);

    parse_cap(op->ic, mcap, host, &port, cmd->key, cmd->typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[IBP_VALIDATE_CHKSUM]));
    op->dop.cmd.hostport = strdup(hoststr);

    cmd->cap = mcap;
    cmd = &(op->ops.get_chksum_op);
    cmd->chksum_info_only = chksum_info_only;
    cmd->cs_type = cs_type;
    cmd->cs_size = cs_size;
    cmd->blocksize = blocksize;
    cmd->nblocks = nblocks;
    cmd->n_chksumbytes = nbytes;

    gop->op->cmd.send_command = get_chksum_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = get_chksum_recv;

    return(ibp_get_gop(op));
}
示例#20
0
unsigned long int IBP_phoebus_copy(char *path, ibp_cap_t *srccap, ibp_cap_t *destcap, ibp_timer_t  *src_timer, ibp_timer_t *dest_timer,
                                   ibp_off_t size, ibp_off_t offset)
{
    ibp_op_t op;
    int err;

    make_ibp_sync_context();

    init_ibp_op(_ibp_sync, &op);
    set_ibp_copyappend_op(&op, NS_TYPE_PHOEBUS, path, srccap, destcap, offset, size, src_timer->ClientTimeout,
                          dest_timer->ServerSync, dest_timer->ClientTimeout);
    err = ibp_sync_command(&op);
    gop_free(ibp_get_gop(&op), OP_FINALIZE);

    if (err != IBP_OK) return(0);
    return(size);
}
示例#21
0
int IBP_manage(ibp_cap_t *cap, ibp_timer_t  *timer, int cmd, int captype, ibp_capstatus_t *cs)
{
    ibp_op_t op;
    int err;

    make_ibp_sync_context();

    init_ibp_op(_ibp_sync, &op);

    log_printf(15, "IBP_manage: cmd=%d cap=%s cctype=%d\n", cmd, cap, op.ic->cc[IBP_MANAGE].type);
    fflush(stdout);

    err = 0;
    switch (cmd) {
    case IBP_INCR:
    case IBP_DECR:
        set_ibp_modify_count_op(&op, cap, cmd, captype, timer->ClientTimeout);
        break;
    case IBP_PROBE:
        set_ibp_probe_op(&op, cap, cs, timer->ClientTimeout);
        break;
    case IBP_CHNG:
        set_ibp_modify_alloc_op(&op, cap, cs->maxSize, cs->attrib.duration, cs->attrib.reliability, timer->ClientTimeout);
        break;
    default:
        err = 1;
        log_printf(0, "IBP_manage:  Invalid command: %d\n", cmd);
    }

    log_printf(15, "AFTER IBP_manage: cmd=%d cap=%s cctype=%d\n", cmd, cap, op.ic->cc[IBP_MANAGE].type);
    fflush(stdout);

    if (err == 0) {
        ibp_sync_command(&op);
    } else {
        IBP_errno = IBP_E_INVALID_PARAMETER;
    }

    gop_free(ibp_get_gop(&op), OP_FINALIZE);

    if (IBP_errno != IBP_OK) return(-1);
    return(0);
}
示例#22
0
unsigned long int IBP_load(ibp_cap_t *cap, ibp_timer_t  *timer, char *data,
                           unsigned long int size, unsigned long int offset)
{
    ibp_op_t op;
    int err;
    tbx_tbuf_t buf;

    tbx_tbuf_single(&buf, size, data);

    make_ibp_sync_context();

    init_ibp_op(_ibp_sync, &op);
    set_ibp_read_op(&op, cap, offset, &buf, 0, size, timer->ClientTimeout);
    err = ibp_sync_command(&op);
    gop_free(ibp_get_gop(&op), OP_FINALIZE);

    if (err != IBP_OK) return(0);
    return(size);
}
示例#23
0
文件: op.c 项目: accre/lstore
void set_ibp_generic_modify_count_op(int command, ibp_op_t *op, ibp_cap_t *cap, ibp_cap_t *mcap, int mode, int captype, int timeout)
{
    char hoststr[MAX_HOST_SIZE];
    int port;
    char host[MAX_HOST_SIZE];
    ibp_op_probe_t *cmd;

    if ((command != IBP_MANAGE) && (command != IBP_PROXY_MANAGE)) {
        log_printf(0, "set_ibp_generic_modify_count_op: Invalid command! should be IBP_MANAGE or IBP_PROXY_MANAGE.  Got %d\n", command);
        return;
    }
    if ((mode != IBP_INCR) && (mode != IBP_DECR)) {
        log_printf(0, "ibp_modify_count_gop: Invalid mode! should be IBP_INCR or IBP_DECR\n");
        return;
    }
    if ((captype != IBP_WRITECAP) && (captype != IBP_READCAP)) {
        log_printf(0, "ibp_modify_count_gop: Invalid captype! should be IBP_READCAP or IBP_WRITECAP\n");
        return;
    }

    init_ibp_base_op(op, "modify_count", timeout, op->ic->other_new_command, NULL, 1, command, mode);

    cmd = &(op->ops.probe_op);

    parse_cap(op->ic, cap, host, &port, cmd->key, cmd->typekey);
    set_hostport(hoststr, sizeof(hoststr), host, port, &(op->ic->cc[command]));
    op->dop.cmd.hostport = strdup(hoststr);

    if (command == IBP_PROXY_MANAGE) parse_cap(op->ic, mcap, host, &port, cmd->mkey, cmd->mtypekey);

    cmd->cmd = command;
    cmd->cap = cap;
    cmd->mode = mode;
    cmd->captype = captype;

    gop_op_generic_t *gop = ibp_get_gop(op);
    gop->op->cmd.send_command = modify_count_command;
    if (command == IBP_PROXY_MANAGE) gop->op->cmd.send_command = proxy_modify_count_command;
    gop->op->cmd.send_phase = NULL;
    gop->op->cmd.recv_phase = status_get_recv;
}
示例#24
0
ibp_capset_t *IBP_allocate(ibp_depot_t  *depot, ibp_timer_t *timer, unsigned long int size, ibp_attributes_t *attr)
{
    ibp_op_t op;
    int err;

    make_ibp_sync_context();

    ibp_capset_t *cs = (ibp_capset_t *)malloc(sizeof(ibp_capset_t));
    assert(cs != NULL);

    init_ibp_op(_ibp_sync, &op);
    set_ibp_alloc_op(&op, cs, size, depot, attr, CHKSUM_DEFAULT, 0, timer->ClientTimeout);
    err = ibp_sync_command(&op);
    gop_free(ibp_get_gop(&op), OP_FINALIZE);

    if (err != IBP_OK) {
        free(cs);
        cs = NULL;
    }

    return(cs);
}