"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "pvfs-2.7.1/src/client/sysint/sys-del-eattr.c" of archive pvfs-2.7.1.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 /* WARNING: THIS FILE IS AUTOMATICALLY GENERATED FROM A .SM FILE.
    2  * Changes made here will certainly be overwritten.
    3  */
    4 
    5 /*
    6  * (C) 2003 Clemson University and The University of Chicago
    7  *
    8  * See COPYING in top-level directory.
    9  */
   10 
   11 #include <string.h>
   12 #include <assert.h>
   13 #include <unistd.h>
   14 
   15 #include "client-state-machine.h"
   16 #include "pvfs2-debug.h"
   17 #include "pvfs2-util.h"
   18 #include "job.h"
   19 #include "gossip.h"
   20 #include "str-utils.h"
   21 #include "pint-cached-config.h"
   22 #include "PINT-reqproto-encode.h"
   23 
   24 extern job_context_id pint_client_sm_context;
   25 
   26 static int del_eattr_comp_fn(
   27     void *v_p,
   28     struct PVFS_server_resp *resp_p,
   29     int i);
   30 
   31 
   32 static PINT_sm_action del_eattr_setup_msgpair(
   33 	struct PINT_smcb *smcb, job_status_s *js_p);
   34 
   35 static struct PINT_state_s ST_setup_msgpair;
   36 static struct PINT_pjmp_tbl_s ST_setup_msgpair_pjtbl[];
   37 static struct PINT_tran_tbl_s ST_setup_msgpair_trtbl[];
   38 static struct PINT_state_s ST_xfer_msgpair;
   39 static struct PINT_pjmp_tbl_s ST_xfer_msgpair_pjtbl[];
   40 static struct PINT_tran_tbl_s ST_xfer_msgpair_trtbl[];
   41 
   42 static PINT_sm_action del_eattr_cleanup(
   43 	struct PINT_smcb *smcb, job_status_s *js_p);
   44 
   45 static struct PINT_state_s ST_cleanup;
   46 static struct PINT_pjmp_tbl_s ST_cleanup_pjtbl[];
   47 static struct PINT_tran_tbl_s ST_cleanup_trtbl[];
   48 
   49 struct PINT_state_machine_s pvfs2_client_del_eattr_sm = {
   50 	.name = "pvfs2_client_del_eattr_sm",
   51 	.first_state = &ST_setup_msgpair
   52 };
   53 
   54 static struct PINT_state_s ST_setup_msgpair = {
   55 	 .state_name = "setup_msgpair" ,
   56 	 .parent_machine = &pvfs2_client_del_eattr_sm ,
   57 	 .flag = SM_RUN ,
   58 	 .action.func = del_eattr_setup_msgpair ,
   59 	 .pjtbl = NULL ,
   60 	 .trtbl = ST_setup_msgpair_trtbl
   61 };
   62 
   63 static struct PINT_tran_tbl_s ST_setup_msgpair_trtbl[] = {
   64 	{ .return_value = 0 ,
   65 	 .next_state = &ST_xfer_msgpair },
   66 	{ .return_value = -1 ,
   67 	 .next_state = &ST_cleanup }
   68 };
   69 
   70 static struct PINT_state_s ST_xfer_msgpair = {
   71 	 .state_name = "xfer_msgpair" ,
   72 	 .parent_machine = &pvfs2_client_del_eattr_sm ,
   73 	 .flag = SM_JUMP ,
   74 	 .action.nested = &pvfs2_msgpairarray_sm ,
   75 	 .pjtbl = NULL ,
   76 	 .trtbl = ST_xfer_msgpair_trtbl
   77 };
   78 
   79 static struct PINT_tran_tbl_s ST_xfer_msgpair_trtbl[] = {
   80 	{ .return_value = -1 ,
   81 	 .next_state = &ST_cleanup }
   82 };
   83 
   84 static struct PINT_state_s ST_cleanup = {
   85 	 .state_name = "cleanup" ,
   86 	 .parent_machine = &pvfs2_client_del_eattr_sm ,
   87 	 .flag = SM_RUN ,
   88 	 .action.func = del_eattr_cleanup ,
   89 	 .pjtbl = NULL ,
   90 	 .trtbl = ST_cleanup_trtbl
   91 };
   92 
   93 static struct PINT_tran_tbl_s ST_cleanup_trtbl[] = {
   94 	{ .return_value = -1 ,
   95 
   96 	 .flag = SM_TERM }
   97 };
   98 
   99 # 51 "src/client/sysint/sys-del-eattr.sm"
  100 
  101 
  102 PVFS_error PVFS_isys_deleattr(
  103         PVFS_object_ref ref,
  104         const PVFS_credentials *credentials,
  105         PVFS_ds_keyval *key_p,
  106         PVFS_sys_op_id *op_id,
  107         void *user_ptr)
  108 {
  109     int ret = -PVFS_EINVAL;
  110     PINT_smcb *smcb = NULL;
  111     PINT_client_sm *sm_p = NULL;
  112 
  113     gossip_debug(GOSSIP_CLIENT_DEBUG, "PINT_isys_del_eattr entered\n");
  114 
  115     if ((ref.handle == PVFS_HANDLE_NULL) ||
  116        (ref.fs_id == PVFS_FS_ID_NULL))
  117     {
  118         gossip_err("invalid (NULL) required argument\n");
  119 	return ret;
  120     }
  121 
  122     PINT_smcb_alloc(&smcb, PVFS_SYS_DELEATTR,
  123              sizeof(struct PINT_client_sm),
  124              client_op_state_get_machine,
  125              client_state_machine_terminate,
  126              pint_client_sm_context);
  127     if (smcb == NULL)
  128     {
  129         return -PVFS_ENOMEM;
  130     }
  131     sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  132 
  133     PINT_init_msgarray_params(&sm_p->msgarray_params, ref.fs_id);
  134     PINT_init_sysint_credentials(sm_p->cred_p, credentials);
  135     sm_p->u.deleattr.key_p = key_p;
  136     sm_p->error_code = 0;
  137     sm_p->object_ref = ref;
  138 
  139     return PINT_client_state_machine_post(
  140             smcb,  op_id, user_ptr);
  141 }
  142 
  143 PVFS_error PVFS_sys_deleattr(
  144         PVFS_object_ref ref,
  145         const PVFS_credentials *credentials,
  146         PVFS_ds_keyval *key_p)
  147 {
  148     PVFS_error ret = -PVFS_EINVAL, error = 0;
  149     PVFS_sys_op_id op_id;
  150 
  151     gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_sys_deleattr entered\n");
  152 
  153     ret = PVFS_isys_deleattr(ref, credentials,
  154             key_p, &op_id, NULL);
  155 
  156     if (ret)
  157     {
  158         PVFS_perror_gossip("PVFS_isys_deleattr call", ret);
  159         error = ret;
  160     }
  161     else
  162     {
  163         ret = PVFS_sys_wait(op_id, "deleattr", &error);
  164         if (ret)
  165         {
  166              PVFS_perror_gossip("PVFS_sys_wait call", ret);
  167              error = ret;
  168         }
  169     }
  170 
  171     PINT_sys_release(op_id);
  172     return error;
  173 }
  174 
  175 static PINT_sm_action del_eattr_setup_msgpair(
  176         struct PINT_smcb *smcb, job_status_s *js_p)
  177 {
  178     struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  179     int ret = -PVFS_EINVAL;
  180 
  181     gossip_debug(GOSSIP_CLIENT_DEBUG,
  182 		"del_eattr state: del_eattr_setup_msgpair\n");
  183 
  184     PINT_SERVREQ_DELEATTR_FILL(
  185             sm_p->msgpair.req,
  186             (*sm_p->cred_p),
  187             sm_p->object_ref.fs_id,
  188             sm_p->object_ref.handle,
  189             (*sm_p->u.deleattr.key_p)
  190             );
  191 
  192     sm_p->msgarray = &(sm_p->msgpair);
  193     sm_p->msgarray_count = 1;
  194     sm_p->msgpair.fs_id = sm_p->object_ref.fs_id;
  195     sm_p->msgpair.handle = sm_p->object_ref.handle;
  196     sm_p->msgpair.retry_flag = PVFS_MSGPAIR_RETRY;
  197     sm_p->msgpair.comp_fn = del_eattr_comp_fn;
  198 
  199     ret = PINT_cached_config_map_to_server(
  200             &sm_p->msgpair.svr_addr,
  201             sm_p->msgpair.handle,
  202             sm_p->msgpair.fs_id);
  203 
  204     if (ret)
  205     {
  206         gossip_err("Failed to map meta server address\n");
  207         js_p->error_code = 0;
  208     }
  209     return SM_ACTION_COMPLETE;
  210 }
  211 
  212 static PINT_sm_action del_eattr_cleanup(
  213         struct PINT_smcb *smcb, job_status_s *js_p)
  214 {
  215     struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  216     gossip_debug(GOSSIP_CLIENT_DEBUG,
  217 		"del_eattr state: del_eattr_cleanup\n");
  218     sm_p->error_code  = js_p->error_code;
  219 
  220     PINT_SET_OP_COMPLETE;
  221     return SM_ACTION_TERMINATE;
  222 }
  223 
  224 static int del_eattr_comp_fn(
  225     void *v_p,
  226     struct PVFS_server_resp *resp_p,
  227     int i)
  228 {
  229     int j = 0;
  230     int ret = 0;
  231     PINT_smcb *smcb = v_p;
  232     PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  233 
  234     gossip_debug(GOSSIP_CLIENT_DEBUG,
  235 		"del_eattr completion fn: del_eattr_comp_fn\n");
  236 
  237     /* only posted one msgpair */
  238     assert(i==0);
  239 
  240     /* no return value from del eattrib so just check status */
  241 
  242     if (sm_p->msgarray[i].op_status != 0)
  243     {
  244         ret = sm_p->msgarray[i].op_status;
  245     }
  246 
  247     /* if this is the last response, check all of the status values
  248      * and return error code if any requests failed
  249      */
  250     if (i == (sm_p->msgarray_count -1))
  251     {
  252 	for (j=0; j < sm_p->msgarray_count; j++)
  253 	{
  254 	    if (sm_p->msgarray[j].op_status != 0)
  255 	    {
  256 		return(sm_p->msgarray[j].op_status);
  257 	    }
  258 	}
  259     }
  260     return ret;
  261 }
  262 
  263 /*
  264  * Local variables:
  265  *  mode: c
  266  *  c-indent-level: 4
  267  *  c-basic-offset: 4
  268  * End:
  269  *
  270  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  271  */