home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / test / io / description / debug22.c < prev    next >
C/C++ Source or Header  |  2005-09-27  |  8KB  |  356 lines

  1. /*
  2.  * (C) 2002 Clemson University.
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */       
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <pvfs2-types.h>
  11. #include <gossip.h>
  12. #include <pvfs2-debug.h>
  13.  
  14. #include <pint-distribution.h>
  15. #include <pint-dist-utils.h>
  16. #include <pvfs2-request.h>
  17. #include <pint-request.h>
  18.  
  19. #include <debug.h>
  20.  
  21. #define SEGMAX 16
  22. #define BYTEMAX (1024*1024)
  23.  
  24. PVFS_offset exp1_offset[] =
  25. {
  26.         0,
  27.         48128,
  28.         97280,
  29.         146432
  30. };
  31. PVFS_offset exp1_size[] =
  32. {
  33.         48128,
  34.         49152
  35. };
  36. PINT_Request_result expected[] =
  37. {{
  38.        offset_array : &exp1_offset[0],
  39.        size_array : &exp1_size[0],
  40.        segmax : SEGMAX,
  41.        segs : 1,
  42.        bytes : 48128
  43. }, {
  44.        offset_array : &exp1_offset[1],
  45.        size_array : &exp1_size[1],
  46.        segmax : SEGMAX,
  47.        segs : 1,
  48.        bytes : 49152
  49. }, {
  50.        offset_array : &exp1_offset[2],
  51.        size_array : &exp1_size[1],
  52.        segmax : SEGMAX,
  53.        segs : 1,
  54.        bytes : 49152
  55. }, {
  56.        offset_array : &exp1_offset[3],
  57.        size_array : &exp1_size[1],
  58.        segmax : SEGMAX,
  59.        segs : 1,
  60.        bytes : 49152
  61. }};
  62.  
  63.  
  64. int request_debug(void)
  65. {
  66.     int i;
  67.     PINT_Request *r;
  68.     PINT_Request *r_enc;
  69.     PINT_Request *r_dec;
  70.     PINT_Request_state *rs1;
  71.     PINT_Request_state *rs2;
  72.     PINT_Request_state *rs3;
  73.     PINT_Request_state *rs4;
  74.     PINT_request_file_data rf1;
  75.     PINT_request_file_data rf2;
  76.     PINT_request_file_data rf3;
  77.     PINT_request_file_data rf4;
  78.     PINT_Request_result seg1;
  79.     int ret = -1;
  80.     int pack_size = 0;
  81.  
  82.     /* PVFS_Process_request arguments */
  83.     int retval;
  84.  
  85.     /* the case that we want to test is a write, with 4 servers holding
  86.      * parts of the file data.  We will setup 4 different request states,
  87.      * one per server.  The request will be large enough that all 4
  88.      * servers will be involved
  89.      */
  90.  
  91.     /* set up one request, we will reuse it for each server scenario */
  92.     /* we want to read 4M of data, resulting from 1M from each server */
  93.     PVFS_Request_vector(64, 3*1024, 4*1024, PVFS_BYTE, &r);
  94.  
  95.     /* allocate a new request and pack the original one into it */
  96.     pack_size = PINT_REQUEST_PACK_SIZE(r);
  97.     r_enc = (PINT_Request*)malloc(pack_size);
  98.     ret = PINT_request_commit(r_enc, r);
  99.     if(ret < 0)
  100.     {
  101.         fprintf(stderr, "PINT_Request_commit() failure.\n");
  102.         return(-1);
  103.     }
  104.     ret = PINT_request_encode(r_enc);
  105.     if(ret < 0)
  106.     {
  107.         fprintf(stderr, "PINT_Request_encode() failure.\n");
  108.         return(-1);
  109.     }
  110.  
  111.  
  112.     /* decode the encoded request (hopefully ending up with something
  113.      * equivalent to the original request)
  114.      */
  115.     r_dec = (PINT_Request*)malloc(pack_size);
  116.     memcpy(r_dec, r_enc, pack_size);
  117.     free(r_enc);
  118.     free(r);
  119.     ret = PINT_request_decode(r_dec);
  120.     if(ret < 0)
  121.     {
  122.         fprintf(stderr, "PINT_request_decode() failure.\n");
  123.         return(-1);
  124.     }
  125.  
  126.     /* set up four request states */
  127.     rs1 = PINT_new_request_state(r_dec);
  128.     rs2 = PINT_new_request_state(r_dec);
  129.     rs3 = PINT_new_request_state(r_dec);
  130.     rs4 = PINT_new_request_state(r_dec);
  131.  
  132.     PINT_REQUEST_STATE_SET_TARGET(rs1, 1024);
  133.     PINT_REQUEST_STATE_SET_TARGET(rs2, 1024);
  134.     PINT_REQUEST_STATE_SET_TARGET(rs3, 1024);
  135.     PINT_REQUEST_STATE_SET_TARGET(rs4, 1024);
  136.  
  137.     /* set up file data for each server */
  138.     PINT_dist_initialize(NULL);
  139.     rf1.server_nr = 0;
  140.     rf1.server_ct = 4;
  141.     rf1.fsize = 0;
  142.     rf1.dist = PINT_dist_create("simple_stripe");
  143.     rf1.extend_flag = 1;
  144.     PINT_dist_lookup(rf1.dist);
  145.  
  146.     rf2.server_nr = 1;
  147.     rf2.server_ct = 4;
  148.     rf2.fsize = 0;
  149.     rf2.dist = PINT_dist_create("simple_stripe");
  150.     rf2.extend_flag = 1;
  151.     PINT_dist_lookup(rf2.dist);
  152.  
  153.     rf3.server_nr = 2;
  154.     rf3.server_ct = 4;
  155.     rf3.fsize = 0;
  156.     rf3.dist = PINT_dist_create("simple_stripe");
  157.     rf3.extend_flag = 1;
  158.     PINT_dist_lookup(rf3.dist);
  159.  
  160.     rf4.server_nr = 3;
  161.     rf4.server_ct = 4;
  162.     rf4.fsize = 0;
  163.     rf4.dist = PINT_dist_create("simple_stripe");
  164.     rf4.extend_flag = 1;
  165.     PINT_dist_lookup(rf4.dist);
  166.  
  167.     /* set up response for each server */
  168.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  169.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  170.     seg1.segmax = SEGMAX;
  171.     seg1.bytemax = BYTEMAX;
  172.     seg1.segs = 0;
  173.     seg1.bytes = 0;
  174.  
  175.    /* Turn on debugging */
  176.     if (gossipflag)
  177.     {
  178.         gossip_enable_stderr();
  179.         gossip_set_debug_mask(1,GOSSIP_REQUEST_DEBUG);
  180.     }
  181.  
  182.     i = 0;
  183.  
  184.     printf("\n************************************\n");
  185.     printf("Four requests in CLIENT mode 4 each contiguous servers 0-3 of 4\n");
  186.     printf("Simple stripe, default stripe size (64K)\n");
  187.     printf("Vector request, 3K block 4K stride, 64 blocks\n");
  188.     printf("Each from offset 0, file size 0, extend flag\n");
  189.     printf("Server 0\n");
  190.     printf("\n************************************\n");
  191.     do
  192.     {
  193.         seg1.bytes = 0;
  194.         seg1.segs = 0;
  195.  
  196.         /* process request */
  197.         /* note that bytemax is exactly large enough to hold all of the
  198.          * data that I should find here
  199.          */
  200.         retval = PINT_process_request(rs1, NULL, &rf1, &seg1, PINT_CLIENT);
  201.  
  202.         if(!PINT_REQUEST_DONE(rs1))
  203.         {
  204.             fprintf(stderr, "IEEE! reporting more work to do when I should really be done...\n");
  205.         }
  206.  
  207.         if(retval >= 0)
  208.         {
  209.             prtseg(&seg1,"Results obtained");
  210.             prtseg(&expected[i],"Results expected");
  211.             cmpseg(&seg1,&expected[i]);
  212.         }
  213.  
  214.         i++;
  215.  
  216.     } while(0); 
  217.     //} while(!PINT_REQUEST_DONE(rs1) && retval >= 0); 
  218.     
  219.     if(retval < 0)
  220.     {
  221.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  222.         return(-1);
  223.     }
  224.     if(PINT_REQUEST_DONE(rs1))
  225.     {
  226.         printf("**** first request done.\n");
  227.     }
  228.  
  229.     printf("\n************************************\n");
  230.     printf("Server 1\n");
  231.     printf("\n************************************\n");
  232.     do
  233.     {
  234.         seg1.bytes = 0;
  235.         seg1.segs = 0;
  236.  
  237.         /* process request */
  238.         /* note that bytemax is exactly large enough to hold all of the
  239.          * data that I should find here
  240.          */
  241.         retval = PINT_process_request(rs2, NULL, &rf2, &seg1, PINT_CLIENT);
  242.  
  243.         if(!PINT_REQUEST_DONE(rs2))
  244.         {
  245.             fprintf(stderr, "IEEE! reporting more work to do when I should really be done...\n");
  246.         }
  247.  
  248.         if(retval >= 0)
  249.         {
  250.             prtseg(&seg1,"Results obtained");
  251.             prtseg(&expected[i],"Results expected");
  252.             cmpseg(&seg1,&expected[i]);
  253.         }
  254.  
  255.         i++;
  256.  
  257.     } while(0);
  258.     //} while(!PINT_REQUEST_DONE(rs2) && retval >= 0);
  259.     
  260.     if(retval < 0)
  261.     {
  262.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  263.         return(-1);
  264.     }
  265.     if(PINT_REQUEST_DONE(rs2))
  266.     {
  267.         printf("**** second request done.\n");
  268.     }
  269.  
  270.     printf("\n************************************\n");
  271.     printf("Server 2\n");
  272.     printf("\n************************************\n");
  273.     do
  274.     {
  275.         seg1.bytes = 0;
  276.         seg1.segs = 0;
  277.  
  278.         /* process request */
  279.         /* note that bytemax is exactly large enough to hold all of the
  280.          * data that I should find here
  281.          */
  282.         retval = PINT_process_request(rs3, NULL, &rf3, &seg1, PINT_CLIENT);
  283.  
  284.         if(!PINT_REQUEST_DONE(rs3))
  285.         {
  286.             fprintf(stderr, "IEEE! reporting more work to do when I should really be done...\n");
  287.         }
  288.  
  289.         if(retval >= 0)
  290.         {
  291.             prtseg(&seg1,"Results obtained");
  292.             prtseg(&expected[i],"Results expected");
  293.             cmpseg(&seg1,&expected[i]);
  294.         }
  295.  
  296.         i++;
  297.  
  298.     } while(0);
  299.     //} while(!PINT_REQUEST_DONE(rs3) && retval >= 0);
  300.     
  301.     if(retval < 0)
  302.     {
  303.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  304.         return(-1);
  305.     }
  306.     if(PINT_REQUEST_DONE(rs3))
  307.     {
  308.         printf("**** third request done.\n");
  309.     }
  310.  
  311.  
  312.     printf("\n************************************\n");
  313.     printf("Server 3\n");
  314.     printf("\n************************************\n");
  315.     do
  316.     {
  317.         seg1.bytes = 0;
  318.         seg1.segs = 0;
  319.  
  320.         /* process request */
  321.         /* note that bytemax is exactly large enough to hold all of the
  322.          * data that I should find here
  323.          */
  324.         retval = PINT_process_request(rs4, NULL, &rf4, &seg1, PINT_CLIENT);
  325.  
  326.         if(!PINT_REQUEST_DONE(rs4))
  327.         {
  328.             fprintf(stderr, "IEEE! reporting more work to do when I should really be done...\n");
  329.         }
  330.  
  331.         if(retval >= 0)
  332.         {
  333.             prtseg(&seg1,"Results obtained");
  334.             prtseg(&expected[i],"Results expected");
  335.             cmpseg(&seg1,&expected[i]);
  336.         }
  337.  
  338.         i++;
  339.  
  340.     } while(0);
  341.     //} while(!PINT_REQUEST_DONE(rs4) && retval >= 0);
  342.     
  343.     if(retval < 0)
  344.     {
  345.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  346.         return(-1);
  347.     }
  348.     if(PINT_REQUEST_DONE(rs4))
  349.     {
  350.         printf("**** fourth request done.\n");
  351.     }
  352.  
  353.  
  354.     return 0;
  355. }
  356.