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 / src / io / trove / trove.c < prev    next >
C/C++ Source or Header  |  2010-09-08  |  29KB  |  1,282 lines

  1. /*
  2.  * (C) 2002 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6.  
  7. /** \file
  8.  *  \ingroup troveint
  9.  *
  10.  *  Trove interface routines.
  11.  *
  12.  *  This file holds the top-level routines for Trove.  These routines 
  13.  *  are responsible for mapping Trove calls to specific underlying
  14.  *  implementations.
  15.  *
  16.  *  Currently there is just one implementation, DBPF (database plus
  17.  *  files), but there could be more.
  18.  */
  19.  
  20. #include <stdlib.h>
  21.  
  22. #include "trove.h"
  23. #include "trove-internal.h"
  24.  
  25. extern struct TROVE_keyval_ops  *keyval_method_table[];
  26. extern struct TROVE_dspace_ops  *dspace_method_table[];
  27. extern struct TROVE_bstream_ops *bstream_method_table[];
  28. extern struct TROVE_mgmt_ops    *mgmt_method_table[];
  29.  
  30. struct PINT_perf_counter* PINT_server_pc = NULL;
  31.  
  32. int TROVE_db_cache_size_bytes = 0;
  33. int TROVE_shm_key_hint = 0;
  34. int TROVE_max_concurrent_io = 16;
  35.  
  36. extern TROVE_method_callback global_trove_method_callback;
  37.  
  38. /** Initiate reading from a contiguous region in a bstream into a
  39.  *  contiguous region in memory.
  40.  */
  41. int trove_bstream_read_at(
  42.     TROVE_coll_id coll_id,
  43.     TROVE_handle handle,
  44.     void* buffer,
  45.     TROVE_size* inout_size_p,
  46.     TROVE_offset offset,
  47.     TROVE_ds_flags flags,
  48.     TROVE_vtag_s* vtag,
  49.     void* user_ptr,
  50.     TROVE_context_id context_id,
  51.     TROVE_op_id* out_op_id_p,
  52.     PVFS_hint  hints)
  53. {
  54.     TROVE_method_id method_id;
  55.  
  56.     method_id = global_trove_method_callback(coll_id);
  57.     if(method_id < 0)
  58.     {
  59.     return -TROVE_EINVAL;
  60.     }
  61.  
  62.     return bstream_method_table[method_id]->bstream_read_at(
  63.            coll_id,
  64.            handle,
  65.            buffer,
  66.            inout_size_p,
  67.            offset,
  68.            flags,
  69.            vtag,
  70.            user_ptr,
  71.            context_id,
  72.            out_op_id_p,
  73.            hints);
  74. }
  75.  
  76. /** Initiate writing from a contiguous region in memory into a
  77.  *  contiguous region in a bstream.
  78.  */
  79. int trove_bstream_write_at(
  80.     TROVE_coll_id coll_id,
  81.     TROVE_handle handle,
  82.     void* buffer,
  83.     TROVE_size* inout_size_p,
  84.     TROVE_offset offset,
  85.     TROVE_ds_flags flags,
  86.     TROVE_vtag_s* vtag,
  87.     void* user_ptr,
  88.     TROVE_context_id context_id,
  89.     TROVE_op_id* out_op_id_p,
  90.     PVFS_hint hints)
  91. {
  92.     TROVE_method_id method_id;
  93.  
  94.     method_id = global_trove_method_callback(coll_id);
  95.     if(method_id < 0)
  96.     {
  97.     return -TROVE_EINVAL;
  98.     }
  99.  
  100.     return bstream_method_table[method_id]->bstream_write_at(
  101.            coll_id,
  102.            handle,
  103.            buffer,
  104.            inout_size_p,
  105.            offset,
  106.            flags,
  107.            vtag,
  108.            user_ptr,
  109.            context_id,
  110.            out_op_id_p,
  111.            hints);
  112. }
  113.  
  114. /** Initiate resizing of a bstream.  This may be used to grow or
  115.  *  shrink a bstream.  It does not guarantee that space is actually
  116.  *  allocated; rather it changes the logical size of the bstream.
  117.  */
  118. int trove_bstream_resize(
  119.     TROVE_coll_id coll_id,
  120.     TROVE_handle handle,
  121.     TROVE_size* inout_size_p,
  122.     TROVE_ds_flags flags,
  123.     TROVE_vtag_s* vtag,
  124.     void* user_ptr,
  125.     TROVE_context_id context_id,
  126.     TROVE_op_id* out_op_id_p,
  127.     PVFS_hint hints)
  128. {
  129.     TROVE_method_id method_id;
  130.  
  131.     method_id = global_trove_method_callback(coll_id);
  132.     if(method_id < 0)
  133.     {
  134.     return -TROVE_EINVAL;
  135.     }
  136.  
  137.     return bstream_method_table[method_id]->bstream_resize(
  138.            coll_id,
  139.            handle,
  140.            inout_size_p,
  141.            flags,
  142.            vtag,
  143.            user_ptr,
  144.            context_id,
  145.            out_op_id_p,
  146.            hints);
  147. }
  148.  
  149. int trove_bstream_validate(
  150.     TROVE_coll_id coll_id,
  151.     TROVE_handle handle,
  152.     TROVE_ds_flags flags,
  153.     TROVE_vtag_s* vtag,
  154.     void* user_ptr,
  155.     TROVE_context_id context_id,
  156.     TROVE_op_id* out_op_id_p,
  157.     PVFS_hint hints)
  158. {
  159.     TROVE_method_id method_id;
  160.  
  161.     method_id = global_trove_method_callback(coll_id);
  162.     if(method_id < 0)
  163.     {
  164.     return -TROVE_EINVAL;
  165.     }
  166.  
  167.     return bstream_method_table[method_id]->bstream_validate(
  168.            coll_id,
  169.            handle,
  170.            flags,
  171.            vtag,
  172.            user_ptr,
  173.            context_id,
  174.            out_op_id_p,
  175.            hints);
  176. }
  177.  
  178. /** Initiate reading from a list of regions in a bstream into
  179.  *  a list of regions in memory.  Sizes of individual regions
  180.  *  in lists need not match, but total sizes must be equal.
  181.  */
  182. int trove_bstream_read_list(
  183.     TROVE_coll_id coll_id,
  184.     TROVE_handle handle,
  185.     char** mem_offset_array,
  186.     TROVE_size* mem_size_array,
  187.     int mem_count,
  188.     TROVE_offset* stream_offset_array,
  189.     TROVE_size* stream_size_array,
  190.     int stream_count,
  191.     TROVE_size* out_size_p,
  192.     TROVE_ds_flags flags,
  193.     TROVE_vtag_s* vtag,
  194.     void* user_ptr,
  195.     TROVE_context_id context_id,
  196.     TROVE_op_id* out_op_id_p,
  197.     PVFS_hint hints)
  198. {
  199.     TROVE_method_id method_id;
  200.  
  201.     method_id = global_trove_method_callback(coll_id);
  202.     if(method_id < 0)
  203.     {
  204.     return -TROVE_EINVAL;
  205.     }
  206.  
  207.     return bstream_method_table[method_id]->bstream_read_list(
  208.            coll_id,
  209.            handle,
  210.            mem_offset_array,
  211.            mem_size_array,
  212.            mem_count,
  213.            stream_offset_array,
  214.            stream_size_array,
  215.            stream_count,
  216.            out_size_p,
  217.            flags,
  218.            vtag,
  219.            user_ptr,
  220.            context_id,
  221.            out_op_id_p,
  222.            hints);
  223. }
  224.  
  225. /** Initiate writing from a list of regions in memory into a
  226.  *  list of regions in a bstream.  Sizes of individual regions
  227.  *  in lists need not match, but total sizes must be equal.
  228.  */
  229. int trove_bstream_write_list(
  230.     TROVE_coll_id coll_id,
  231.     TROVE_handle handle,
  232.     char** mem_offset_array,
  233.     TROVE_size* mem_size_array,
  234.     int mem_count,
  235.     TROVE_offset* stream_offset_array,
  236.     TROVE_size* stream_size_array,
  237.     int stream_count,
  238.     TROVE_size* out_size_p,
  239.     TROVE_ds_flags flags,
  240.     TROVE_vtag_s* vtag,
  241.     void* user_ptr,
  242.     TROVE_context_id context_id,
  243.     TROVE_op_id* out_op_id_p,
  244.     PVFS_hint  hints)
  245. {
  246.     TROVE_method_id method_id;
  247.  
  248.     method_id = global_trove_method_callback(coll_id);
  249.     if(method_id < 0)
  250.     {
  251.     return -TROVE_EINVAL;
  252.     }
  253.  
  254.    return bstream_method_table[method_id]->bstream_write_list(
  255.            coll_id,
  256.            handle,
  257.            mem_offset_array,
  258.            mem_size_array,
  259.            mem_count,
  260.            stream_offset_array,
  261.            stream_size_array,
  262.            stream_count,
  263.            out_size_p,
  264.            flags,
  265.            vtag,
  266.            user_ptr,
  267.            context_id,
  268.            out_op_id_p,
  269.            hints);
  270. }
  271.  
  272. /** Initiate movement of all data to storage devices for a specific
  273.  *  bstream.
  274.  */
  275. int trove_bstream_flush(
  276.     TROVE_coll_id coll_id,
  277.     TROVE_handle handle,
  278.     TROVE_ds_flags flags,
  279.     void* user_ptr,
  280.     TROVE_context_id context_id,
  281.     TROVE_op_id* out_op_id_p,
  282.                      PVFS_hint  hints)
  283. {
  284.     TROVE_method_id method_id;
  285.  
  286.     method_id = global_trove_method_callback(coll_id);
  287.     if(method_id < 0)
  288.     {
  289.     return -TROVE_EINVAL;
  290.     }
  291.  
  292.     return bstream_method_table[method_id]->bstream_flush(
  293.            coll_id,
  294.            handle,
  295.            flags,
  296.            user_ptr,
  297.            context_id,
  298.            out_op_id_p,
  299.            hints);
  300. }
  301.  
  302. /** Initiate read of a single keyword/value pair.
  303.  */
  304. int trove_keyval_read(
  305.     TROVE_coll_id coll_id,
  306.     TROVE_handle handle,
  307.     TROVE_keyval_s* key_p,
  308.     TROVE_keyval_s* val_p,
  309.     TROVE_ds_flags flags,
  310.     TROVE_vtag_s* vtag,
  311.     void* user_ptr,
  312.     TROVE_context_id context_id,
  313.     TROVE_op_id* out_op_id_p,
  314.     PVFS_hint  hints)
  315. {
  316.     TROVE_method_id method_id;
  317.  
  318.     method_id = global_trove_method_callback(coll_id);
  319.     if(method_id < 0)
  320.     {
  321.     return -TROVE_EINVAL;
  322.     }
  323.  
  324.     /* Check arguments */
  325.     if (key_p->buffer_sz < 2)
  326.     return -TROVE_EINVAL;
  327.     if(!(flags & TROVE_BINARY_KEY))
  328.     {
  329.         if (((char *)key_p->buffer)[key_p->buffer_sz-1] != 0)
  330.         return -TROVE_EINVAL;
  331.     }
  332.  
  333.     return keyval_method_table[method_id]->keyval_read(
  334.            coll_id,
  335.            handle,
  336.            key_p,
  337.            val_p,
  338.            flags,
  339.            vtag,
  340.            user_ptr,
  341.            context_id,
  342.            out_op_id_p,
  343.            hints);
  344. }
  345.  
  346. /** Initiate write of a single keyword/value pair.
  347.  *
  348.  *  Expects val_p->buffer to be user allocated and val_p->buffer_sz to
  349.  *  be size of buffer allocated.
  350.  *  If data is too large for buffer, returns error (Cannot allocate
  351.  *  Memory) and returns needed size in val_p->read_sz
  352.  */
  353. int trove_keyval_write(
  354.     TROVE_coll_id coll_id,
  355.     TROVE_handle handle,
  356.     TROVE_keyval_s* key_p,
  357.     TROVE_keyval_s* val_p,
  358.     TROVE_ds_flags flags,
  359.     TROVE_vtag_s* vtag,
  360.     void* user_ptr,
  361.     TROVE_context_id context_id,
  362.     TROVE_op_id* out_op_id_p,
  363.     PVFS_hint  hints)
  364. {
  365.     TROVE_method_id method_id;
  366.  
  367.     method_id = global_trove_method_callback(coll_id);
  368.     if(method_id < 0)
  369.     {
  370.     return -TROVE_EINVAL;
  371.     }
  372.  
  373.     /* Check arguments */
  374.     if (key_p->buffer_sz < 2)
  375.     return -TROVE_EINVAL;
  376.     if(!(flags & TROVE_BINARY_KEY))
  377.     {
  378.         if (((char *)key_p->buffer)[key_p->buffer_sz-1] != 0)
  379.         return -TROVE_EINVAL;
  380.     }
  381.  
  382.     return keyval_method_table[method_id]->keyval_write(
  383.            coll_id,
  384.            handle,
  385.            key_p,
  386.            val_p,
  387.            flags,
  388.            vtag,
  389.            user_ptr,
  390.            context_id,
  391.            out_op_id_p,
  392.            hints);
  393. }
  394.  
  395. /** Initiate removal of a keyword/value pair from a given data space.
  396.  */
  397. int trove_keyval_remove(
  398.     TROVE_coll_id coll_id,
  399.     TROVE_handle handle,
  400.     TROVE_keyval_s* key_p,
  401.     TROVE_keyval_s* val_p,
  402.     TROVE_ds_flags flags,
  403.     TROVE_vtag_s* vtag,
  404.     void* user_ptr,
  405.     TROVE_context_id context_id,
  406.     TROVE_op_id* out_op_id_p,
  407.     PVFS_hint  hints)
  408. {
  409.     TROVE_method_id method_id;
  410.  
  411.     method_id = global_trove_method_callback(coll_id);
  412.     if(method_id < 0)
  413.     {
  414.     return -TROVE_EINVAL;
  415.     }
  416.  
  417.     return keyval_method_table[method_id]->keyval_remove(
  418.            coll_id,
  419.            handle,
  420.            key_p,
  421.        val_p,
  422.            flags,
  423.            vtag,
  424.            user_ptr,
  425.            context_id,
  426.            out_op_id_p,
  427.            hints);
  428. }
  429.  
  430. int trove_keyval_validate(
  431.     TROVE_coll_id coll_id,
  432.     TROVE_handle handle,
  433.     TROVE_ds_flags flags,
  434.     TROVE_vtag_s* vtag,
  435.     void* user_ptr,
  436.     TROVE_context_id context_id,
  437.     TROVE_op_id* out_op_id_p,
  438.     PVFS_hint  hints)
  439. {
  440.     TROVE_method_id method_id;
  441.  
  442.     method_id = global_trove_method_callback(coll_id);
  443.     if(method_id < 0)
  444.     {
  445.     return -TROVE_EINVAL;
  446.     }
  447.  
  448.     return keyval_method_table[method_id]->keyval_validate(
  449.            coll_id,
  450.            handle,
  451.            flags,
  452.            vtag,
  453.            user_ptr,
  454.            context_id,
  455.            out_op_id_p,
  456.            hints);
  457. }
  458.  
  459. int trove_keyval_iterate(
  460.     TROVE_coll_id coll_id,
  461.     TROVE_handle handle,
  462.     TROVE_ds_position* position_p,
  463.     TROVE_keyval_s* key_array,
  464.     TROVE_keyval_s* val_array,
  465.     int* inout_count_p,
  466.     TROVE_ds_flags flags,
  467.     TROVE_vtag_s* vtag,
  468.     void* user_ptr,
  469.     TROVE_context_id context_id,
  470.     TROVE_op_id* out_op_id_p,
  471.     PVFS_hint  hints)
  472. {
  473.     TROVE_method_id method_id;
  474.  
  475.     method_id = global_trove_method_callback(coll_id);
  476.     if(method_id < 0)
  477.     {
  478.     return -TROVE_EINVAL;
  479.     }
  480.  
  481.     return keyval_method_table[method_id]->keyval_iterate(
  482.            coll_id,
  483.            handle,
  484.            position_p,
  485.            key_array,
  486.            val_array,
  487.            inout_count_p,
  488.            flags,
  489.            vtag,
  490.            user_ptr,
  491.            context_id,
  492.            out_op_id_p,
  493.            hints);
  494. }
  495.  
  496. int trove_keyval_iterate_keys(
  497.     TROVE_coll_id coll_id,
  498.     TROVE_handle handle,
  499.     TROVE_ds_position* position_p,
  500.     TROVE_keyval_s* key_array,
  501.     int* inout_count_p,
  502.     TROVE_ds_flags flags,
  503.     TROVE_vtag_s* vtag,
  504.     void* user_ptr,
  505.     TROVE_context_id context_id,
  506.     TROVE_op_id* out_op_id_p,
  507.     PVFS_hint  hints)
  508. {
  509.     TROVE_method_id method_id;
  510.  
  511.     method_id = global_trove_method_callback(coll_id);
  512.     if(method_id < 0)
  513.     {
  514.     return -TROVE_EINVAL;
  515.     }
  516.  
  517.     return keyval_method_table[method_id]->keyval_iterate_keys(
  518.            coll_id,
  519.            handle,
  520.            position_p,
  521.            key_array,
  522.            inout_count_p,
  523.            flags,
  524.            vtag,
  525.            user_ptr,
  526.            context_id,
  527.            out_op_id_p,
  528.            hints);
  529. }
  530.  
  531. /** Initiate read of multiple keyword/value pairs from the same
  532.  *  data space as a single operation.
  533.  */
  534. int trove_keyval_read_list(
  535.     TROVE_coll_id coll_id,
  536.     TROVE_handle handle,
  537.     TROVE_keyval_s* key_array,
  538.     TROVE_keyval_s* val_array,
  539.     TROVE_ds_state* err_array,
  540.     int count,
  541.     TROVE_ds_flags flags,
  542.     TROVE_vtag_s* vtag,
  543.     void* user_ptr,
  544.     TROVE_context_id context_id,
  545.     TROVE_op_id* out_op_id_p,
  546.     PVFS_hint  hints)
  547. {
  548.     TROVE_method_id method_id;
  549.     int i;
  550.  
  551.     method_id = global_trove_method_callback(coll_id);
  552.     if(method_id < 0)
  553.     {
  554.     return -TROVE_EINVAL;
  555.     }
  556.  
  557.     /* Check arguments */
  558.     for (i = 0; i < count; i++)
  559.     {
  560.     if (key_array[i].buffer_sz < 2)
  561.         return -TROVE_EINVAL;
  562.         if(!(flags & TROVE_BINARY_KEY))
  563.         {
  564.         if (((char *)key_array[i].buffer)[key_array[i].buffer_sz-1] != 0)
  565.             return -TROVE_EINVAL;
  566.         }
  567.     }
  568.  
  569.     return keyval_method_table[method_id]->keyval_read_list(
  570.            coll_id,
  571.            handle,
  572.            key_array,
  573.            val_array,
  574.        err_array,
  575.            count,
  576.            flags,
  577.            vtag,
  578.            user_ptr,
  579.            context_id,
  580.            out_op_id_p,
  581.            hints);
  582. }
  583.  
  584. /** Initiate storing of multiple keyword/value pairs to the same
  585.  *  data space as a single operation.
  586.  */
  587. int trove_keyval_write_list(
  588.     TROVE_coll_id coll_id,
  589.     TROVE_handle handle,
  590.     TROVE_keyval_s* key_array,
  591.     TROVE_keyval_s* val_array,
  592.     int count,
  593.     TROVE_ds_flags flags,
  594.     TROVE_vtag_s* vtag,
  595.     void* user_ptr,
  596.     TROVE_context_id context_id,
  597.     TROVE_op_id* out_op_id_p,
  598.     PVFS_hint  hints)
  599. {
  600.     int i;
  601.     TROVE_method_id method_id;
  602.  
  603.     method_id = global_trove_method_callback(coll_id);
  604.     if(method_id < 0)
  605.     {
  606.     return -TROVE_EINVAL;
  607.     }
  608.  
  609.     /* Check arguments */
  610.     for (i = 0; i < count; i++)
  611.     {
  612.     if (key_array[i].buffer_sz < 2)
  613.         return -TROVE_EINVAL;
  614.         if(!(flags & TROVE_BINARY_KEY))
  615.         {
  616.         if (((char *)key_array[i].buffer)[key_array[i].buffer_sz-1] != 0)
  617.             return -TROVE_EINVAL;
  618.         }
  619.     }
  620.  
  621.     return keyval_method_table[method_id]->keyval_write_list(
  622.            coll_id,
  623.            handle,
  624.            key_array,
  625.            val_array,
  626.            count,
  627.            flags,
  628.            vtag,
  629.            user_ptr,
  630.            context_id,
  631.            out_op_id_p,
  632.        hints);
  633. }
  634.  
  635. /** Initiate storing of multiple keyword/value pairs to the same
  636.  *  data space as a single operation.
  637.  */
  638. int trove_keyval_remove_list(
  639.     TROVE_coll_id coll_id,
  640.     TROVE_handle handle,
  641.     TROVE_keyval_s* key_array,
  642.     TROVE_keyval_s* val_array,
  643.     int *error_array,
  644.     int count,
  645.     TROVE_ds_flags flags,
  646.     TROVE_vtag_s* vtag,
  647.     void* user_ptr,
  648.     TROVE_context_id context_id,
  649.     TROVE_op_id* out_op_id_p,
  650.     PVFS_hint hints)
  651. {
  652.     int i;
  653.     TROVE_method_id method_id;
  654.  
  655.     method_id = global_trove_method_callback(coll_id);
  656.     if(method_id < 0)
  657.     {
  658.     return -TROVE_EINVAL;
  659.     }
  660.  
  661.     /* Check arguments */
  662.     for (i = 0; i < count; i++)
  663.     {
  664.     if (key_array[i].buffer_sz < 2)
  665.         return -TROVE_EINVAL;
  666.         if(!(flags & TROVE_BINARY_KEY))
  667.         {
  668.             if (((char *)key_array[i].buffer)[key_array[i].buffer_sz-1] != 0)
  669.                 return -TROVE_EINVAL;
  670.         }
  671.     }
  672.  
  673.     return keyval_method_table[method_id]->keyval_remove_list(
  674.            coll_id,
  675.            handle,
  676.            key_array,
  677.            val_array,
  678.        error_array,
  679.            count,
  680.            flags,
  681.            vtag,
  682.            user_ptr,
  683.            context_id,
  684.            out_op_id_p,
  685.            hints);
  686. }
  687.  
  688. /** Initiate movement of all keyword/value pairs to storage for a given
  689.  *  data space.
  690.  */
  691. int trove_keyval_flush(
  692.     TROVE_coll_id coll_id,
  693.     TROVE_handle handle,
  694.     TROVE_ds_flags flags,
  695.     void* user_ptr,
  696.     TROVE_context_id context_id,
  697.     TROVE_op_id* out_op_id_p,
  698.     PVFS_hint  hints)
  699. {
  700.     TROVE_method_id method_id;
  701.  
  702.     method_id = global_trove_method_callback(coll_id);
  703.     if(method_id < 0)
  704.     {
  705.     return -TROVE_EINVAL;
  706.     }
  707.  
  708.     return keyval_method_table[method_id]->keyval_flush(
  709.            coll_id,
  710.            handle,
  711.            flags,
  712.            user_ptr,
  713.            context_id,
  714.            out_op_id_p,
  715.            hints);
  716. }
  717.  
  718. int trove_keyval_get_handle_info(TROVE_coll_id coll_id,
  719.                  TROVE_handle handle,
  720.                  TROVE_ds_flags flags,
  721.                  TROVE_keyval_handle_info *info,
  722.                  void * user_ptr,
  723.                  TROVE_context_id context_id,
  724.                  TROVE_op_id *out_op_id_p,
  725.                  PVFS_hint  hints)
  726. {
  727.     TROVE_method_id method_id;
  728.  
  729.     method_id = global_trove_method_callback(coll_id);
  730.     if(method_id < 0)
  731.     {
  732.     return -TROVE_EINVAL;
  733.     }
  734.  
  735.     return keyval_method_table[method_id]->keyval_get_handle_info(
  736.     coll_id,
  737.     handle,
  738.     flags,
  739.     info,
  740.     user_ptr,
  741.     context_id,
  742.     out_op_id_p,
  743.     hints);
  744. }
  745.  
  746. /** Initiate creation of multiple new data spaces.
  747.  */
  748. int trove_dspace_create_list(
  749.     TROVE_coll_id coll_id,
  750.     TROVE_handle_extent_array* handle_extent_array,
  751.     TROVE_handle* out_handle_array,
  752.     int count,
  753.     TROVE_ds_type type,
  754.     TROVE_keyval_s* hint,
  755.     TROVE_ds_flags flags,
  756.     void* user_ptr,
  757.     TROVE_context_id context_id,
  758.     TROVE_op_id* out_op_id_p,
  759.     PVFS_hint hints)
  760. {
  761.     TROVE_method_id method_id;
  762.  
  763.     method_id = global_trove_method_callback(coll_id);
  764.     if(method_id < 0)
  765.     {
  766.     return -TROVE_EINVAL;
  767.     }
  768.  
  769.     return dspace_method_table[method_id]->dspace_create_list(
  770.            coll_id,
  771.            handle_extent_array,
  772.            out_handle_array,
  773.            count,
  774.            type,
  775.            hint,
  776.            flags,
  777.            user_ptr,
  778.            context_id,
  779.            out_op_id_p,
  780.        hints);
  781. }
  782.  
  783. /** Initiate creation of a new data space.
  784.  */
  785. int trove_dspace_create(
  786.     TROVE_coll_id coll_id,
  787.     TROVE_handle_extent_array* handle_extent_array,
  788.     TROVE_handle* out_handle,
  789.     TROVE_ds_type type,
  790.     TROVE_keyval_s* hint,
  791.     TROVE_ds_flags flags,
  792.     void* user_ptr,
  793.     TROVE_context_id context_id,
  794.     TROVE_op_id* out_op_id_p,
  795.     PVFS_hint  hints)
  796. {
  797.     TROVE_method_id method_id;
  798.  
  799.     method_id = global_trove_method_callback(coll_id);
  800.     if(method_id < 0)
  801.     {
  802.     return -TROVE_EINVAL;
  803.     }
  804.  
  805.     return dspace_method_table[method_id]->dspace_create(
  806.            coll_id,
  807.            handle_extent_array,
  808.            out_handle,
  809.            type,
  810.            hint,
  811.            flags,
  812.            user_ptr,
  813.            context_id,
  814.            out_op_id_p,
  815.            hints);
  816. }
  817.  
  818. /** Initiate removal of a list of data spaces.
  819.  */
  820. int trove_dspace_remove_list(
  821.     TROVE_coll_id coll_id,
  822.     TROVE_handle* handle_array,
  823.     TROVE_ds_state* error_array,
  824.     int count,
  825.     TROVE_ds_flags flags,
  826.     void* user_ptr,
  827.     TROVE_context_id context_id,
  828.     TROVE_op_id* out_op_id_p,
  829.     PVFS_hint hints)
  830. {
  831.     TROVE_method_id method_id;
  832.  
  833.     method_id = global_trove_method_callback(coll_id);
  834.     if(method_id < 0)
  835.     {
  836.     return -TROVE_EINVAL;
  837.     }
  838.  
  839.     return dspace_method_table[method_id]->dspace_remove_list(
  840.            coll_id,
  841.            handle_array,
  842.            error_array,
  843.            count,
  844.            flags,
  845.            user_ptr,
  846.            context_id,
  847.            out_op_id_p);
  848. }
  849.  
  850. /** Initiate removal of a data space.
  851.  */
  852. int trove_dspace_remove(
  853.     TROVE_coll_id coll_id,
  854.     TROVE_handle handle,
  855.     TROVE_ds_flags flags,
  856.     void* user_ptr,
  857.     TROVE_context_id context_id,
  858.     TROVE_op_id* out_op_id_p,
  859.     PVFS_hint  hints)
  860. {
  861.     TROVE_method_id method_id;
  862.  
  863.     method_id = global_trove_method_callback(coll_id);
  864.     if(method_id < 0)
  865.     {
  866.     return -TROVE_EINVAL;
  867.     }
  868.  
  869.     return dspace_method_table[method_id]->dspace_remove(
  870.            coll_id,
  871.            handle,
  872.            flags,
  873.            user_ptr,
  874.            context_id,
  875.            out_op_id_p,
  876.            hints);
  877. }
  878.  
  879. int trove_dspace_iterate_handles(
  880.     TROVE_coll_id coll_id,
  881.     TROVE_ds_position* position_p,
  882.     TROVE_handle* handle_array,
  883.     int* inout_count_p,
  884.     TROVE_ds_flags flags,
  885.     TROVE_vtag_s* vtag,
  886.     void* user_ptr,
  887.     TROVE_context_id context_id,
  888.     TROVE_op_id* out_op_id_p)
  889. {
  890.     TROVE_method_id method_id;
  891.  
  892.     method_id = global_trove_method_callback(coll_id);
  893.     if(method_id < 0)
  894.     {
  895.     return -TROVE_EINVAL;
  896.     }
  897.  
  898.     return dspace_method_table[method_id]->dspace_iterate_handles(
  899.            coll_id,
  900.            position_p,
  901.            handle_array,
  902.            inout_count_p,
  903.            flags,
  904.            vtag,
  905.            user_ptr,
  906.            context_id,
  907.            out_op_id_p);
  908. }
  909.  
  910. int trove_dspace_verify(
  911.     TROVE_coll_id coll_id,
  912.     TROVE_handle handle,
  913.     TROVE_ds_type* type,
  914.     TROVE_ds_flags flags,
  915.     void* user_ptr,
  916.     TROVE_context_id context_id,
  917.     TROVE_op_id* out_op_id_p,
  918.     PVFS_hint  hints)
  919. {
  920.     TROVE_method_id method_id;
  921.  
  922.     method_id = global_trove_method_callback(coll_id);
  923.     if(method_id < 0)
  924.     {
  925.     return -TROVE_EINVAL;
  926.     }
  927.  
  928.     return dspace_method_table[method_id]->dspace_verify(
  929.            coll_id,
  930.            handle,
  931.            type,
  932.            flags,
  933.            user_ptr,
  934.            context_id,
  935.            out_op_id_p,
  936.            hints);
  937. }
  938.  
  939. /** Initiate retrieval of attributes for a given data space.
  940.  */
  941. int trove_dspace_getattr(
  942.     TROVE_coll_id coll_id,
  943.     TROVE_handle handle,
  944.     TROVE_ds_attributes_s* ds_attr_p,
  945.     TROVE_ds_flags flags,
  946.     void* user_ptr,
  947.     TROVE_context_id context_id,
  948.     TROVE_op_id* out_op_id_p,
  949.     PVFS_hint  hints)
  950. {
  951.     TROVE_method_id method_id;
  952.  
  953.     method_id = global_trove_method_callback(coll_id);
  954.     if(method_id < 0)
  955.     {
  956.     return -TROVE_EINVAL;
  957.     }
  958.  
  959.     return dspace_method_table[method_id]->dspace_getattr(
  960.            coll_id,
  961.            handle,
  962.            ds_attr_p,
  963.            flags,
  964.            user_ptr,
  965.            context_id,
  966.            out_op_id_p,
  967.            hints);
  968. }
  969.  
  970. /** Initiate retrieval of attributes for a list of handles.
  971.  */
  972. int trove_dspace_getattr_list(
  973.     TROVE_coll_id coll_id,
  974.      int nhandles,
  975.     TROVE_handle *handle_array,
  976.     TROVE_ds_attributes_s *ds_attr_p,
  977.      TROVE_ds_state  *error_array,
  978.     TROVE_ds_flags flags,
  979.     void* user_ptr,
  980.     TROVE_context_id context_id,
  981.     TROVE_op_id* out_op_id_p,
  982.     PVFS_hint  hints)
  983. {
  984.     int method_id;
  985.  
  986.     method_id = global_trove_method_callback(coll_id);
  987.     if (method_id < 0) {
  988.         return -TROVE_EINVAL;
  989.     }
  990.     return dspace_method_table[method_id]->dspace_getattr_list(
  991.            coll_id,
  992.        nhandles,
  993.            handle_array,
  994.            ds_attr_p,
  995.        error_array,
  996.        flags,
  997.            user_ptr,
  998.            context_id,
  999.            out_op_id_p,
  1000.            hints);
  1001. }
  1002.  
  1003. int trove_dspace_setattr(
  1004.     TROVE_coll_id coll_id,
  1005.     TROVE_handle handle,
  1006.     TROVE_ds_attributes_s* ds_attr_p,
  1007.     TROVE_ds_flags flags,
  1008.     void* user_ptr,
  1009.     TROVE_context_id context_id,
  1010.     TROVE_op_id* out_op_id_p,
  1011.     PVFS_hint  hints)
  1012. {
  1013.     TROVE_method_id method_id;
  1014.  
  1015.     method_id = global_trove_method_callback(coll_id);
  1016.     if(method_id < 0)
  1017.     {
  1018.     return -TROVE_EINVAL;
  1019.     }
  1020.  
  1021.     return dspace_method_table[method_id]->dspace_setattr(
  1022.            coll_id,
  1023.            handle,
  1024.            ds_attr_p,
  1025.            flags,
  1026.            user_ptr,
  1027.            context_id,
  1028.            out_op_id_p,
  1029.            hints);
  1030. }
  1031.  
  1032. int trove_dspace_cancel(
  1033.     TROVE_coll_id coll_id,
  1034.     TROVE_op_id id,
  1035.     TROVE_context_id context_id)
  1036. {
  1037.     TROVE_method_id method_id;
  1038.  
  1039.     method_id = global_trove_method_callback(coll_id);
  1040.     if(method_id < 0)
  1041.     {
  1042.     return -TROVE_EINVAL;
  1043.     }
  1044.  
  1045.     return dspace_method_table[method_id]->dspace_cancel(
  1046.            coll_id,
  1047.            id,
  1048.            context_id);
  1049. }
  1050.  
  1051. /** Test for completion of a single trove operation.
  1052.  */
  1053. int trove_dspace_test(
  1054.     TROVE_coll_id coll_id,
  1055.     TROVE_op_id id,
  1056.     TROVE_context_id context_id,
  1057.     int* out_count_p,
  1058.     TROVE_vtag_s* vtag,
  1059.     void** returned_user_ptr_p,
  1060.     TROVE_ds_state* state_p,
  1061.     int max_idle_time_ms)
  1062. {
  1063.     TROVE_method_id method_id;
  1064.  
  1065.     method_id = global_trove_method_callback(coll_id);
  1066.     if(method_id < 0)
  1067.     {
  1068.     return -TROVE_EINVAL;
  1069.     }
  1070.  
  1071.     return dspace_method_table[method_id]->dspace_test(
  1072.            coll_id,
  1073.            id,
  1074.            context_id,
  1075.            out_count_p,
  1076.            vtag,
  1077.            returned_user_ptr_p,
  1078.            state_p,
  1079.            max_idle_time_ms);
  1080. }
  1081.  
  1082. /** Test for completion of one or more trove operations.
  1083.  */
  1084. int trove_dspace_testsome(
  1085.     TROVE_coll_id coll_id,
  1086.     TROVE_context_id context_id,
  1087.     TROVE_op_id* ds_id_array,
  1088.     int* inout_count_p,
  1089.     int* out_index_array,
  1090.     TROVE_vtag_s* vtag_array,
  1091.     void** returned_user_ptr_array,
  1092.     TROVE_ds_state* state_array,
  1093.     int max_idle_time_ms)
  1094. {
  1095.     TROVE_method_id method_id;
  1096.  
  1097.     method_id = global_trove_method_callback(coll_id);
  1098.     if(method_id < 0)
  1099.     {
  1100.     return -TROVE_EINVAL;
  1101.     }
  1102.  
  1103.     return dspace_method_table[method_id]->dspace_testsome(
  1104.            coll_id,
  1105.            context_id,
  1106.            ds_id_array,
  1107.            inout_count_p,
  1108.            out_index_array,
  1109.            vtag_array,
  1110.            returned_user_ptr_array,
  1111.            state_array,
  1112.            max_idle_time_ms);
  1113. }
  1114.  
  1115. /** Test for completion of any trove operation within a given context.
  1116.  */
  1117. int trove_dspace_testcontext(
  1118.     TROVE_coll_id coll_id,
  1119.     TROVE_op_id* ds_id_array,
  1120.     int* inout_count_p,
  1121.     TROVE_ds_state* state_array,
  1122.     void** user_ptr_array,
  1123.     int max_idle_time_ms,
  1124.     TROVE_context_id context_id)
  1125. {
  1126.     TROVE_method_id method_id;
  1127.  
  1128.     method_id = global_trove_method_callback(coll_id);
  1129.     if(method_id < 0)
  1130.     {
  1131.     return -TROVE_EINVAL;
  1132.     }
  1133.  
  1134.     return dspace_method_table[method_id]->dspace_testcontext(
  1135.            coll_id,
  1136.            ds_id_array,
  1137.            inout_count_p,
  1138.            state_array,
  1139.            user_ptr_array,
  1140.            max_idle_time_ms,
  1141.            context_id);
  1142. }
  1143.  
  1144. int trove_collection_geteattr(
  1145.     TROVE_coll_id coll_id,
  1146.     TROVE_keyval_s* key_p,
  1147.     TROVE_keyval_s* val_p,
  1148.     TROVE_ds_flags flags,
  1149.     void* user_ptr,
  1150.     TROVE_context_id context_id,
  1151.     TROVE_op_id* out_op_id_p)
  1152. {
  1153.     TROVE_method_id method_id;
  1154.  
  1155.     method_id = global_trove_method_callback(coll_id);
  1156.     if(method_id < 0)
  1157.     {
  1158.     return -TROVE_EINVAL;
  1159.     }
  1160.  
  1161.     return mgmt_method_table[method_id]->collection_geteattr(
  1162.            coll_id,
  1163.            key_p,
  1164.            val_p,
  1165.            flags,
  1166.            user_ptr,
  1167.            context_id,
  1168.            out_op_id_p);
  1169. }
  1170.  
  1171. int trove_collection_seteattr(
  1172.     TROVE_coll_id coll_id,
  1173.     TROVE_keyval_s* key_p,
  1174.     TROVE_keyval_s* val_p,
  1175.     TROVE_ds_flags flags,
  1176.     void* user_ptr,
  1177.     TROVE_context_id context_id,
  1178.     TROVE_op_id* out_op_id_p)
  1179. {
  1180.     TROVE_method_id method_id;
  1181.  
  1182.     method_id = global_trove_method_callback(coll_id);
  1183.     if(method_id < 0)
  1184.     {
  1185.     return -TROVE_EINVAL;
  1186.     }
  1187.  
  1188.     return mgmt_method_table[method_id]->collection_seteattr(
  1189.            coll_id,
  1190.            key_p,
  1191.            val_p,
  1192.            flags,
  1193.            user_ptr,
  1194.            context_id,
  1195.            out_op_id_p);
  1196. }
  1197.  
  1198. int trove_collection_deleattr(
  1199.     TROVE_coll_id coll_id,
  1200.     TROVE_keyval_s* key_p,
  1201.     TROVE_ds_flags flags,
  1202.     void* user_ptr,
  1203.     TROVE_context_id context_id,
  1204.     TROVE_op_id* out_op_id_p)
  1205. {
  1206.     TROVE_method_id method_id;
  1207.  
  1208.     method_id = global_trove_method_callback(coll_id);
  1209.     if(method_id < 0)
  1210.     {
  1211.     return -TROVE_EINVAL;
  1212.     }
  1213.  
  1214.     return mgmt_method_table[method_id]->collection_deleattr(
  1215.            coll_id,
  1216.            key_p,
  1217.            flags,
  1218.            user_ptr,
  1219.            context_id,
  1220.            out_op_id_p);
  1221. }
  1222.  
  1223. int trove_collection_getinfo(
  1224.     TROVE_coll_id coll_id,
  1225.     TROVE_context_id context_id,
  1226.     TROVE_coll_getinfo_options opt,
  1227.     void* parameter)
  1228. {
  1229.     TROVE_method_id method_id;
  1230.  
  1231.     method_id = global_trove_method_callback(coll_id);
  1232.     if(method_id < 0)
  1233.     {
  1234.     return -TROVE_EINVAL;
  1235.     }
  1236.  
  1237.     return mgmt_method_table[method_id]->collection_getinfo(
  1238.            coll_id,
  1239.            context_id,
  1240.            opt,
  1241.            parameter);
  1242. }
  1243.  
  1244. int trove_collection_setinfo(
  1245.     TROVE_coll_id coll_id,
  1246.     TROVE_context_id context_id,
  1247.     int option,
  1248.     void* parameter)
  1249. {
  1250.     TROVE_method_id method_id;
  1251.  
  1252.     if(option == TROVE_DB_CACHE_SIZE_BYTES)
  1253.     {
  1254.     TROVE_db_cache_size_bytes = *((int *)parameter);
  1255.     return 0;
  1256.     }
  1257.     if(option == TROVE_SHM_KEY_HINT)
  1258.     {
  1259.         TROVE_shm_key_hint = *((int*)parameter);
  1260.     return(0);
  1261.     }
  1262.     if(option == TROVE_MAX_CONCURRENT_IO)
  1263.     {
  1264.         TROVE_max_concurrent_io = *((int*)parameter);
  1265.     return(0);
  1266.     }
  1267.  
  1268.     method_id = global_trove_method_callback(coll_id);
  1269.     if(method_id < 0)
  1270.     {
  1271.     return -TROVE_EINVAL;
  1272.     }
  1273.  
  1274.     return mgmt_method_table[method_id]->collection_setinfo(
  1275.        method_id,
  1276.            coll_id,
  1277.            context_id,
  1278.            option,
  1279.            parameter);
  1280. }
  1281.  
  1282.