[Pvfs2-cvs] commit by bligon in pvfs2/src/server: get-attr.sm pvfs2-server.h set-eattr.sm

CVS commit program cvs at parl.clemson.edu
Fri Jul 10 17:16:26 EDT 2009


Update of /projects/cvsroot/pvfs2/src/server
In directory parlweb1:/tmp/cvs-serv30788/src/server

Modified Files:
      Tag: Orange-FailOver-Becky
	get-attr.sm pvfs2-server.h set-eattr.sm 
Log Message:
Completed changes to PVFS_object_attr.  Changes to get-attr.sm are still underday


Index: get-attr.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/server/get-attr.sm,v
diff -p -u -r1.97 -r1.97.18.1
--- get-attr.sm	26 Feb 2009 05:38:18 -0000	1.97
+++ get-attr.sm	10 Jul 2009 21:16:25 -0000	1.97.18.1
@@ -32,10 +32,13 @@
 
 PINT_server_trove_keys_s Trove_Special_Keys[] =
 {
-    {"user.pvfs2.dist_name"  , SPECIAL_DIST_NAME_KEYLEN},
-    {"user.pvfs2.dist_params", SPECIAL_DIST_PARAMS_KEYLEN},
-    {"user.pvfs2.num_dfiles" , SPECIAL_NUM_DFILES_KEYLEN},
-    {"user.pvfs2.meta_hint"  , SPECIAL_METAFILE_HINT_KEYLEN},
+    {"user.pvfs2.dist_name"    , SPECIAL_DIST_NAME_KEYLEN},
+    {"user.pvfs2.dist_params"  , SPECIAL_DIST_PARAMS_KEYLEN},
+    {"user.pvfs2.num_dfiles"   , SPECIAL_NUM_DFILES_KEYLEN},
+    {"user.pvfs2.meta_hint"    , SPECIAL_METAFILE_HINT_KEYLEN},
+    {"user.pvfs2.mirror.copies", SPECIAL_MIRROR_COPIES_KEYLEN},
+    {"user.pvfs2.mirror.handles", SPECIAL_MIRROR_HANDLES_KEYLEN},
+    {"user.pvfs2.mirror.status" , SPECIAL_MIRROR_STATUS_KEYLEN},
 };
 
 enum
@@ -91,10 +94,31 @@ nested machine pvfs2_get_attr_work_sm
     state datafile_handles_safety_check
     {
         run getattr_datafile_handles_safety_check;
-        success => read_metafile_distribution_if_required; 
+        success => read_mirrored_copies_count_if_required; 
+        default => setup_resp;
+    }
+
+    state read_mirrored_copies_count_if_required
+    {
+        run getattr_read_mirrored_copies_count_if_required;
+        success => read_mirrored_handles_if_required;
+        default => setup_resp;
+    }
+
+    state read_mirrored_handles_if_required
+    {
+        run getattr_read_mirrored_handles_if_required;
+        success => mirrored_handles_safety_check;
         default => setup_resp;
     }
  
+    state mirrored_handles_safety_check
+    {
+        run getattr_mirrored_handles_safety_check;
+        success => read_metafile_distribution_if_required;
+        default => setup_resp;
+    }
+
     state read_metafile_distribution_if_required
     {
         run getattr_read_metafile_distribution_if_required;
@@ -496,7 +520,7 @@ static PINT_sm_action getattr_interpret_
         s_op->resp.u.getattr.attr.mask &= ~PVFS_ATTR_META_DIST;
         s_op->resp.u.getattr.attr.mask &= ~PVFS_ATTR_META_DFILES;
     }
-    return 1;
+    return SM_ACTION_COMPLETE;
 }
 
 static PINT_sm_action getattr_read_metafile_hint(
@@ -640,15 +664,284 @@ static PINT_sm_action getattr_read_metaf
 		 s_op->val.buffer_sz);
 
     ret = job_trove_keyval_read(
-        s_op->u.getattr.fs_id, s_op->u.getattr.handle,
-        &s_op->key, &s_op->val,
-        0,
-        NULL, smcb, 0, js_p,
-        &i, server_job_context, s_op->req->hints);
+        s_op->u.getattr.fs_id
+       ,s_op->u.getattr.handle
+       ,&s_op->key
+       ,&s_op->val
+       ,0
+       ,NULL
+       ,smcb
+       ,0
+       ,js_p
+       ,&i
+       ,server_job_context
+       ,s_op->req->hints);
 
     return ret;
 }
 
+
+static PINT_sm_action getattr_read_mirrored_copies_count_if_required(
+        struct PINT_smcb *smcb, job_status_s *js_p)
+{
+    gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing %s...\n",__func__);
+
+    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+    struct PVFS_server_resp *resp = &(s_op->resp);
+    PVFS_metafile_attr *meta =  &(resp->u.getattr.attr.u.meta);
+    PVFS_metafile_hint *hint = &(meta->hint);
+    int ret = -PVFS_EINVAL;
+    job_id_t job_id;
+
+
+    js_p->error_code = 0;
+
+    /* if mirroring is not turned on, then skip this step */
+    if (!(hint->flags & PVFS_MIRROR_FL))
+    {
+        gossip_debug(GOSSIP_MIRROR_DEBUG,"\tMirroring is NOT turned on "
+                                         "for this handle(%llu)..\n"
+                                        ,llu(s_op->u.getattr.handle));
+        return SM_ACTION_COMPLETE;
+    }
+
+
+    /* setup job to read user.pvfs2.mirror.copies */
+
+    /* initialize */
+    if (s_op->free_val)
+       free(s_op->val.buffer);
+    memset(&(s_op->val),0,sizeof(s_op->val));
+    memset(&(s_op->key),0,sizeof(s_op->key));
+
+    /* set key = user.pvfs2.mirror.copies */
+    s_op->key.buffer    = Trove_Common_Keys[MIRROR_COPIES_KEY].key;
+    s_op->key.buffer_sz = Trove_Common_Keys[MIRROR_COPIES_KEY].size;
+
+    /* setup space for retrieved value */
+    s_op->val.buffer = &(meta->mirror_copies_count);
+    s_op->val.buffer_sz = sizeof(meta->mirror_copies_count);
+    s_op->free_val = 0;
+
+    /* submit job to read the value */
+    ret = job_trove_keyval_read(
+        s_op->u.getattr.fs_id
+       ,s_op->u.getattr.handle
+       ,&s_op->key
+       ,&s_op->val
+       ,0
+       ,NULL
+       ,smcb
+       ,0
+       ,js_p
+       ,&job_id
+       ,server_job_context
+       ,s_op->req->hints);
+
+    return ret;
+}/*end getattr_read_mirrored_copies_if_required*/
+
+
+
+static PINT_sm_action getattr_read_mirrored_handles_if_required(
+        struct PINT_smcb *smcb, job_status_s *js_p)
+{
+   gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing %s ...\n",__func__);
+
+    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+    struct PVFS_server_resp *resp = &(s_op->resp);
+    PVFS_metafile_attr *meta =  &(resp->u.getattr.attr.u.meta);
+    PVFS_metafile_hint *hint = &(meta->hint);
+    int ret = -PVFS_EINVAL;
+    job_id_t job_id;
+    int i;
+
+   /* Are we mirroring? */
+    if (!(hint->flags & PVFS_MIRROR_FL))
+    {
+        gossip_debug(GOSSIP_MIRROR_DEBUG,"\tMirroring is NOT turned on "
+                                         "for this handle(%llu)..\n"
+                                        ,llu(s_op->u.getattr.handle));
+        return SM_ACTION_COMPLETE;
+    }
+
+   /* check number of mirrored copies */
+    if (meta->mirror_copies_count == 0)
+    {
+       gossip_debug(GOSSIP_MIRROR_DEBUG,"\tNumber of mirrored copies "
+                                        "is ZERO.\n");
+       gossip_lerr("Mirror handles requested, but number of mirrored copies "
+                   "is zero.\n");
+       js_p->error_code = -PVFS_EINVAL;
+       return SM_ACTION_COMPLETE;
+    }
+
+   /* check to see if total number of mirrored handle is sane */
+   if ( (meta->dfile_count * meta->mirror_copies_count) >
+         PVFS_REQ_LIMIT_MIRROR_DFILE_COUNT )
+   {
+       gossip_lerr("Number of mirrored handles(%d) exceeds a system "
+                   "limit(%d)\n"
+                  ,meta->dfile_count * meta->mirror_copies_count
+                  ,PVFS_REQ_LIMIT_MIRROR_DFILE_COUNT); 
+       js_p->error_code = -PVFS_EOVERFLOW;
+       return SM_ACTION_COMPLETE;
+   }
+
+   /* get mirrored handles and status of each handle */
+
+   /* initialize */
+   if (s_op->free_val)
+      free(s_op->val.buffer);
+   memset(&(s_op->key),0,sizeof(s_op->key));
+   memset(&(s_op->val),0,sizeof(s_op->val));
+
+   for (i=0; i<s_op->keyval_count; i++)
+       if (s_op->val_a && s_op->val_a[i].buffer && s_op->free_val)
+           free(s_op->val_a[i].buffer);
+   if (s_op->val_a)
+       free(s_op->val_a);
+   if (s_op->key_a)
+       free(s_op->key_a);
+   if (s_op->error_a)
+      free(s_op->error_a);
+   s_op->free_val = 0;
+
+   /* allocate space for keys and values */
+   s_op->keyval_count = 2;
+   
+   s_op->key_a   = malloc(sizeof(*s_op->key_a)   * s_op->keyval_count);
+   s_op->val_a   = malloc(sizeof(*s_op->val_a)   * s_op->keyval_count);
+   s_op->error_a = malloc(sizeof(*s_op->error_a) * s_op->keyval_count);
+   if (!s_op->key_a || !s_op->val_a || !s_op->error_a)
+   {
+      gossip_lerr("Cannot allocate memory for key/val pair with error.\n");
+      js_p->error_code = -PVFS_ENOMEM;
+      goto error_exit;
+   }
+   memset(s_op->key_a,0,sizeof(*s_op->key_a));
+   memset(s_op->val_a,0,sizeof(*s_op->val_a));
+
+   /* set key = user.pvfs2.mirror.handles */
+   s_op->key_a[0].buffer    = Trove_Special_Keys[MIRROR_HANDLES_KEY].key;
+   s_op->key_a[0].buffer_sz = Trove_Special_Keys[MIRROR_HANDLES_KEY].size;
+
+   /* setup buffer space for handles */
+   s_op->val_a[0].buffer = malloc(sizeof(PVFS_handle) * 
+                                  meta->dfile_count   *
+                                  meta->mirror_copies_count);
+   if (!s_op->val_a[0].buffer)
+   {
+      gossip_lerr("Cannot allocate memory for mirrored handles.\n");
+      js_p->error_code = -PVFS_ENOMEM;
+      goto error_exit;
+   }
+   memset(s_op->val_a[0].buffer,0,sizeof(PVFS_handle) *
+                                  meta->dfile_count   *
+                                  meta->mirror_copies_count);
+   s_op->val_a[0].buffer_sz = sizeof(PVFS_handle) *
+                              meta->dfile_count   *
+                              meta->mirror_copies_count;
+   meta->mirror_dfile_array = s_op->val_a[0].buffer;
+
+   /* set key = user.pvfs2.mirror.status */
+   s_op->key_a[1].buffer    = Trove_Special_Keys[MIRROR_STATUS_KEY].key;
+   s_op->key_a[1].buffer_sz = Trove_Special_Keys[MIRROR_STATUS_KEY].size;
+
+   /* setup buffer space for handle statuses */
+   s_op->val_a[1].buffer = malloc(sizeof(PVFS_handle) *
+                                  meta->dfile_count   *
+                                  meta->mirror_copies_count);
+   if (!s_op->val_a[1].buffer)
+   {
+       gossip_lerr("Cannot allocate memory for mirrored handle statuses.\n");
+       js_p->error_code = -PVFS_ENOMEM;
+       goto error_exit;
+   }
+   memset(s_op->val_a[1].buffer,0,sizeof(PVFS_handle) *
+                                  meta->dfile_count   *
+                                  meta->mirror_copies_count);
+   s_op->val_a[1].buffer_sz = sizeof(PVFS_handle) *
+                              meta->dfile_count   *
+                              meta->mirror_copies_count;
+   s_op->u.getattr.mirror_dfile_status_array = s_op->val_a[1].buffer;
+
+   s_op->free_val = 0;
+
+   
+   /* call job to retrieve the key/val pairs */
+   ret = job_trove_keyval_read_list(
+          s_op->u.getattr.fs_id
+         ,s_op->u.getattr.handle
+         ,s_op->key_a
+         ,s_op->val_a
+         ,s_op->error_a
+         ,s_op->keyval_count
+         ,0
+         ,NULL
+         ,smcb
+         ,0
+         ,js_p
+         ,&job_id
+         ,server_job_context
+         ,s_op->req->hints );
+
+   return ret;
+
+error_exit:
+   for (i=0; i<s_op->keyval_count; i++)
+   {
+       if (s_op->val_a && s_op->val_a[i].buffer)
+          free(s_op->val_a[i].buffer);
+   }
+   if (s_op->val_a)
+       free(s_op->val_a);
+   if (s_op->key_a)
+       free(s_op->key_a);
+   if (s_op->error_a)
+       free(s_op->error_a);
+   s_op->val_a = s_op->key_a = NULL;
+   s_op->error_a = NULL;
+   s_op->keyval_count = 0;
+   s_op->free_val = 0;
+
+   return SM_ACTION_COMPLETE;
+}/*end getattr_read_mirrored_handles_if_required*/
+
+
+
+
+static PINT_sm_action getattr_mirrored_handles_safety_check(
+        struct PINT_smcb *smcb, job_status_s *js_p)
+{
+   gossip_debug(GOSSIP_MIRROR_DEBUG,"Executing %s ...\n",__func__);
+
+    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+    struct PVFS_server_resp *resp = &(s_op->resp);
+    PVFS_metafile_attr *meta =  &(resp->u.getattr.attr.u.meta);
+    PVFS_metafile_hint *hint = &(meta->hint);
+    int ret = -PVFS_EINVAL;
+    job_id_t job_id;
+    int i;
+
+   /* Are we mirroring? */
+    if (!(hint->flags & PVFS_MIRROR_FL))
+    {
+        gossip_debug(GOSSIP_MIRROR_DEBUG,"\tMirroring is NOT turned on "
+                                         "for this handle(%llu)..\n"
+                                        ,llu(s_op->u.getattr.handle));
+        return SM_ACTION_COMPLETE;
+    }
+
+   /* Did we get the data that we were expecting? */
+
+
+   return SM_ACTION_COMPLETE;
+}/*end getattr_mirrored_handles_safety_check*/
+
+
+
+
 static PINT_sm_action getattr_read_metafile_distribution_if_required(
         struct PINT_smcb *smcb, job_status_s *js_p)
 {
@@ -1002,7 +1295,8 @@ static PINT_sm_action getattr_datafile_h
         /* successfully read datafile key; make sure we got something valid */
         if(s_op->val.read_sz != s_op->val.buffer_sz)
         {
-            gossip_err("Error: %s key found val size: %d when expecting val size: %d\n",
+            gossip_err("Error: %s key found val size: %d when "
+                       "expecting val size: %d\n",
                 Trove_Common_Keys[METAFILE_HANDLES_KEY].key,
                 s_op->val.read_sz,
                 s_op->val.buffer_sz);

Index: pvfs2-server.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/server/pvfs2-server.h,v
diff -p -u -r1.155.10.2 -r1.155.10.2.2.1
--- pvfs2-server.h	25 Jun 2009 16:56:03 -0000	1.155.10.2
+++ pvfs2-server.h	10 Jul 2009 21:16:26 -0000	1.155.10.2.2.1
@@ -178,8 +178,11 @@ enum 
     DIST_NAME_KEY        = 0,
     DIST_PARAMS_KEY      = 1,
     NUM_DFILES_KEY       = 2,
-    NUM_SPECIAL_KEYS     = 3, /* not an index */
     METAFILE_HINT_KEY    = 3,
+    MIRROR_COPIES_KEY    = 4,
+    MIRROR_HANDLES_KEY   = 5,
+    MIRROR_STATUS_KEY    = 6,
+    NUM_SPECIAL_KEYS     = 6, /* not an index */
 };
 
 typedef enum
@@ -528,6 +531,7 @@ struct PINT_server_getattr_op
     PVFS_ds_keyval_handle_info keyval_handle_info;
     PVFS_handle dirent_handle;
     int num_dfiles_req;
+    PVFS_handle *mirror_dfile_status_array;
 };
 
 struct PINT_server_listattr_op

Index: set-eattr.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/server/set-eattr.sm,v
diff -p -u -r1.21.10.2.2.1 -r1.21.10.2.2.2
--- set-eattr.sm	3 Jul 2009 21:20:53 -0000	1.21.10.2.2.1
+++ set-eattr.sm	10 Jul 2009 21:16:26 -0000	1.21.10.2.2.2
@@ -54,8 +54,8 @@ machine pvfs2_set_eattr_sm
     state check_mirror_mode
     {
         run seteattr_get_metahint_flag;
-        success     => update_flag;
         SKIP_UPDATE => check_immutable;
+        success     => update_flag;
         default     => final_response;
     }
 
@@ -290,8 +290,8 @@ error_exit:
 }/*end seteattr_get_metahint_flag*/
 
 
-/*This function updates the meta-hint flag, when the mirroring mode has 
- *changed.
+/*This function updates the meta-hint flag, whenever the mirroring mode  
+ *changes.
 */
 static PINT_sm_action seteattr_set_metahint_flag(struct PINT_smcb *smcb
                                                 ,job_status_s *js_p)
@@ -475,11 +475,13 @@ static PINT_sm_action inspect_imm_copies
 
     if (js_p->error_code)
     {
-       gossip_err("File NOT mirrored successfully(%d)\n",js_p->error_code);
+       gossip_debug(GOSSIP_MIRROR_DEBUG,"File NOT mirrored "
+                                        "successfully(%d)\n"
+                                       ,js_p->error_code);
     }
     else
     {
-       gossip_err("File successfully mirrored.\n");
+       gossip_debug(GOSSIP_MIRROR_DEBUG,"File successfully mirrored.\n");
     }
 
     /*free memory from popped stack frame*/
@@ -577,6 +579,7 @@ static int seteattr_cleanup(
 
     /*free key/val structs from the s_op*/
     init_keyval_structs(s_op,s_op->free_val);
+
 
     return(server_state_machine_complete(smcb));
 }



More information about the Pvfs2-cvs mailing list