Example #1
0
void mp_remove_1_svc_nb(void * pt_req, 
                        rozorpc_srv_ctx_t *rozorpc_srv_ctx_p,
                        void * pt_resp, 
			uint32_t cnx_id) {

    mp_status_ret_t * ret = (mp_status_ret_t *) pt_resp;
    mp_remove_arg_t * args = (mp_remove_arg_t*) pt_req;
    storage_t *st = 0;
    
    DEBUG_FUNCTION;

    START_PROFILING(remove);

    ret->status = MP_FAILURE;

    if ((st = storaged_lookup(args->cid, args->sid)) == 0) {
        ret->mp_status_ret_t_u.error = errno;
        goto out;
    }
    

    if (storage_rm_file(st, (unsigned char *) args->fid) != 0) {
        ret->mp_status_ret_t_u.error = errno;
        goto out;
    }

    ret->status = MP_SUCCESS;

    
out:
    STOP_PROFILING(remove);
}
Example #2
0
static inline storage_t * get_storage(cid_t cid, sid_t sid, uint32_t cnx_id) {
  storage_t * st;

  /*
  ** Retrieve storage context used for this connection
  */
  if (cnx_id<MAX_STORAGED_CNX_TBL) {
    st = st_per_cnx[cnx_id];
    if ((st!=NULL) 
    &&  (st->cid == cid) 
    &&  (st->sid == sid)) return st;
  }
  
  /*
  ** Lookup for the storaage the request argument
  */
  st = storaged_lookup(cid, sid);
  
  /*
  ** Save the storage in the connection table
  */
  if (cnx_id<MAX_STORAGED_CNX_TBL) {
    st_per_cnx[cnx_id] = st;
  }
  
  return st;
}
Example #3
0
sp_read_ret_t *sp_read_1_svc(sp_read_arg_t * args, struct svc_req * req) {
    static sp_read_ret_t ret;
    uint32_t psize;
    storage_t *st = 0;
    DEBUG_FUNCTION;

    START_PROFILING_IO(read,
            args->nrb * rozofs_psizes[args->tid] * sizeof (bin_t));

    xdr_free((xdrproc_t) xdr_sp_read_ret_t, (char *) &ret);
    ret.status = SP_FAILURE;

    if ((st = storaged_lookup(args->sid)) == 0) {
        ret.sp_read_ret_t_u.error = errno;
        goto out;
    }
    psize = rozofs_psizes[args->tid];
    ret.sp_read_ret_t_u.bins.bins_len = args->nrb * psize * sizeof (bin_t);
    ret.sp_read_ret_t_u.bins.bins_val =
        (char *) xmalloc(args->nrb * psize * sizeof (bin_t));
    if (storage_read
        (st, args->fid, args->tid, args->bid, args->nrb,
         (bin_t *) ret.sp_read_ret_t_u.bins.bins_val) != 0) {
        ret.sp_read_ret_t_u.error = errno;
        goto out;
    }
    ret.status = SP_SUCCESS;

out:
    STOP_PROFILING(read);
    return &ret;
}
Example #4
0
void sp_write_1_svc_nb(void * pt, rozorpc_srv_ctx_t *req_ctx_p) {
    sp_write_arg_t * args = (sp_write_arg_t *) pt;
    static sp_write_ret_t ret;
    storage_t *st = 0;
    // Variable to be used in a later version.
    uint8_t version = 0;
    char *buf_bins;
    
    /*
    ** put  the pointer to the bins (still in received buffer
    */
    int position = storage_get_position_of_first_byte2write_from_write_req();
    buf_bins = (char*)ruc_buf_getPayload(req_ctx_p->recv_buf);
    buf_bins+= position;


    DEBUG_FUNCTION;

    START_PROFILING_IO(write, args->nb_proj * rozofs_get_max_psize(args->layout)
            * sizeof (bin_t));

    ret.status = SP_FAILURE;

    // Get the storage for the couple (cid;sid)
    if ((st = storaged_lookup(args->cid, args->sid)) == 0) {
        ret.sp_write_ret_t_u.error = errno;
        goto out;
    }

    // Write projections
    if (storage_write(st, args->layout, (sid_t *) args->dist_set, args->spare,
            (unsigned char *) args->fid, args->bid, args->nb_proj, version,
            &ret.sp_write_ret_t_u.file_size,
            (bin_t *) buf_bins) <= 0) {
        ret.sp_write_ret_t_u.error = errno;
        goto out;
    }

    ret.status = SP_SUCCESS;
out:
 
    req_ctx_p->xmitBuf  = req_ctx_p->recv_buf;
    req_ctx_p->recv_buf = NULL;
    rozorpc_srv_forward_reply(req_ctx_p,(char*)&ret); 
    /*
    ** release the context
    */
    rozorpc_srv_release_context(req_ctx_p);
    STOP_PROFILING(write);
    return ;
}
Example #5
0
void mp_stat_1_svc_nb(void * pt_req, rozorpc_srv_ctx_t *rozorpc_srv_ctx_p,
        void * pt_resp, uint32_t cnx_id) {

    mp_stat_arg_t * args = (mp_stat_arg_t *) pt_req;
    mp_stat_ret_t * ret = (mp_stat_ret_t *) pt_resp;
    storage_t     * st = 0;
    uint64_t        ssize;
    uint64_t        sfree;
    int             device;
    storage_share_t *share;
    
    DEBUG_FUNCTION;

    START_PROFILING(stat);

    ret->status = MP_FAILURE;

    if ((st = storaged_lookup(args->cid, args->sid)) == 0) {
        ret->mp_stat_ret_t_u.error = errno;
        goto out;
    }

    sfree = 0;
    ssize = 0;

    /*
    ** Resolve the share memory address
    */
    share = storage_get_share(st);    
    if (share == NULL) {
      ret->mp_stat_ret_t_u.error = ENOENT;
      goto out;
    }    
    

    for (device=0; device < st->device_number; device++) {
      sfree += share->dev[device].free;
      ssize += share->dev[device].size;
    }  
    
    ret->mp_stat_ret_t_u.sstat.size = ssize;
    ret->mp_stat_ret_t_u.sstat.free = sfree;

    ret->status = MP_SUCCESS;

out:
    STOP_PROFILING(stat);
}
Example #6
0
sp_status_ret_t *sp_truncate_1_svc(sp_truncate_arg_t * args,
                                   struct svc_req * req) {
    static sp_status_ret_t ret;
    storage_t *st = 0;
    DEBUG_FUNCTION;

    ret.status = SP_FAILURE;
    if ((st = storaged_lookup(args->sid)) == 0) {
        ret.sp_status_ret_t_u.error = errno;
        goto out;
    }
    if (storage_truncate(st, args->fid, args->tid, args->bid) != 0) {
        ret.sp_status_ret_t_u.error = errno;
        goto out;
    }
    ret.status = SP_SUCCESS;
out:
    return &ret;
}
Example #7
0
void sp_truncate_1_svc_nb(void * pt, rozorpc_srv_ctx_t *req_ctx_p) {
    sp_truncate_arg_t * args = (sp_truncate_arg_t *) pt;
    static sp_status_ret_t ret;
    storage_t *st = 0;
    // Variable to be used in a later version.
    uint8_t version = 0;
    
    DEBUG_FUNCTION;
    
    START_PROFILING(truncate);
    
    ret.status = SP_FAILURE;

    // Get the storage for the couple (cid;sid)
    if ((st = storaged_lookup(args->cid, args->sid)) == 0) {
        ret.sp_status_ret_t_u.error = errno;
        goto out;
    }

    // Truncate bins file
    if (storage_truncate(st, args->layout, (sid_t *) args->dist_set,
            args->spare, (unsigned char *) args->fid, args->proj_id,
            args->bid,version,args->last_seg,args->last_timestamp,
	    args->bins.bins_len, args->bins.bins_val) != 0) {
        ret.sp_status_ret_t_u.error = errno;
        goto out;
    }
    ret.status = SP_SUCCESS;
out:
 
    req_ctx_p->xmitBuf  = req_ctx_p->recv_buf;
    req_ctx_p->recv_buf = NULL;
    rozorpc_srv_forward_reply(req_ctx_p,(char*)&ret); 
    /*
    ** release the context
    */
    rozorpc_srv_release_context(req_ctx_p);
    
    STOP_PROFILING(truncate);
    return ;
}
Example #8
0
mp_list_bins_files_ret_t *mp_list_bins_files_1_svc(
        mp_list_bins_files_arg_t * args,
        struct svc_req * req) {

    static mp_list_bins_files_ret_t ret;
    storage_t *st = 0;

    DEBUG_FUNCTION;

    xdr_free((xdrproc_t) xdr_mp_list_bins_files_ret_t, (char *) &ret);

    if ((st = storaged_lookup(args->cid, args->sid)) == 0) {
        ret.mp_list_bins_files_ret_t_u.error = errno;
        goto out;
    }

    if (storage_list_bins_files_to_rebuild(st, args->rebuild_sid,
            &args->layout,
            (sid_t *) & args->dist_set,
            &args->spare,
            &args->cookie,
            (bins_file_rebuild_t **)
            & ret.mp_list_bins_files_ret_t_u.reply.children,
            (uint8_t *) & ret.mp_list_bins_files_ret_t_u.reply.eof) != 0) {
        goto error;
    }

    ret.mp_list_bins_files_ret_t_u.reply.cookie = args->cookie;
    memcpy(&ret.mp_list_bins_files_ret_t_u.reply.dist_set, &args->dist_set,
            sizeof (sid_t) * ROZOFS_SAFE_MAX);
    ret.mp_list_bins_files_ret_t_u.reply.layout = args->layout;
    ret.mp_list_bins_files_ret_t_u.reply.spare = args->spare;

    ret.status = MP_SUCCESS;
    goto out;
error:
    ret.status = MP_FAILURE;
    ret.mp_list_bins_files_ret_t_u.error = errno;
out:
    return &ret;
}
Example #9
0
mp_stat_ret_t *mp_stat_1_svc(mp_stat_arg_t * args, struct svc_req * req) {
    static mp_stat_ret_t ret;
    storage_t *st = 0;
    sstat_t sstat;
    DEBUG_FUNCTION;

    START_PROFILING(stat);

    ret.status = MP_FAILURE;
    if ((st = storaged_lookup(args->cid, args->sid)) == 0) {
        ret.mp_stat_ret_t_u.error = errno;
        goto out;
    }
    if (storage_stat(st, &sstat) != 0) {
        ret.mp_stat_ret_t_u.error = errno;
        goto out;
    }
    ret.mp_stat_ret_t_u.sstat.size = sstat.size;
    ret.mp_stat_ret_t_u.sstat.free = sstat.free;
    ret.status = MP_SUCCESS;
out:
    STOP_PROFILING(stat);
    return &ret;
}
Example #10
0
mp_status_ret_t *mp_remove_1_svc(mp_remove_arg_t * args, struct svc_req * req) {
    static mp_status_ret_t ret;
    storage_t *st = 0;
    DEBUG_FUNCTION;

    START_PROFILING(remove);

    ret.status = MP_FAILURE;

    if ((st = storaged_lookup(args->cid, args->sid)) == 0) {
        ret.mp_status_ret_t_u.error = errno;
        goto out;
    }
    if (storage_rm_file(st, args->layout, (sid_t *) args->dist_set,
            (unsigned char *) args->fid) != 0) {
        ret.mp_status_ret_t_u.error = errno;
        goto out;
    }

    ret.status = MP_SUCCESS;
out:
    STOP_PROFILING(remove);
    return &ret;
}
Example #11
0
sp_status_ret_t *sp_write_1_svc(sp_write_arg_t * args, struct svc_req * req) {
    static sp_status_ret_t ret;
    storage_t *st = 0;
    DEBUG_FUNCTION;

    START_PROFILING_IO(write,
            args->nrb * rozofs_psizes[args->tid] * sizeof (bin_t));

    ret.status = SP_FAILURE;
    if ((st = storaged_lookup(args->sid)) == 0) {
        ret.sp_status_ret_t_u.error = errno;
        goto out;
    }
    if (storage_write
        (st, args->fid, args->tid, args->bid, args->nrb, args->bins.bins_len,
         (bin_t *) args->bins.bins_val) != 0) {
        ret.sp_status_ret_t_u.error = errno;
        goto out;
    }
    ret.status = SP_SUCCESS;
out:
    STOP_PROFILING(write);
    return &ret;
}
Example #12
0
static int load_storages_conf(struct config_t *config) {

    int status = -1;
    int i = 0;
    struct config_setting_t *settings = NULL;

    if (!(settings = config_lookup(config, "storages"))) {
        errno = ENOKEY;
        fprintf(stderr, "can't locate the storages settings in conf file\n");
        fatal("can't locate the storages settings in conf file");
        goto out;
    }

    storaged_storages =
            xmalloc(config_setting_length(settings) * sizeof (storage_t));

    for (i = 0; i < config_setting_length(settings); i++) {
        struct config_setting_t *ms = NULL;
        long int sid;
        const char *root;

        if (!(ms = config_setting_get_elem(settings, i))) {
            errno = EIO; //XXX
            fprintf(stderr, "cant't fetche storage at index %d\n", i);
            severe("cant't fetche storage at index %d", i);
            goto out;
        }

        if (config_setting_lookup_int(ms, "sid", &sid) == CONFIG_FALSE) {
            errno = ENOKEY;
            fprintf(stderr, "cant't look up sid for storage (idx=%d)\n", i);
            fatal("cant't look up sid for storage (idx=%d)", i);
            goto out;
        }

        if (storaged_lookup(sid) != NULL) {
            fprintf(stderr,
                    "cant't add storage with sid %ld: already exists\n", sid);
            info("cant't add storage with sid %ld: already exists", sid);
            goto out;
        }

        if (config_setting_lookup_string(ms, "root", &root) == CONFIG_FALSE) {
            errno = ENOKEY;
            fprintf(stderr, "cant't look up root path for storage (idx=%d)\n",
                    i);
            severe("cant't look up root path for storage (idx=%d)", i);
            goto out;
        }

        if (storage_initialize(storaged_storages + i, (uint16_t) sid, root) !=
                0) {
            fprintf(stderr,
                    "can't initialize storage (sid:%ld) with path %s: %s\n",
                    sid, root, strerror(errno));
            severe("can't initialize storage (sid:%ld) with path %s: %s", sid,
                    root, strerror(errno));
            goto out;
        }

        storaged_nrstorages++;
    }
    status = 0;
out:
    return status;
}
Example #13
0
void sp_read_1_svc_nb(void * pt, rozorpc_srv_ctx_t *req_ctx_p) {
    sp_read_arg_t * args = (sp_read_arg_t *) pt;
    static sp_read_ret_t ret;
    storage_t *st = 0;

    START_PROFILING_IO(read, args->nb_proj * rozofs_get_max_psize(args->layout)
            * sizeof (bin_t));
            
    ret.status = SP_FAILURE;            
    /*
    ** allocate a buffer for the response
    */
    req_ctx_p->xmitBuf = ruc_buf_getBuffer(storage_xmit_buffer_pool_p);
    if (req_ctx_p->xmitBuf == NULL)
    {
      severe("Out of memory STORAGE_NORTH_LARGE_POOL");
      ret.sp_read_ret_t_u.error = ENOMEM;
      req_ctx_p->xmitBuf  = req_ctx_p->recv_buf;
      req_ctx_p->recv_buf = NULL;
      goto error;         
    }


    // Get the storage for the couple (cid;sid)
    if ((st = storaged_lookup(args->cid, args->sid)) == 0) {
        ret.sp_read_ret_t_u.error = errno;
        goto error;
    }

    /*
    ** set the pointer to the bins
    */
    int position = storage_get_position_of_first_byte2write_from_read_req();
    uint8_t *pbuf = (uint8_t*)ruc_buf_getPayload(req_ctx_p->xmitBuf);     
    /*
    ** clear the length of the bins and set the pointer where data must be returned
    */  
    ret.sp_read_ret_t_u.rsp.bins.bins_val =(char *)(pbuf+position);  ;
    ret.sp_read_ret_t_u.rsp.bins.bins_len = 0;
#if 0 // for future usage with distributed cache 
    /*
    ** clear the optimization array
    */
    ret.sp_read_ret_t_u.rsp.optim.optim_val = (char*)sp_optim;
    ret.sp_read_ret_t_u.rsp.optim.optim_len = 0;
#endif    
    // Read projections
    if (storage_read(st, args->layout, (sid_t *) args->dist_set, args->spare,
            (unsigned char *) args->fid, args->bid, args->nb_proj,
            (bin_t *) ret.sp_read_ret_t_u.rsp.bins.bins_val,
            (size_t *) & ret.sp_read_ret_t_u.rsp.bins.bins_len,
            &ret.sp_read_ret_t_u.rsp.file_size) != 0) {
        ret.sp_read_ret_t_u.error = errno;
        goto error;
    }

    ret.status = SP_SUCCESS;
    storaged_srv_forward_read_success(req_ctx_p,&ret);
    /*
    ** check the case of the readahead
    */
    storage_check_readahead();
    goto out;
    
error:
    rozorpc_srv_forward_reply(req_ctx_p,(char*)&ret); 
    /*
    ** release the context
    */
out:
    rozorpc_srv_release_context(req_ctx_p);
    STOP_PROFILING(read);
    return ;
}