| 1 | |
|---|
| 2 | |
|---|
| 3 | Steps in adding a request to the server: |
|---|
| 4 | |
|---|
| 5 | 1) select a request name and number |
|---|
| 6 | src/proto/pvfs2-req-proto.h |
|---|
| 7 | |
|---|
| 8 | 2) add a request and response struct |
|---|
| 9 | src/proto/pvfs2-req-proto.h |
|---|
| 10 | add entry to unions: PVFS_server_req and PVFS_server_resp |
|---|
| 11 | |
|---|
| 12 | 2a) add endecode functions if needed |
|---|
| 13 | src/proto/endecode-funcs.h |
|---|
| 14 | for each of these you add or modify you must also |
|---|
| 15 | add a stub in include/pvfs2-encode-stubs.h |
|---|
| 16 | |
|---|
| 17 | 2b) update the protocol version number |
|---|
| 18 | src/proto/pvfs2-req-proto.h |
|---|
| 19 | increment PVFS2_PROTO_MINOR, assuming that the |
|---|
| 20 | addition of this new request does not break backwards |
|---|
| 21 | compatibility for other request types |
|---|
| 22 | |
|---|
| 23 | 3) add entries to decode/encode functions |
|---|
| 24 | src/proto/PINT-le-bytefield.c |
|---|
| 25 | lebf_initialize() - need code here to set up a request so it |
|---|
| 26 | can be encoded and expression for extra message size if any |
|---|
| 27 | lebf_encode_req() |
|---|
| 28 | lebf_encode_resp() |
|---|
| 29 | lebf_decode_req() |
|---|
| 30 | lebf_decode_resp() |
|---|
| 31 | lebf_decode_rel() (2 places) |
|---|
| 32 | In this last entry, we free any resources allocated during |
|---|
| 33 | decode - specifically array items |
|---|
| 34 | This does not free resources allocated by SM code |
|---|
| 35 | |
|---|
| 36 | 4) add request specific scratch space to PINT_server_op |
|---|
| 37 | src/server/pvfs2-server.h |
|---|
| 38 | PINT_server_op -- only if required |
|---|
| 39 | |
|---|
| 40 | 5) write state machine -- se details below |
|---|
| 41 | src/server/<reqname>.sm |
|---|
| 42 | each state machine added must have a delcaration in |
|---|
| 43 | src/server/pvfs2-server.h |
|---|
| 44 | |
|---|
| 45 | 6) update request scheduler |
|---|
| 46 | src/server/request-scheduler/request-scheduler.c |
|---|
| 47 | PINT_req_sched_target_handle() |
|---|
| 48 | |
|---|
| 49 | 7) add entry to server operation parameters table |
|---|
| 50 | src/server/pvfs2-server.c |
|---|
| 51 | init_req_table -- see src/server/prelude.sm |
|---|
| 52 | prelude_perm_check() |
|---|
| 53 | |
|---|
| 54 | 8) add entry in final response state machine |
|---|
| 55 | src/server/final-response.sm |
|---|
| 56 | s_req_resp_type_map |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | Writing State Machines |
|---|
| 61 | |
|---|
| 62 | Every state machine passes a PINT_server_op in to each state function. |
|---|
| 63 | state machine initialized in src/server/pvfs2-server.c |
|---|
| 64 | server_state_machine_start |
|---|
| 65 | gets the s_op set up |
|---|
| 66 | decodes request message |
|---|
| 67 | sets s_op->req, s_op->resp |
|---|
| 68 | |
|---|
| 69 | Each state machine must first run the pvfs2_prelude_sm |
|---|
| 70 | reads the attribs of the target object, if appropriate to s_op->attr |
|---|
| 71 | does basic permission checking |
|---|
| 72 | posts request to the scheduler |
|---|
| 73 | |
|---|
| 74 | State machines typically submit jobs, defined in |
|---|
| 75 | src/io/job/job.h |
|---|
| 76 | |
|---|
| 77 | Each state machine must run the pvfs2_final_response_sm |
|---|
| 78 | releases request from the scheduler |
|---|
| 79 | sends response to the client |
|---|
| 80 | s_op->resp must be filled in |
|---|
| 81 | return status in js_p->error_code |
|---|
| 82 | |
|---|
| 83 | Cleanup must free any memory allocated by SM code |
|---|
| 84 | |
|---|
| 85 | State functions return 0 or 1 on error-free completion, |
|---|
| 86 | 0 indicates an asynchronous call has been made and must be waited for |
|---|
| 87 | 1 indicates no async call was made and should proceed to next state |
|---|
| 88 | <0 indicates an error - use PVFS_EXXX codes defined in |
|---|
| 89 | include/pvfs2-types.h |
|---|
| 90 | |
|---|