| 1 | /* |
|---|
| 2 | * (C) 2003 Clemson University and The University of Chicago |
|---|
| 3 | * |
|---|
| 4 | * See COPYING in top-level directory. |
|---|
| 5 | */ |
|---|
| 6 | |
|---|
| 7 | #include <string.h> |
|---|
| 8 | #include <assert.h> |
|---|
| 9 | #include <unistd.h> |
|---|
| 10 | |
|---|
| 11 | #include "client-state-machine.h" |
|---|
| 12 | #include "pvfs2-debug.h" |
|---|
| 13 | #include "pvfs2-util.h" |
|---|
| 14 | #include "job.h" |
|---|
| 15 | #include "gossip.h" |
|---|
| 16 | #include "str-utils.h" |
|---|
| 17 | #include "pint-cached-config.h" |
|---|
| 18 | #include "PINT-reqproto-encode.h" |
|---|
| 19 | #include "pvfs2-internal.h" |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | extern job_context_id pint_client_sm_context; |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | %% |
|---|
| 26 | |
|---|
| 27 | machine pvfs2_client_mgmt_migrate_sm{ |
|---|
| 28 | |
|---|
| 29 | state init{ |
|---|
| 30 | run mgmt_migrate_init; |
|---|
| 31 | default => migrate_setup_msgpair; |
|---|
| 32 | } |
|---|
| 33 | state cleanup{ |
|---|
| 34 | run mgmt_migrate_cleanup; |
|---|
| 35 | default => terminate; |
|---|
| 36 | } |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | %% |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | PVFS_error PVFS_imgmt_migrate( |
|---|
| 43 | PVFS_object_ref ref, |
|---|
| 44 | const PVFS_credentials *credentials, |
|---|
| 45 | PVFS_sys_op_id *op_id, |
|---|
| 46 | PVFS_hint hints, |
|---|
| 47 | void *user_ptr) |
|---|
| 48 | { |
|---|
| 49 | int ret = -PVFS_EINVAL; |
|---|
| 50 | PINT_smcb *smcb = NULL; |
|---|
| 51 | PINT_client_sm *sm_p = NULL; |
|---|
| 52 | |
|---|
| 53 | PINT_smcb_alloc(&smcb, PVFS_MGMT_MIGRATE, |
|---|
| 54 | sizeof(struct PINT_client_sm), |
|---|
| 55 | client_op_state_get_machine, |
|---|
| 56 | client_state_machine_terminate, |
|---|
| 57 | pint_client_sm_context); |
|---|
| 58 | if(smcb == NULL){ |
|---|
| 59 | return -PVFS_ENOMEM; |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | sm_p = PINT_sm_frame(smcb, PINT_CURRENT_FRAME); |
|---|
| 64 | PINT_init_msgarray_params(sm_p, ref.fs_id); |
|---|
| 65 | PINT_init_sysint_credentials(sm->cred_p, credentials); |
|---|
| 66 | /* fill in stuff in the union */ |
|---|
| 67 | sm_p->error_code = 0; |
|---|
| 68 | sm_p->object_ref = ref; |
|---|
| 69 | PVFS_hint_copy(hints, &sm_p->hints); |
|---|
| 70 | |
|---|
| 71 | return PINT_client_state_machine_post( |
|---|
| 72 | smcb, op_id, user_ptr); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | PVFS_error PVFS_mgmt_migrate( |
|---|
| 77 | PVFS_object_ref ref, |
|---|
| 78 | const PVFS_credentials *credentials, |
|---|
| 79 | PVFS_hint hints) |
|---|
| 80 | { |
|---|
| 81 | PVFS_error ret = -PVFS_EINVAL, error = 0; |
|---|
| 82 | PVFS_sys_op_id op_id; |
|---|
| 83 | |
|---|
| 84 | gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_migrate entered\n"); |
|---|
| 85 | |
|---|
| 86 | ret = PVFS_imgmt_migrate(credentials, &op_id, hints) |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | PINT_sys_release(op_id); |
|---|
| 93 | return error; |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | static PINT_sm_action mgmt_migrate_init( |
|---|
| 98 | struct PINT_smcb *smcb, job_status_s js_p) |
|---|
| 99 | { |
|---|
| 100 | gossip_debug(GOSSIP_CLIENT_DEBUG, "mgmt_migrate_init called\n"); |
|---|
| 101 | assert(js_p->error_code == 0); |
|---|
| 102 | return SM_ACTION_COMPLETE; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | |
|---|