[PVFS2-CVS] commit by pcarns in pvfs2/src/client/sysint: initialize.c module.mk.in pint-sysint-utils.c pint-sysint-utils.h

CVS commit program cvs at parl.clemson.edu
Thu Mar 11 17:19:21 EST 2004


Update of /projects/cvsroot/pvfs2/src/client/sysint
In directory parlweb:/tmp/cvs-serv5270/src/client/sysint

Modified Files:
	initialize.c module.mk.in pint-sysint-utils.c 
	pint-sysint-utils.h 
Log Message:
added hooks to add file systems _after_ system interface initialization, 
updated apps accordingly, made pvfs2-ping more verbose using the extra info
that we now have access to.  still not very robust.  here are some
(temporary) limitations:
- client must initialize all compiled in flowprotocols and bmi modules from
  the beginning, no hooks to init them as we go
- can't remove file systems that have been added
- probably can't yet add file systems that didn't come from parse_fstab() call


Index: initialize.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/initialize.c,v
diff -p -u -r1.76 -r1.77
--- initialize.c	8 Mar 2004 22:06:36 -0000	1.76
+++ initialize.c	11 Mar 2004 22:19:21 -0000	1.77
@@ -28,8 +28,6 @@ job_context_id PVFS_sys_job_context = -1
 
 extern gen_mutex_t *g_session_tag_mt_lock;
 
-static char* build_flow_module_list(PVFS_util_tab* tab);
-
 /* PVFS_sys_initialize()
  *
  * Initializes the PVFS system interface and any necessary internal data
@@ -40,23 +38,12 @@ static char* build_flow_module_list(PVFS
  * env variable are the same as the EventLogging line in the server
  * configuration file.
  *
- * returns 0 on success, -errno on failure
+ * returns 0 on success, -PVFS_error on failure
  */
-
 int PVFS_sys_initialize(
-    PVFS_util_tab tab,
-    int default_debug_mask,
-    PVFS_sysresp_init *resp)
+    int default_debug_mask)
 {
-    int ret = -1, i, j;
-    int num_file_systems = 0;
-    gen_mutex_t *mt_config = NULL;
-    PINT_llist *cur = NULL;
-    struct filesystem_configuration_s *cur_fs = NULL;
-    const char **method_ptr_list;
-    int num_method_ptr_list, max_method_ptr_list;
-    char *method_list = 0;
-    char *flowproto_list = NULL;
+    int ret = -1;
     char *debug_mask_str = NULL;
     int debug_mask = 0;
     char *debug_file = 0;
@@ -70,8 +57,7 @@ int PVFS_sys_initialize(
 	JOB_CONTEXT_FAIL,
 	ACACHE_INIT_FAIL,
 	NCACHE_INIT_FAIL,
-	BUCKET_INIT_FAIL,
-	GET_CONFIG_INIT_FAIL
+	BUCKET_INIT_FAIL
     } init_fail = NONE_INIT_FAIL;
 
     gossip_enable_stderr();
@@ -86,14 +72,6 @@ int PVFS_sys_initialize(
     if (debug_file)
 	gossip_enable_file(debug_file, "w");
 
-    /* make sure we were given sane arguments */
-    if ((tab.mntent_array == NULL) || (resp == NULL))
-    {
-	ret = -EINVAL;
-	init_fail = NONE_INIT_FAIL;
-	goto return_error;
-    }
-
     /* initialize protocol encoder */
     ret = PINT_encode_initialize();
     if(ret < 0)
@@ -101,87 +79,21 @@ int PVFS_sys_initialize(
 	init_fail = ENCODER_INIT_FAIL;
 	goto return_error;
     }
-
-    /* Parse the method types from the tab */
-    num_method_ptr_list = 0;
-    max_method_ptr_list = 0;
-    method_ptr_list = 0;
-    for (i=0; i<tab.mntent_count; i++) {
-	const char *meth_name = BMI_method_from_scheme(
-	  tab.mntent_array[i].pvfs_config_server);
-	for (j=0; j<num_method_ptr_list; j++) {
-	    if (method_ptr_list[j] == meth_name)
-		break;
-	}
-	if (j == num_method_ptr_list && meth_name) {  /* ignore unknown ones */
-	    if (num_method_ptr_list == max_method_ptr_list) {
-		const char **x = method_ptr_list;
-		max_method_ptr_list += 2;
-		method_ptr_list = malloc(
-		  max_method_ptr_list * sizeof(*method_ptr_list));
-		if (!method_ptr_list) {
-		    init_fail = BMI_INIT_FAIL;
-		    ret = -ENOMEM;
-		    goto return_error;
-		}
-		if (x) {
-		    memcpy(method_ptr_list, x,
-		      num_method_ptr_list * sizeof(*method_ptr_list));
-		    free(x);
-		}
-	    }
-	    method_ptr_list[num_method_ptr_list] = meth_name;
-	    ++num_method_ptr_list;
-	}
-    }
-    if (num_method_ptr_list) {
-	j = num_method_ptr_list;  /* intervening , and ending \0 */
-	for (i=0; i<num_method_ptr_list; i++)
-	    j += strlen(method_ptr_list[i]);
-	method_list = malloc(j * sizeof(char));
-	method_list[0] = 0;
-	for (i=0; i<num_method_ptr_list; i++) {
-	    if (i > 0)
-		strcat(method_list, ",");
-	    strcat(method_list, method_ptr_list[i]);
-	}
-	free(method_ptr_list);
-    }
-
-    if(method_list == NULL)
-    {
-	gossip_err("Error: failed to parse BMI method names from tab file entries.\n");
-	ret = -EINVAL;
-	init_fail = BMI_INIT_FAIL;
-	goto return_error;
-    }
-
-    /* parse flowprotocol list as well */
-    flowproto_list = build_flow_module_list(&tab);
-    if(!flowproto_list)
-    {
-	gossip_err("Error: failed to parse flow protocols from tab file entries.\n");
-	ret = -EINVAL;
-	init_fail = BMI_INIT_FAIL;
-	goto return_error;
-    }
     
     /* Initialize BMI */
-    ret = BMI_initialize(method_list,NULL,0);
+    ret = BMI_initialize(NULL,NULL,0);
     if (ret < 0)
     {
 	init_fail = BMI_INIT_FAIL;
 	gossip_ldebug(GOSSIP_CLIENT_DEBUG,"BMI initialize failure\n");
 	goto return_error;
     }
-    if (method_list)
-	free(method_list);
 
     /* initialize bmi session identifier, TODO: DOCUMENT THIS */
     g_session_tag_mt_lock = gen_mutex_build();
 
     /* Initialize flow */
-    ret = PINT_flow_initialize(flowproto_list, 0);
+    ret = PINT_flow_initialize(NULL, 0);
     if (ret < 0)
     {
 	init_fail = FLOW_INIT_FAIL;
@@ -226,91 +138,19 @@ int PVFS_sys_initialize(
     }	
     PINT_ncache_set_timeout(PINT_NCACHE_TIMEOUT * 1000);
 
-    /* Get configuration parameters from server */
-    ret = PINT_server_get_config(PINT_get_server_config_struct(),
-                                 tab);
-    if (ret < 0)
-    {
-	init_fail = NCACHE_INIT_FAIL;
-	gossip_ldebug(GOSSIP_CLIENT_DEBUG,"Error in getting server "
-                      "config parameters\n");
-	goto return_error;
-    }
-    num_file_systems = PINT_llist_count(
-      PINT_get_server_config_struct()->file_systems);
-    assert(num_file_systems);
-
-    /* Grab the mutex - serialize all writes to server_config */
-    mt_config = gen_mutex_build();
-    if (!mt_config)
-    {
-	init_fail = NCACHE_INIT_FAIL;
-	gossip_ldebug(GOSSIP_CLIENT_DEBUG,
-                      "Failed to initialize mutex\n");
-	goto return_error;
-    }
-
-    gen_mutex_lock(mt_config);	
-
     /* Initialize the configuration management interface */
     ret = PINT_bucket_initialize();
     if (ret < 0)
     {
 	init_fail = BUCKET_INIT_FAIL;
-	gossip_ldebug(GOSSIP_CLIENT_DEBUG,"Error in initializing "
-                      "configuration management interface\n");
-	gen_mutex_unlock(mt_config);
-	goto return_error;
-    }
-
-    /* we need to return the fs_id's to the calling function */
-    resp->nr_fsid = num_file_systems;
-    resp->fsid_list = malloc(num_file_systems * sizeof(PVFS_handle));
-    if (resp->fsid_list == NULL)
-    {
-	init_fail = GET_CONFIG_INIT_FAIL;
-	ret = -ENOMEM;
-	goto return_error;
-    }
-
-    /*
-      iterate over each fs for two reasons:
-      1) load mappings of each fs into the bucket interface
-      2) store fs ids into resp object
-    */
-    i = 0;
-    cur = PINT_config_get_filesystems(PINT_get_server_config_struct());
-    while(cur && (i < num_file_systems))
-    {
-        cur_fs = PINT_llist_head(cur);
-        if (!cur_fs)
-        {
-            break;
-        }
-        assert(cur_fs->coll_id);
-        if (PINT_handle_load_mapping(PINT_get_server_config_struct(), cur_fs))
-        {
-            init_fail = GET_CONFIG_INIT_FAIL;
-            gossip_ldebug(GOSSIP_CLIENT_DEBUG,
-                          "Failed to load fs info into the "
-                          "PINT_handle interface.\n");
-            gen_mutex_unlock(mt_config);
-            goto return_error;
-        }
-        resp->fsid_list[i++] = cur_fs->coll_id;
-        cur = PINT_llist_next(cur);
+	gossip_ldebug(GOSSIP_CLIENT_DEBUG,"Error initializing config management\n");
+	goto return_error;	
     }
 
-    gen_mutex_unlock(mt_config);
-    gen_mutex_destroy(mt_config);
-
-    assert(i == num_file_systems);
     return(0);
 
  return_error:
     switch(init_fail) {
-	case GET_CONFIG_INIT_FAIL:
-	    PINT_bucket_finalize();
 	case BUCKET_INIT_FAIL:
 	    PINT_ncache_finalize();
 	case NCACHE_INIT_FAIL:
@@ -333,86 +173,6 @@ int PVFS_sys_initialize(
 
     return(ret);
 }
-
-/* build_flow_module_list()
- *
- * builds a string specifying a list of flow protocols suitable for use
- * as an argument to PINT_flow_initialize(), based on flow protocols
- * found in tabfile
- *
- * returns pointer to string on success, NULL on failure
- * NOTE: caller must free string returned by this function
- */
-static char* build_flow_module_list(PVFS_util_tab* tab)
-{
-    int i,j;
-    int found = 0;
-    int new_len = 0;
-    /* we always load up at least the default module */
-    char* ret_str = NULL;
-    char* old_ret_str = NULL;
-    char* next_mod = NULL;
-
-    /* iterate through array */
-    for(i=0; i<tab->mntent_count; i++)
-    {
-	switch(tab->mntent_array[i].flowproto)
-	{
-	    case FLOWPROTO_BMI_TROVE:
-		next_mod = "flowproto_bmi_trove";
-		break;
-	    case FLOWPROTO_DUMP_OFFSETS:
-		next_mod = "flowproto_dump_offsets";
-		break;
-	    case FLOWPROTO_BMI_CACHE:
-		next_mod = "flowproto_bmi_cache";
-		break;
-	    case FLOWPROTO_MULTIQUEUE:
-		next_mod = "flowproto_multiqueue";
-		break;
-	}
-
-	/* see if we have already found this module */
-	found = 0;
-	for(j=0; j<i; j++)
-	{
-	    if(tab->mntent_array[i].flowproto == 
-		tab->mntent_array[j].flowproto)
-	    {
-		found = 1;
-		break;
-	    }
-	}
-
-	/* if we don't already have this module in our list, add it in */
-	if(!found)
-	{
-	    old_ret_str = ret_str;
-	    new_len = strlen(next_mod) + 2;
-	    if(old_ret_str)
-		new_len += strlen(old_ret_str);
-	    ret_str = (char*)malloc(new_len);
-	    if(!ret_str)
-	    {
-		if(old_ret_str)
-		    free(old_ret_str);
-		return(NULL);
-	    }
-	    memset(ret_str, 0, new_len);
-	    if(old_ret_str)
-	    {
-		strcpy(ret_str, old_ret_str);
-		strcat(ret_str, ",");
-	    }
-	    strcat(ret_str, next_mod);
-	    if(old_ret_str)
-		free(old_ret_str);
-	}
-    }
-
-    return(ret_str);
-}
-
 
 
 /*

Index: module.mk.in
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/module.mk.in,v
diff -p -u -r1.60 -r1.61
--- module.mk.in	12 Jan 2004 21:01:24 -0000	1.60
+++ module.mk.in	11 Mar 2004 22:19:21 -0000	1.61
@@ -12,7 +12,8 @@ CSRC := \
 	$(DIR)/client-state-machine.c \
 	$(DIR)/shared-state-methods.c \
 	$(DIR)/mgmt-misc.c \
-	$(DIR)/sys-statfs.c
+	$(DIR)/sys-statfs.c \
+	$(DIR)/fs-add.c
 
 SMSRC := \
 	msgpairarray.sm \

Index: pint-sysint-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/pint-sysint-utils.c,v
diff -p -u -r1.21 -r1.22
--- pint-sysint-utils.c	8 Mar 2004 22:06:36 -0000	1.21
+++ pint-sysint-utils.c	11 Mar 2004 22:19:21 -0000	1.22
@@ -79,126 +79,100 @@ int PINT_check_perms(PVFS_object_attr at
 }
 
 int PINT_server_get_config(struct server_configuration_s *config,
-                           PVFS_util_tab tab)
+			    struct PVFS_sys_mntent* mntent_p)
 {
-    int ret = -1, i = 0;
+    int ret = -1;
     PVFS_BMI_addr_t serv_addr;
     struct PVFS_server_req serv_req;
     struct PVFS_server_resp *serv_resp = NULL;
     PVFS_credentials creds;
     struct PINT_decoded_msg decoded;
     void* encoded_resp;
-    struct PVFS_sys_mntent *mntent_p = NULL;
     PVFS_msg_tag_t op_tag = get_next_session_tag();
-    int found_one_good = 0;
     struct filesystem_configuration_s* cur_fs = NULL;
 
-    /*
-      for each entry in the pvfstab, attempt to query the server for
-      getconfig information.  discontinue loop when we have info.
-    */
-    for (i = 0; i < tab.mntent_count; i++)
+    /* obtain the metaserver to send the request */
+    ret = BMI_addr_lookup(&serv_addr, mntent_p->pvfs_config_server);
+    if (ret < 0)
     {
-	mntent_p = &tab.mntent_array[i];
+	gossip_ldebug(GOSSIP_CLIENT_DEBUG,"Failed to resolve BMI "
+		      "address %s\n",mntent_p->pvfs_config_server);
+	return(ret);
+    }
 
-   	/* obtain the metaserver to send the request */
-	ret = BMI_addr_lookup(&serv_addr, mntent_p->pvfs_config_server);
-	if (ret < 0)
-	{
-            gossip_ldebug(GOSSIP_CLIENT_DEBUG,"Failed to resolve BMI "
-                          "address %s\n",mntent_p->pvfs_config_server);
-	    continue;
-	}
-
-        creds.uid = getuid();
-        creds.gid = getgid();
-
-        memset(&serv_req,0,sizeof(struct PVFS_server_req));
-	serv_req.op = PVFS_SERV_GETCONFIG;
-	serv_req.credentials = creds;
-
-	gossip_ldebug(GOSSIP_CLIENT_DEBUG,"asked for fs name = %s\n",
-                      mntent_p->pvfs_fs_name);
-
-	/* send the request and receive an acknowledgment */
-	ret = PINT_send_req(serv_addr, &serv_req, mntent_p->encoding,
-                            &decoded, &encoded_resp, op_tag);
-	if (ret < 0)
-        {
-            gossip_err("Error: failed to send request to initial"
-	    " configuration server;\n");
-	    gossip_err("       please verify that your client configuration"
-	    " is correct \n       and that the server is running.\n");
-	    gossip_err("       (%s)\n", mntent_p->pvfs_config_server);
-	    continue;
-	}
-
-	serv_resp = (struct PVFS_server_resp *)decoded.buffer;
-	if (serv_resp->status != 0)
-	{
-	    PVFS_perror_gossip("Error: getconfig request denied",
-                               serv_resp->status);
-	    continue;
-	}
-
-        if (server_parse_config(config,&(serv_resp->u.getconfig)))
-        {
-            gossip_err("Failed to getconfig from host %s\n",
-                       mntent_p->pvfs_config_server);
-
-            PINT_release_req(serv_addr, &serv_req, mntent_p->encoding,
-                             &decoded, &encoded_resp, op_tag);
-            continue;
-        }
+    creds.uid = getuid();
+    creds.gid = getgid();
 
-	PINT_release_req(serv_addr, &serv_req, mntent_p->encoding,
-                         &decoded, &encoded_resp, op_tag);
-        break;
+    memset(&serv_req,0,sizeof(struct PVFS_server_req));
+    serv_req.op = PVFS_SERV_GETCONFIG;
+    serv_req.credentials = creds;
+
+    gossip_ldebug(GOSSIP_CLIENT_DEBUG,"asked for fs name = %s\n",
+		  mntent_p->pvfs_fs_name);
+
+    /* send the request and receive an acknowledgment */
+    ret = PINT_send_req(serv_addr, &serv_req, mntent_p->encoding,
+			&decoded, &encoded_resp, op_tag);
+    if (ret < 0)
+    {
+	gossip_err("Error: failed to send request to initial"
+	" configuration server;\n");
+	gossip_err("       please verify that your client configuration"
+	" is correct \n       and that the server is running.\n");
+	gossip_err("       (%s)\n", mntent_p->pvfs_config_server);
+	return(ret);
     }
 
-    /* verify that each pvfstab entry is valid according to the server */
-    for (i = 0; i < tab.mntent_count; i++)
+    serv_resp = (struct PVFS_server_resp *)decoded.buffer;
+    if (serv_resp->status != 0)
     {
-	mntent_p = &tab.mntent_array[i];
-
-        /* make sure we have valid information about this fs */
-        cur_fs = PINT_config_find_fs_name(config, mntent_p->pvfs_fs_name);
-        if (!cur_fs)
-        {
-            gossip_err("Warning:\n Cannot retrieve information about "
-                       "pvfstab entry %s\n",
-                       mntent_p->pvfs_config_server);
-
-            /*
-              if the device has no space left on it, we can't save
-              the config file for parsing and get a failure; make
-              a note of that possibility here
-            */
-            gossip_err("\nHINTS: If you're sure that your pvfstab file "
-                       "contains valid information,\n please make sure "
-                       "that you are not out of disk space and that you "
-                       "have\n write permissions in the current "
-                       "directory or in the /tmp directory\n\n");
-            continue;
-        }
-        else
-	{
-	    found_one_good = 1;
-	    mntent_p->fs_id = cur_fs->coll_id;
-	    cur_fs->flowproto = mntent_p->flowproto;
-	    cur_fs->encoding = mntent_p->encoding;
-	}
+	PVFS_perror_gossip("Error: getconfig request denied",
+			   serv_resp->status);
+	PINT_release_req(serv_addr, &serv_req, mntent_p->encoding,
+			 &decoded, &encoded_resp, op_tag);
+	return(serv_resp->status);
     }
 
-    if (found_one_good)
+    if (server_parse_config(config,&(serv_resp->u.getconfig)))
     {
-	return(0); 
+	gossip_err("Failed to getconfig from host %s\n",
+		   mntent_p->pvfs_config_server);
+
+	PINT_release_req(serv_addr, &serv_req, mntent_p->encoding,
+			 &decoded, &encoded_resp, op_tag);
+	return(-PVFS_ENODEV);
     }
-    else
+
+    PINT_release_req(serv_addr, &serv_req, mntent_p->encoding,
+		     &decoded, &encoded_resp, op_tag);
+
+    /* make sure we have valid information about this fs */
+    cur_fs = PINT_config_find_fs_name(config, mntent_p->pvfs_fs_name);
+    if (!cur_fs)
     {
-	gossip_err("Error: no valid pvfs2tab entries found.\n");
+	gossip_err("Warning:\n Cannot retrieve information about "
+		   "pvfstab entry %s\n",
+		   mntent_p->pvfs_config_server);
+
+	/*
+	  if the device has no space left on it, we can't save
+	  the config file for parsing and get a failure; make
+	  a note of that possibility here
+	*/
+	gossip_err("\nHINTS: If you're sure that your pvfstab file "
+		   "contains valid information,\n please make sure "
+		   "that you are not out of disk space and that you "
+		   "have\n write permissions in the current "
+		   "directory or in the /tmp directory\n\n");
+	
 	return(-PVFS_ENODEV);
     }
+
+    mntent_p->fs_id = cur_fs->coll_id;
+    cur_fs->flowproto = mntent_p->flowproto;
+    cur_fs->encoding = mntent_p->encoding;
+
+    return(0); 
 }
 
 static int server_parse_config(struct server_configuration_s *config,

Index: pint-sysint-utils.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/pint-sysint-utils.h,v
diff -p -u -r1.13 -r1.14
--- pint-sysint-utils.h	9 Mar 2004 04:19:01 -0000	1.13
+++ pint-sysint-utils.h	11 Mar 2004 22:19:21 -0000	1.14
@@ -23,6 +23,7 @@
 #include "pvfs2-sysint.h"
 #include "gen-locks.h"
 #include "pint-bucket.h"
+#include "pvfs2-sysint.h"
 
 #include "dotconf.h"
 #include "trove.h"
@@ -77,7 +78,7 @@ int PINT_do_lookup (
     PVFS_pinode_reference *entry);
 int PINT_server_get_config(
     struct server_configuration_s *config,
-    PVFS_util_tab tab);
+    struct PVFS_sys_mntent* mntent);
 void PINT_release_pvfstab(void);
 
 struct server_configuration_s *PINT_get_server_config_struct(void);



More information about the PVFS2-CVS mailing list