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 / client / sysint / mgmt-misc.c < prev    next >
C/C++ Source or Header  |  2008-11-19  |  5KB  |  228 lines

  1. /*
  2.  * (C) 2001 Clemson University and The University of Chicago
  3.  *
  4.  * See COPYING in top-level directory.
  5.  *
  6.  */
  7.  
  8. /** \file
  9.  *  \ingroup mgmtint
  10.  *
  11.  *  Various PVFS2 management interface routines.  Many are built on top of
  12.  *  other management interface routines.
  13.  */
  14.  
  15. #include <assert.h>
  16.  
  17. #include "pvfs2-types.h"
  18. #include "pvfs2-mgmt.h"
  19. #include "bmi.h"
  20. #include "pint-sysint-utils.h"
  21. #include "pint-cached-config.h"
  22. #include "pint-util.h"
  23. #include "server-config.h"
  24. #include "client-state-machine.h"
  25.  
  26. /** Maps a given opaque server address back to a string address.  Also
  27.  *  fills in server type.
  28.  *
  29.  *  \return Pointer to string on success, NULL on failure.
  30.  */
  31. const char *PVFS_mgmt_map_addr(
  32.     PVFS_fs_id fs_id,
  33.     PVFS_credentials *credentials,
  34.     PVFS_BMI_addr_t addr,
  35.     int *server_type)
  36. {
  37.     return PINT_cached_config_map_addr(fs_id, addr, server_type);
  38. }
  39.  
  40. PVFS_error PVFS_mgmt_map_handle(
  41.     PVFS_fs_id fs_id,
  42.     PVFS_handle handle,
  43.     PVFS_BMI_addr_t *addr)
  44. {
  45.     return PINT_cached_config_map_to_server(addr, handle, fs_id);
  46. }
  47.  
  48. /** Obtains file system statistics from all servers in a given
  49.  *  file system.
  50.  *
  51.  *  \return 0 on success, -PVFS_error on failure.
  52.  */
  53. PVFS_error PVFS_mgmt_statfs_all(
  54.     PVFS_fs_id fs_id,
  55.     PVFS_credentials *credentials,
  56.     struct PVFS_mgmt_server_stat *stat_array,
  57.     int *inout_count_p,
  58.     PVFS_error_details *details,
  59.     PVFS_hint hints)
  60. {
  61.     PVFS_error ret = -PVFS_EINVAL;
  62.     PVFS_BMI_addr_t *addr_array = NULL;
  63.     int real_count = 0;
  64.  
  65.     ret = PINT_cached_config_count_servers(
  66.         fs_id,  PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER,
  67.         &real_count);
  68.  
  69.     if (ret < 0)
  70.     {
  71.     return ret;
  72.     }
  73.  
  74.     if (real_count > *inout_count_p)
  75.     {
  76.     return -PVFS_EOVERFLOW;
  77.     }
  78.  
  79.     *inout_count_p = real_count;
  80.  
  81.     addr_array = (PVFS_BMI_addr_t *)malloc(
  82.         real_count*sizeof(PVFS_BMI_addr_t));
  83.     if (addr_array == NULL)
  84.     {
  85.     return -PVFS_ENOMEM;
  86.     }
  87.  
  88.     /* generate default list of servers */
  89.     ret = PINT_cached_config_get_server_array(
  90.         fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER,
  91.         addr_array, &real_count);
  92.  
  93.     if (ret < 0)
  94.     {
  95.     free(addr_array);
  96.     return ret;
  97.     }
  98.     
  99.     ret = PVFS_mgmt_statfs_list(
  100.         fs_id, credentials, stat_array, addr_array,
  101.         real_count, details, hints);
  102.  
  103.     free(addr_array);
  104.  
  105.     return ret;
  106. }
  107.  
  108. /** Set a single run-time parameter on all servers in a given
  109.  *  file system.
  110.  *
  111.  *  \return 0 on success, -PVFS_error on failure.
  112.  */
  113. PVFS_error PVFS_mgmt_setparam_all(
  114.     PVFS_fs_id fs_id,
  115.     PVFS_credentials *credentials,
  116.     enum PVFS_server_param param,
  117.     struct PVFS_mgmt_setparam_value *value,
  118.     PVFS_error_details *details,
  119.     PVFS_hint hints)
  120. {
  121.     int count = 0;
  122.     PVFS_error ret = -PVFS_EINVAL;
  123.     PVFS_BMI_addr_t *addr_array = NULL;
  124.     ret = PINT_cached_config_count_servers(
  125.         fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER, &count);
  126.  
  127.     if (ret < 0)
  128.     {
  129.     return ret;
  130.     }
  131.  
  132.     addr_array = (PVFS_BMI_addr_t *)malloc(
  133.         (count * sizeof(PVFS_BMI_addr_t)));
  134.     if (addr_array == NULL)
  135.     {
  136.     return -PVFS_ENOMEM;
  137.     }
  138.  
  139.     /* generate default list of servers */
  140.     ret = PINT_cached_config_get_server_array(
  141.         fs_id, PVFS_MGMT_IO_SERVER|PVFS_MGMT_META_SERVER,
  142.         addr_array, &count);
  143.  
  144.     if (ret < 0)
  145.     {
  146.     free(addr_array);
  147.     return ret;
  148.     }
  149.  
  150.     ret = PVFS_mgmt_setparam_list(
  151.         fs_id, credentials, param, value, addr_array,
  152.         count, details, hints);
  153.  
  154.     free(addr_array);
  155.  
  156.     return ret;
  157. }
  158.  
  159. /** Sets a single run-time parameter on a specific server.
  160.  */
  161. PVFS_error PVFS_mgmt_setparam_single(
  162.     PVFS_fs_id fs_id,
  163.     PVFS_credentials *credentials,
  164.     enum PVFS_server_param param,
  165.     struct PVFS_mgmt_setparam_value *value,
  166.     char *server_addr_str,
  167.     PVFS_error_details *details,
  168.     PVFS_hint hints)
  169. {
  170.     PVFS_error ret = -PVFS_EINVAL;
  171.     PVFS_BMI_addr_t addr;
  172.  
  173.     if (server_addr_str && (BMI_addr_lookup(&addr, server_addr_str) == 0))
  174.     {
  175.         ret = PVFS_mgmt_setparam_list(
  176.             fs_id, credentials, param, value,
  177.             &addr, 1, details, hints);
  178.     }
  179.     return ret;
  180. }
  181.  
  182. /** Obtains a list of all servers of a given type in a specific
  183.  *  file system.
  184.  *
  185.  *  \return 0 on success, -PVFS_error on failure.
  186.  */
  187. PVFS_error PVFS_mgmt_get_server_array(
  188.     PVFS_fs_id fs_id,
  189.     PVFS_credentials *credentials,
  190.     int server_type,
  191.     PVFS_BMI_addr_t *addr_array,
  192.     int *inout_count_p)
  193. {
  194.     PVFS_error ret = -PVFS_EINVAL;
  195.  
  196.     ret = PINT_cached_config_get_server_array(
  197.         fs_id, server_type, addr_array, inout_count_p);
  198.     return ret;
  199. }
  200.  
  201. /** Counts the number of servers of a given type present in a file
  202.  *  system.
  203.  *
  204.  *  \param count pointer to address where output count is stored
  205.  *
  206.  *  \return 0 on success, -PVFS_error on failure.
  207.  */
  208. PVFS_error PVFS_mgmt_count_servers(
  209.     PVFS_fs_id fs_id,
  210.     PVFS_credentials *credentials,
  211.     int server_type,
  212.     int *count)
  213. {
  214.     PVFS_error ret = -PVFS_EINVAL;
  215.  
  216.     ret = PINT_cached_config_count_servers(fs_id, server_type, count);
  217.     return ret;
  218. }
  219.  
  220. /*
  221.  * Local variables:
  222.  *  c-indent-level: 4
  223.  *  c-basic-offset: 4
  224.  * End:
  225.  *
  226.  * vim: ts=8 sts=4 sw=4 expandtab
  227.  */
  228.