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 / debug3.c < prev    next >
C/C++ Source or Header  |  2005-07-07  |  4KB  |  244 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 (4*1024*1024)
  23.  
  24. PVFS_offset exp1_offset [] = {
  25.     65536,
  26.     196608,
  27.     327680,
  28.     458752,
  29.     589824,
  30.     720896,
  31.     851968,
  32.     983040,
  33.     1114112,
  34.     1245184,
  35.     1376256,
  36.     1507328,
  37.     1638400,
  38.     1769472,
  39.     1900544,
  40.     2031616,
  41.     2162688,
  42.     2293760,
  43.     2424832,
  44.     2555904,
  45.     2686976,
  46.     2818048,
  47.     2949120,
  48.     3080192,
  49.     3211264,
  50.     3342336,
  51.     3473408,
  52.     3604480,
  53.     3735552,
  54.     3866624,
  55.     3997696,
  56.     4128768,
  57.     4259840
  58. };
  59.  
  60. PVFS_size exp1_size [] = {
  61.     65536,
  62.     65536,
  63.     65536,
  64.     65536,
  65.     65536,
  66.     65536,
  67.     65536,
  68.     65536,
  69.     65536,
  70.     65536,
  71.     65536,
  72.     65536,
  73.     65536,
  74.     65536,
  75.     65536,
  76.     65536,
  77.     65536,
  78.     65536,
  79.     65536,
  80.     65536,
  81.     65536,
  82.     65536,
  83.     65536,
  84.     65536,
  85.     65536,
  86.     65536,
  87.     65536,
  88.     65536,
  89.     65536,
  90.     65536,
  91.     65536,
  92.     65536,
  93.     65536
  94. };
  95.  
  96. PINT_Request_result expected[] =
  97. {{
  98.       offset_array : &exp1_offset[0],
  99.       size_array : &exp1_size[0],
  100.       segmax : SEGMAX,
  101.       segs : 16,
  102.       bytes : 16*65536
  103. }, {
  104.       offset_array : &exp1_offset[16],
  105.       size_array : &exp1_size[16],
  106.       segmax : SEGMAX,
  107.       segs : 16,
  108.       bytes : 16*65536
  109. }, {
  110.       offset_array : &exp1_offset[32],
  111.       size_array : &exp1_size[32],
  112.       segmax : SEGMAX,
  113.       segs : 1,
  114.       bytes : 65536
  115. }};
  116.  
  117.  
  118. int request_debug(void)
  119. {
  120.     int i;
  121.     PINT_Request *r;
  122.     PINT_Request *r_enc;
  123.     PINT_Request *r_dec;
  124.     PINT_Request_state *rs1;
  125.     PINT_request_file_data rf1;
  126.     PINT_Request_result seg1;
  127.     int ret = -1;
  128.     int pack_size = 0;
  129.  
  130.     /* DESCRIPTION: 
  131.      * in this case, we are doing a single write, of size 4390228,
  132.      * at offset 20M.  There are two servers.  We are looking at
  133.      * the output of the request processing code on the client side
  134.      */
  135.  
  136.     /* PVFS_Process_request arguments */
  137.     int retval;
  138.     int32_t blocklength = 4390228;
  139.     PVFS_size displacement = 20*1024*1024;
  140.  
  141.     PVFS_Request_indexed(1, &blocklength, &displacement, PVFS_BYTE, &r);
  142.  
  143.     /* allocate a new request and pack the original one into it */
  144.     pack_size = PINT_REQUEST_PACK_SIZE(r);
  145.     r_enc = (PINT_Request*)malloc(pack_size);
  146.     ret = PINT_request_commit(r_enc, r);
  147.     if(ret < 0)
  148.     {
  149.         fprintf(stderr, "PINT_Request_commit() failure.\n");
  150.         return(-1);
  151.     }
  152.     ret = PINT_request_encode(r_enc);
  153.     if(ret < 0)
  154.     {
  155.         fprintf(stderr, "PINT_Request_encode() failure.\n");
  156.         return(-1);
  157.     }
  158.  
  159.     /* decode the encoded request (hopefully ending up with something
  160.      * equivalent to the original request)
  161.      */
  162.     r_dec = (PINT_Request*)malloc(pack_size);
  163.     memcpy(r_dec, r_enc, pack_size);
  164.     free(r_enc);
  165.     free(r);
  166.     ret = PINT_request_decode(r_dec);
  167.     if(ret < 0)
  168.     {
  169.         fprintf(stderr, "PINT_request_decode() failure.\n");
  170.         return(-1);
  171.     }
  172.  
  173.     rs1 = PINT_new_request_state(r_dec);
  174.  
  175.     /* set up file data for each server */
  176.     PINT_dist_initialize(NULL);
  177.     rf1.server_nr = 1;
  178.     rf1.server_ct = 2;
  179.     rf1.fsize = 0;
  180.     rf1.dist = PINT_dist_create("simple_stripe");
  181.     rf1.extend_flag = 1;
  182.     PINT_dist_lookup(rf1.dist);
  183.  
  184.     /* set up response struct */
  185.     seg1.offset_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  186.     seg1.size_array = (int64_t *)malloc(SEGMAX * sizeof(int64_t));
  187.     seg1.segmax = SEGMAX;
  188.     seg1.bytemax = BYTEMAX;
  189.     seg1.bytes = 0;
  190.     seg1.segs = 0;
  191.  
  192.    /* Turn on debugging */
  193.     if (gossipflag)
  194.     {
  195.         gossip_enable_stderr();
  196.         gossip_set_debug_mask(1,GOSSIP_REQUEST_DEBUG);
  197.     }
  198.  
  199.     i = 0;
  200.  
  201.     printf("\n************************************\n");
  202.     printf("One request in CLIENT mode size 4390228 contiguous server 0 of 2\n");
  203.     printf("Simple stripe, default stripe size (64K)\n");
  204.     printf("Offset 20M, file size 0, extend flag\n");
  205.     printf("\n************************************\n");
  206.     do
  207.     {
  208.         seg1.bytes = 0;
  209.         seg1.segs = 0;
  210.  
  211.         /* process request */
  212.         /* note that bytemax is exactly large enough to hold all of the
  213.          * data that I should find here
  214.          */
  215.         retval = PINT_process_request(rs1, NULL, &rf1, &seg1, PINT_CLIENT);
  216.  
  217.         if(retval >= 0)
  218.         {
  219.              prtseg(&seg1,"Results obtained");
  220.            prtseg(&expected[i],"Results expected");
  221.            cmpseg(&seg1,&expected[i]);
  222.        }
  223.  
  224.       i++;
  225.  
  226.         if(PINT_REQUEST_DONE(rs1) && i < 3)
  227.         {
  228.             fprintf(stderr, "  AAIIEEE! Why am I done?\n");
  229.         }
  230.     } while(!PINT_REQUEST_DONE(rs1) && retval >= 0);
  231.     
  232.     if(retval < 0)
  233.     {
  234.         fprintf(stderr, "Error: PINT_process_request() failure.\n");
  235.         return(-1);
  236.     }
  237.     if(PINT_REQUEST_DONE(rs1))
  238.     {
  239.         printf("**** first request done.\n");
  240.     }
  241.  
  242.     return 0;
  243. }
  244.