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; }
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 ; }
int main(int argc, char **argv) { storage_t st; sid_t sid = 0; sstat_t sst; fid_t fid; //bin_t *bins; rozofs_initialize(LAYOUT_2_3_4); storage_initialize(&st, sid, "/tmp"); if (storage_stat(&st, &sst) != 0) { perror("failed to stat storage"); exit(-1); } printf("size: %" PRIu64 ", free: %" PRIu64 "\n", sst.size, sst.free); uuid_generate(fid); // Write some bins (15 prj) //bins = xmalloc(rozofs_psizes[0] * 15); /* if (storage_write(&st, fid, 0, 10, 15, bins) != 0) { perror("failed to write bins"); exit(-1); } */ if (storage_truncate(&st, fid, 0, 10) != 0) { perror("failed to truncate pfile"); exit(-1); } if (storage_rm_file(&st, fid) != 0) { perror("failed to remove pfile"); exit(-1); } storage_release(&st); exit(0); }