root/trunk/doc/add-server-req @ 4617

Revision 4617, 2.7 KB (checked in by robl, 8 years ago)

[pcarns]: add protocol versioning to PVFS2. Major version changes are
incompatible up or down. New clients can't talk to old servers, but new
servers can talk to old clients.

Line 
1
2
3Steps in adding a request to the server:
4
51) select a request name and number
6                src/proto/pvfs2-req-proto.h
7
82) 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
122a) 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
172b) 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       
233) 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
364) add request specific scratch space to PINT_server_op
37                src/server/pvfs2-server.h
38                        PINT_server_op  -- only if required
39
405) 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
456) update request scheduler
46                src/server/request-scheduler/request-scheduler.c
47                        PINT_req_sched_target_handle()
48
497) 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
548) add entry in final response state machine
55                src/server/final-response.sm
56                        s_req_resp_type_map
57
58
59
60Writing State Machines
61
62Every 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
69Each 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
74State machines typically submit jobs, defined in
75        src/io/job/job.h
76
77Each 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
83Cleanup must free any memory allocated by SM code
84
85State 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
Note: See TracBrowser for help on using the browser.