int main(int argc, char **argv) { int i; PINT_Request *r1; PINT_Request *r2; PINT_Request_state *rs1; PINT_Request_state *rs2; PINT_request_file_data rf1; PINT_Request_result seg1; /* PVFS_Process_request arguments */ int retval; int32_t blksz[] = {4}; PVFS_size disps[] = {32}; /* set up file type request */ PVFS_Request_hindexed(1, blksz, disps, PVFS_INT, &r1); rs1 = PINT_new_request_state(r1); /* set up memory request */ PVFS_Request_contiguous(96, PVFS_BYTE, &r2); rs2 = PINT_new_request_state(r2); /* set up file data for request */ PINT_dist_initialize(NULL); rf1.server_nr = 0; rf1.server_ct = 4; rf1.fsize = 6000; rf1.dist = PINT_dist_create("simple_stripe"); rf1.extend_flag = 0; PINT_dist_lookup(rf1.dist); /* set up result struct */ seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t)); seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t)); seg1.bytemax = BYTEMAX; seg1.segmax = SEGMAX; seg1.bytes = 0; seg1.segs = 0; /* skip into the file datatype */ /*PINT_REQUEST_STATE_SET_TARGET(rs1, 500);*/ PINT_REQUEST_STATE_SET_FINAL(rs1,96); /* Turn on debugging */ // gossip_enable_stderr(); // gossip_set_debug_mask(1,GOSSIP_REQUEST_DEBUG); /* skipping logical bytes */ // PINT_REQUEST_STATE_SET_TARGET(rs1,(3 * 1024) + 512); // PINT_REQUEST_STATE_SET_FINAL(rs1,(6 * 1024) + 512); printf("\n************************************\n"); printf("One request in CLIENT mode server 0 of 4\n"); printf("Simple stripe, default stripe size (64K)\n"); printf("Offset 0, file size 6000, no extend flag\n"); printf("MemReq size 96 coniguous\n"); printf("\n************************************\n"); PINT_REQUEST_STATE_RESET(rs1); PINT_REQUEST_STATE_RESET(rs2); do { int r = 0; seg1.bytes = 0; seg1.segs = 0; /* process request */ retval = PINT_process_request(rs1, rs2, &rf1, &seg1, PINT_CLIENT); if(retval >= 0) { printf("results of PINT_process_request():\n"); printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes)); for(i=0; i<seg1.segs; i++, r++) { printf(" segment %d: offset: %d size: %d\n", i, (int)seg1.offset_array[i], (int)seg1.size_array[i]); } } } while(!PINT_REQUEST_DONE(rs1) && retval >= 0); if(retval < 0) { fprintf(stderr, "Error: PINT_process_request() failure.\n"); return(-1); } if(PINT_REQUEST_DONE(rs1)) { printf("**** request done.\n"); } printf("\n************************************\n"); printf("One request in SERVER mode server 0 of 4\n"); printf("Simple stripe, default stripe size (64K)\n"); printf("Offset 32, file size 6000, no extend flag\n"); printf("MemReq size 96 coniguous\n"); printf("\n************************************\n"); PINT_REQUEST_STATE_RESET(rs1); do { int r = 0; seg1.bytes = 0; seg1.segs = 0; /* process request */ retval = PINT_process_request(rs1, NULL, &rf1, &seg1, PINT_SERVER); if(retval >= 0) { printf("results of PINT_process_request():\n"); printf("%d segments with %lld bytes\n", seg1.segs, lld(seg1.bytes)); for(i=0; i<seg1.segs; i++, r++) { printf(" segment %d: offset: %d size: %d\n", i, (int)seg1.offset_array[i], (int)seg1.size_array[i]); } } } while(!PINT_REQUEST_DONE(rs1) && retval >= 0); if(retval < 0) { fprintf(stderr, "Error: PINT_process_request() failure.\n"); return(-1); } if(PINT_REQUEST_DONE(rs1)) { printf("**** request done.\n"); } return 0; }
int main(int argc, char **argv) { PINT_dist *d; int ret = -1; PVFS_offset tmp_off = 0; PINT_request_file_data file_data; /* grab a distribution */ PINT_dist_initialize(NULL); d = PINT_dist_create("simple_stripe"); assert(d); ret = PINT_dist_lookup(d); assert(ret == 0); PINT_dist_dump(d); /* Initialize the file data */ memset(&file_data, 0, sizeof(file_data)); file_data.server_ct = 4; file_data.server_nr = 0; /* easy case */ tmp_off = d->methods->logical_to_physical_offset(d->params,&file_data,100); printf("offset: %lld\n", (long long)tmp_off); /* just before strip */ tmp_off = d->methods->logical_to_physical_offset(d->params, &file_data, (64*1024-1)); printf("offset: %lld\n", (long long)tmp_off); /* at strip */ tmp_off = d->methods->logical_to_physical_offset(d->params, &file_data, (64*1024)); printf("offset: %lld\n", (long long)tmp_off); /* just after strip */ tmp_off = d->methods->logical_to_physical_offset(d->params, &file_data, (64*1024+1)); printf("offset: %lld\n", (long long)tmp_off); /* wrap around tests */ tmp_off = d->methods->logical_to_physical_offset(d->params, &file_data, (64*1024*4+1)); printf("offset: %lld\n", (long long)tmp_off); /* try a different io server */ file_data.server_nr = 3; tmp_off = d->methods->logical_to_physical_offset(d->params, &file_data, (64*1024-1)); printf("offset: %lld\n", (long long)tmp_off); /* same as above, but in his region w/ wrap around */ tmp_off = d->methods->logical_to_physical_offset(d->params, &file_data, (64*1024*7+15)); printf("offset: %lld\n", (long long)tmp_off); /* free dist */ PINT_dist_free(d); return (0); }
int main( int argc, char **argv) { int ret = -1; int outcount = 0, count; struct BMI_unexpected_info request_info; flow_descriptor *flow_d = NULL; double time1, time2; int i; PINT_Request *req; char path_name[PATH_SIZE]; TROVE_op_id op_id; TROVE_coll_id coll_id; TROVE_handle file_handle, parent_handle; TROVE_ds_state state; char *file_name; TROVE_keyval_s key, val; bmi_context_id context; TROVE_context_id trove_context; PVFS_handle_extent cur_extent; PVFS_handle_extent_array extent_array; /*************************************************************/ /* initialization stuff */ /* set debugging level */ gossip_enable_stderr(); gossip_set_debug_mask( 0, (GOSSIP_FLOW_PROTO_DEBUG | GOSSIP_BMI_DEBUG_TCP)); /* Init dists */ PINT_dist_initialize(NULL); /* start up BMI */ ret = BMI_initialize("bmi_tcp", "tcp://NULL:3335", BMI_INIT_SERVER); if (ret < 0) { fprintf(stderr, "BMI init failure.\n"); return (-1); } ret = BMI_open_context(&context); if (ret < 0) { fprintf(stderr, "BMI_open_context() failure.\n"); return (-1); } ret = trove_initialize( TROVE_METHOD_DBPF, NULL, storage_space, storage_space, 0); if (ret < 0) { fprintf(stderr, "initialize failed: run trove-mkfs first.\n"); return -1; } /* initialize the flow interface */ ret = PINT_flow_initialize("flowproto_multiqueue", 0); if (ret < 0) { fprintf(stderr, "flow init failure.\n"); return (-1); } /* try to look up collection used to store file system */ ret = trove_collection_lookup( TROVE_METHOD_DBPF, file_system, &coll_id, NULL, &op_id); if (ret < 0) { fprintf(stderr, "collection lookup failed.\n"); return -1; } ret = trove_open_context(coll_id, &trove_context); if (ret < 0) { fprintf(stderr, "TROVE_open_context() failure.\n"); return (-1); } /* find the parent directory name */ strcpy(path_name, path_to_file); for (i = strlen(path_name); i >= 0; i--) { if (path_name[i] != '/') path_name[i] = '\0'; else break; } file_name = path_to_file + strlen(path_name); printf("path is %s\n", path_name); printf("file is %s\n", file_name); /* find the parent directory handle */ ret = path_lookup(coll_id, trove_context, path_name, &parent_handle); if (ret < 0) { return -1; } file_handle = 0; cur_extent.first = cur_extent.last = requested_file_handle; extent_array.extent_count = 1; extent_array.extent_array = &cur_extent; ret = trove_dspace_create(coll_id, &extent_array, &file_handle, TROVE_TEST_FILE, NULL, TROVE_FORCE_REQUESTED_HANDLE, NULL, trove_context, &op_id, NULL); while (ret == 0) ret = trove_dspace_test(coll_id, op_id, trove_context, &count, NULL, NULL, &state, TROVE_DEFAULT_TEST_TIMEOUT); if (ret < 0) { fprintf(stderr, "dspace create failed.\n"); return -1; } /* TODO: set attributes of file? */ /* add new file name/handle pair to parent directory */ key.buffer = file_name; key.buffer_sz = strlen(file_name) + 1; val.buffer = &file_handle; val.buffer_sz = sizeof(file_handle); ret = trove_keyval_write(coll_id, parent_handle, &key, &val, 0, NULL, NULL, trove_context, &op_id, NULL); while (ret == 0) ret = trove_dspace_test(coll_id, op_id, trove_context, &count, NULL, NULL, &state, TROVE_DEFAULT_TEST_TIMEOUT); if (ret < 0) { fprintf(stderr, "keyval write failed.\n"); return -1; } /* wait for an initial communication via BMI */ /* we don't give a crap about that message except that it tells us * where to find the client */ do { ret = BMI_testunexpected(1, &outcount, &request_info, 10); } while (ret == 0 && outcount == 0); if (ret < 0 || request_info.error_code != 0) { fprintf(stderr, "waitunexpected failure.\n"); return (-1); } BMI_unexpected_free(request_info.addr, request_info.buffer); /******************************************************/ /* setup request/dist stuff */ /* request description */ /* just want one contiguous region */ ret = PVFS_Request_contiguous(TEST_SIZE, PVFS_BYTE, &req); if (ret < 0) { fprintf(stderr, "PVFS_Request_contiguous() failure.\n"); return (-1); } /******************************************************/ /* setup communicaton stuff */ /* create a flow descriptor */ flow_d = PINT_flow_alloc(); if (!flow_d) { fprintf(stderr, "flow_alloc failed.\n"); return (-1); } /* file data */ flow_d->file_data.fsize = TEST_SIZE; flow_d->file_data.server_nr = 0; flow_d->file_data.server_ct = 1; flow_d->file_data.extend_flag = 1; flow_d->file_data.dist = PINT_dist_create("basic_dist"); if (!flow_d->file_data.dist) { fprintf(stderr, "Error: failed to create dist.\n"); return (-1); } ret = PINT_dist_lookup(flow_d->file_data.dist); if (ret != 0) { fprintf(stderr, "Error: failed to lookup dist.\n"); return (-1); } flow_d->file_req = req; flow_d->tag = 0; flow_d->user_ptr = NULL; flow_d->aggregate_size = TEST_SIZE; /* fill in flow details */ flow_d->src.endpoint_id = BMI_ENDPOINT; flow_d->src.u.bmi.address = request_info.addr; flow_d->dest.endpoint_id = TROVE_ENDPOINT; flow_d->dest.u.trove.handle = file_handle; flow_d->dest.u.trove.coll_id = coll_id; /*************************************************** * test bmi to file (analogous to a client side write) */ time1 = Wtime(); ret = block_on_flow(flow_d); if (ret < 0) { return (-1); } time2 = Wtime(); #if 0 printf("Server bw (recv): %f MB/sec\n", ((TEST_SIZE) / ((time2 - time1) * 1000000.0))); #endif /*******************************************************/ /* final cleanup and output */ PINT_flow_free(flow_d); /* shut down flow interface */ ret = PINT_flow_finalize(); if (ret < 0) { fprintf(stderr, "flow finalize failure.\n"); return (-1); } /* shut down BMI */ BMI_close_context(context); BMI_finalize(); trove_close_context(coll_id, trove_context); trove_finalize(TROVE_METHOD_DBPF); gossip_disable(); return (0); }
/** * Migrates an entire 0.0.1 DBPF collection * \return 0 on succes, -1 on failure */ static int translate_0_0_1( char* storage_space, /**< path to storage space */ char* old_coll_path, /**< path to old collection */ char* coll_name, /**< collection name */ TROVE_coll_id coll_id) /**< collection id in string format */ { int ret = -1; /* choose a handle range big enough to encompass anything pvfs2-genconfig * will create */ char handle_range[] = "4-64000000000"; TROVE_op_id op_id; TROVE_context_id trove_context = -1; char current_path[PATH_MAX]; /* rename old collection */ snprintf(current_path, PATH_MAX, "%s/%08x", storage_space, coll_id); if(access(current_path, F_OK) != 0) { fprintf(stderr, "Error: could not find old collection: %s\n" " fs: %s (%08x)\n", old_coll_path, coll_name, coll_id); return -1; } if(verbose) printf("VERBOSE Renaming old collection.\n"); ret = rename(current_path, old_coll_path); if(ret < 0) { perror("rename"); return(-1); } ret = remove_collection_entry(storage_space, coll_name); if(ret < 0) { fprintf(stderr, "Error: failed to remove collection entry: %s\n", coll_name); return(-1); } /* create new collection */ /* NOTE: deliberately not specifying root handle; it will get translated * later as a normal directory if applicable */ if(verbose) printf("VERBOSE Creating temporary collection to migrate to.\n"); ret = pvfs2_mkspace( storage_space, coll_name, coll_id, TROVE_HANDLE_NULL, handle_range, NULL, 1, 0); if(ret != 0) { fprintf(stderr, "Error: failed to create new collection.\n"); return(-1); } /* initialize distribution infrastructure */ /* NOTE: server config argument is not required here */ ret = PINT_dist_initialize(NULL); if (ret < 0) { PVFS_perror("PINT_dist_initialize", ret); if(verbose) printf("VERBOSE Destroying temporary collection.\n"); pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0); return(-1); } /* initialize trove and lookup collection */ ret = trove_initialize( TROVE_METHOD_DBPF, NULL, storage_space, 0); if (ret < 0) { PVFS_perror("trove_initialize", ret); if(verbose) printf("VERBOSE Destroying temporary collection.\n"); pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0); return(-1); } ret = trove_collection_lookup( TROVE_METHOD_DBPF, coll_name, &coll_id, NULL, &op_id); if (ret != 1) { fprintf(stderr, "Error: failed to lookup new collection.\n"); if(verbose) printf("VERBOSE Destroying temporary collection.\n"); pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0); return -1; } ret = trove_open_context(coll_id, &trove_context); if (ret < 0) { PVFS_perror("trove_open_context", ret); return(-1); } /* convert collection xattrs */ ret = translate_coll_eattr_0_0_1( old_coll_path, coll_id, coll_name, trove_context); if(ret < 0) { fprintf(stderr, "Error: failed to migrate collection extended attributes.\n"); if(verbose) printf("VERBOSE Destroying temporary collection.\n"); pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0); return(-1); } /* convert dspace attrs */ ret = translate_dspace_attr_0_0_1( old_coll_path, coll_id, coll_name, trove_context); if(ret < 0) { fprintf(stderr, "Error: failed to migrate dspace attributes.\n"); if(verbose) printf("VERBOSE Destroying temporary collection.\n"); pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0); return(-1); } /* convert dspace keyvals */ ret = translate_keyvals_0_0_1( old_coll_path, coll_id, coll_name, trove_context); if(ret < 0) { fprintf(stderr, "Error: failed to migrate keyvals.\n"); if(verbose) printf("VERBOSE Destroying temporary collection.\n"); pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0); return(-1); } /* at this point, we are done with the Trove API */ trove_close_context(coll_id, trove_context); trove_finalize(TROVE_METHOD_DBPF); PINT_dist_finalize(); /* convert bstreams */ ret = translate_bstreams_0_0_1( storage_space, old_coll_path, coll_id, coll_name, trove_context); if(ret < 0) { fprintf(stderr, "Error: failed to migrate bstreams.\n"); if(verbose) printf("VERBOSE Destroying temporary collection.\n"); pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0); return(-1); } printf("Migration successful.\n"); if(!opts.cleanup_set) { printf("===================================================================\n"); printf("IMPORTANT!!! IMPORTANT!!! IMPORTANT!!! IMPORTANT!!!\n"); printf("Please delete the old collection once you have tested and confirmed\n"); printf("the results of the migration.\n"); printf("Command: \"pvfs2-migrate-collection -cleanup <fs config> <server config>\"\n"); printf("===================================================================\n"); } return(0); }
int main( int argc, char **argv) { int ret = -1; int outcount = 0; void *mybuffer; PVFS_BMI_addr_t server_addr; bmi_op_id_t op; bmi_error_code_t error_code; flow_descriptor *flow_d = NULL; int i = 0; bmi_size_t actual_size; double time1, time2; PINT_Request *req; bmi_context_id context; /*************************************************************/ /* initialization stuff */ /* set debugging level */ gossip_enable_stderr(); gossip_set_debug_mask( 0, (GOSSIP_FLOW_PROTO_DEBUG | GOSSIP_BMI_DEBUG_TCP)); /* Dist init */ PINT_dist_initialize(NULL); /* start up BMI */ ret = BMI_initialize("bmi_tcp", NULL, 0); if (ret < 0) { fprintf(stderr, "BMI init failure.\n"); return (-1); } ret = BMI_open_context(&context); if (ret < 0) { fprintf(stderr, "BMI_open_context() failure.\n"); return (-1); } /* initialize the flow interface */ ret = PINT_flow_initialize("flowproto_multiqueue", 0); if (ret < 0) { fprintf(stderr, "flow init failure.\n"); return (-1); } /* send some random crap to the other side to start up communication */ ret = BMI_addr_lookup(&server_addr, "tcp://localhost:3335"); if (ret < 0) { fprintf(stderr, "BMI lookup failure.\n"); return (-1); } ret = BMI_post_sendunexpected(&op, server_addr, &mybuffer, 1, BMI_EXT_ALLOC, 0, NULL, context, NULL); if (ret < 0) { fprintf(stderr, "BMI_post_sendunexpected failure.\n"); return (-1); } if (ret == 0) { /* turning this into a blocking call for testing :) */ /* check for completion of request */ do { ret = BMI_test(op, &outcount, &error_code, &actual_size, NULL, 10, context); } while (ret == 0 && outcount == 0); if (ret < 0 || error_code != 0) { fprintf(stderr, "Request send failed.\n"); if (ret < 0) { errno = -ret; perror("BMI_test"); } return (-1); } } /******************************************************/ /* setup request/dist stuff */ /* request description */ /* just want one contiguous region */ ret = PVFS_Request_contiguous(TEST_SIZE, PVFS_BYTE, &req); if (ret < 0) { fprintf(stderr, "PVFS_Request_contiguous() failure.\n"); return (-1); } /******************************************************/ /* setup communicaton stuff */ /* memory buffer to xfer */ mybuffer = (void *) malloc(TEST_SIZE); if (!mybuffer) { fprintf(stderr, "mem.\n"); return (-1); } /* mark it so that we can check correctness */ for (i = 0; i < (TEST_SIZE / (sizeof(int))); i++) { ((int *) mybuffer)[i] = i; } /* create a flow descriptor */ flow_d = PINT_flow_alloc(); if (!flow_d) { fprintf(stderr, "mem.\n"); return (-1); } /* file data */ flow_d->file_data.fsize = TEST_SIZE; flow_d->file_data.server_nr = 0; flow_d->file_data.server_ct = 1; flow_d->file_data.extend_flag = 0; flow_d->file_data.dist = PINT_dist_create("basic_dist"); if (!flow_d->file_data.dist) { fprintf(stderr, "Error: failed to create dist.\n"); return (-1); } ret = PINT_dist_lookup(flow_d->file_data.dist); if (ret != 0) { fprintf(stderr, "Error: failed to lookup dist.\n"); return (-1); } flow_d->file_req = req; flow_d->tag = 0; flow_d->user_ptr = NULL; flow_d->aggregate_size = TEST_SIZE; /* fill in flow details */ flow_d->src.endpoint_id = MEM_ENDPOINT; flow_d->src.u.mem.buffer = mybuffer; flow_d->dest.endpoint_id = BMI_ENDPOINT; flow_d->dest.u.bmi.address = server_addr; /*************************************************** * test memory to bmi (analogous to client side write) */ time1 = Wtime(); ret = block_on_flow(flow_d); if (ret < 0) { return (-1); } time2 = Wtime(); /*******************************************************/ /* final cleanup and output */ #if 0 printf("Client bw (send): %f MB/sec\n", ((TEST_SIZE) / ((time2 - time1) * 1000000.0))); #endif PINT_flow_free(flow_d); /* shut down flow interface */ ret = PINT_flow_finalize(); if (ret < 0) { fprintf(stderr, "flow finalize failure.\n"); return (-1); } /* shut down BMI */ BMI_close_context(context); BMI_finalize(); free(mybuffer); gossip_disable(); return (0); }