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