Commit | Line | Data |
---|---|---|
805e021f CE |
1 | /* |
2 | * Copyright 2006-2010, Sine Nomine Associates and others. | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * This software has been released under the terms of the IBM Public | |
6 | * License. For details, see the LICENSE file in the top-level source | |
7 | * directory or online at http://www.openafs.org/dl/license10.html | |
8 | */ | |
9 | ||
10 | /* | |
11 | * demand attach fs | |
12 | * salvage server interface | |
13 | */ | |
14 | #ifndef _AFS_VOL_SALVSYNC_H | |
15 | #define _AFS_VOL_SALVSYNC_H 1 | |
16 | ||
17 | #define SALSRV_EXIT_VOLGROUP_LINK 10 | |
18 | ||
19 | ||
20 | #ifdef AFS_DEMAND_ATTACH_FS | |
21 | #include "daemon_com.h" | |
22 | #include "voldefs.h" | |
23 | ||
24 | ||
25 | #define SALVSYNC_PROTO_VERSION_V1 1 | |
26 | #define SALVSYNC_PROTO_VERSION_V2 2 | |
27 | #define SALVSYNC_PROTO_VERSION_V3 3 | |
28 | #define SALVSYNC_PROTO_VERSION SALVSYNC_PROTO_VERSION_V3 | |
29 | ||
30 | ||
31 | /** | |
32 | * SALVSYNC protocol command codes. | |
33 | */ | |
34 | typedef enum { | |
35 | SALVSYNC_OP_NOP = SYNC_COM_CODE_DECL(0), /**< just return stats */ | |
36 | SALVSYNC_OP_SALVAGE = SYNC_COM_CODE_DECL(1), /**< schedule a salvage */ | |
37 | SALVSYNC_OP_CANCEL = SYNC_COM_CODE_DECL(2), /**< cancel a salvage */ | |
38 | SALVSYNC_OP_RAISEPRIO = SYNC_COM_CODE_DECL(3), /**< raise salvage priority */ | |
39 | SALVSYNC_OP_QUERY = SYNC_COM_CODE_DECL(4), /**< query status of a salvage */ | |
40 | SALVSYNC_OP_CANCELALL = SYNC_COM_CODE_DECL(5), /**< cancel all pending salvages */ | |
41 | SALVSYNC_OP_LINK = SYNC_COM_CODE_DECL(6), /**< link a clone to its parent */ | |
42 | SALVSYNC_OP_MAX_ID /* must be at end of enum */ | |
43 | } SALVSYNC_op_code_t; | |
44 | ||
45 | #define SALVSYNC_NOP SALVSYNC_OP_NOP | |
46 | #define SALVSYNC_SALVAGE SALVSYNC_OP_SALVAGE | |
47 | #define SALVSYNC_CANCEL SALVSYNC_OP_CANCEL | |
48 | #define SALVSYNC_RAISEPRIO SALVSYNC_OP_RAISEPRIO | |
49 | #define SALVSYNC_QUERY SALVSYNC_OP_QUERY | |
50 | #define SALVSYNC_CANCELALL SALVSYNC_OP_CANCELALL | |
51 | #define SALVSYNC_LINK SALVSYNC_OP_LINK | |
52 | ||
53 | /** | |
54 | * SALVSYNC protocol reason codes. | |
55 | */ | |
56 | typedef enum { | |
57 | SALVSYNC_REASON_WHATEVER = SYNC_REASON_CODE_DECL(0), /**< XXX */ | |
58 | SALVSYNC_REASON_ERROR = SYNC_REASON_CODE_DECL(1), /**< volume is in error state */ | |
59 | SALVSYNC_REASON_OPERATOR = SYNC_REASON_CODE_DECL(2), /**< operator forced salvage */ | |
60 | SALVSYNC_REASON_SHUTDOWN = SYNC_REASON_CODE_DECL(3), /**< cancel due to shutdown */ | |
61 | SALVSYNC_REASON_NEEDED = SYNC_REASON_CODE_DECL(4), /**< needsSalvaged flag set */ | |
62 | SALVSYNC_REASON_MAX_ID /* must be at end of enum */ | |
63 | } SALVSYNC_reason_code_t; | |
64 | ||
65 | #define SALVSYNC_WHATEVER SALVSYNC_REASON_WHATEVER | |
66 | #define SALVSYNC_ERROR SALVSYNC_REASON_ERROR | |
67 | #define SALVSYNC_OPERATOR SALVSYNC_REASON_OPERATOR | |
68 | #define SALVSYNC_SHUTDOWN SALVSYNC_REASON_SHUTDOWN | |
69 | #define SALVSYNC_NEEDED SALVSYNC_REASON_NEEDED | |
70 | ||
71 | /* SALVSYNC response codes */ | |
72 | ||
73 | /* SALVSYNC flags */ | |
74 | #define SALVSYNC_FLAG_VOL_STATS_VALID SYNC_FLAG_CODE_DECL(0) /* volume stats in response are valid */ | |
75 | ||
76 | /** | |
77 | * SALVSYNC command state. | |
78 | */ | |
79 | typedef enum { | |
80 | SALVSYNC_STATE_UNKNOWN = 0, /**< unknown state */ | |
81 | SALVSYNC_STATE_QUEUED = 1, /**< salvage request is queued */ | |
82 | SALVSYNC_STATE_SALVAGING = 2, /**< salvage is happening now */ | |
83 | SALVSYNC_STATE_ERROR = 3, /**< salvage ended in an error */ | |
84 | SALVSYNC_STATE_DONE = 4 /**< last salvage ended successfully */ | |
85 | } SALVSYNC_command_state_t; | |
86 | ||
87 | ||
88 | /** | |
89 | * on-wire salvsync protocol payload. | |
90 | */ | |
91 | typedef struct SALVSYNC_command_hdr { | |
92 | afs_uint32 hdr_version; /**< salvsync protocol header version */ | |
93 | afs_uint32 prio; /**< salvage priority */ | |
94 | VolumeId volume; /**< volume on which to operate */ | |
95 | afs_uint32 parent; /**< parent volume (for vol group linking command) */ | |
96 | char partName[16]; /**< partition name, e.g. /vicepa */ | |
97 | afs_uint32 reserved[6]; | |
98 | } SALVSYNC_command_hdr; | |
99 | ||
100 | typedef struct SALVSYNC_response_hdr { | |
101 | afs_int32 state; | |
102 | afs_int32 prio; | |
103 | afs_int32 sq_len; | |
104 | afs_int32 pq_len; | |
105 | afs_uint32 reserved[4]; | |
106 | } SALVSYNC_response_hdr; | |
107 | ||
108 | typedef struct SALVSYNC_command { | |
109 | SYNC_command_hdr * hdr; | |
110 | SALVSYNC_command_hdr * sop; | |
111 | SYNC_command * com; | |
112 | } SALVSYNC_command; | |
113 | ||
114 | typedef struct SALVSYNC_response { | |
115 | SYNC_response_hdr * hdr; | |
116 | SALVSYNC_response_hdr * sop; | |
117 | SYNC_response * res; | |
118 | } SALVSYNC_response; | |
119 | ||
120 | typedef struct SALVSYNC_command_info { | |
121 | SYNC_command_hdr com; | |
122 | SALVSYNC_command_hdr sop; | |
123 | } SALVSYNC_command_info; | |
124 | ||
125 | typedef enum { | |
126 | SALVSYNC_VOLGROUP_PARENT, | |
127 | SALVSYNC_VOLGROUP_CLONE | |
128 | } SalvageQueueNodeType_t; | |
129 | ||
130 | struct SalvageQueueNode { | |
131 | struct rx_queue q; | |
132 | struct rx_queue hash_chain; | |
133 | SalvageQueueNodeType_t type; | |
134 | union { | |
135 | struct SalvageQueueNode * parent; | |
136 | struct SalvageQueueNode * children[VOLMAXTYPES]; | |
137 | } volgroup; | |
138 | SALVSYNC_command_state_t state; | |
139 | struct SALVSYNC_command_info command; | |
140 | afs_int32 partition_id; | |
141 | int pid; | |
142 | }; | |
143 | ||
144 | #define SALVSYNC_IN_PORT 2041 | |
145 | #define SALVSYNC_UN_PATH "salvsync.sock" | |
146 | #define SALVSYNC_ENDPOINT_DECL SYNC_ENDPOINT_DECL(SALVSYNC_IN_PORT, SALVSYNC_UN_PATH) | |
147 | ||
148 | /* Prototypes from salvsync.c */ | |
149 | ||
150 | /* online salvager client interfaces */ | |
151 | extern int SALVSYNC_clientFinis(void); | |
152 | extern int SALVSYNC_clientInit(void); | |
153 | extern int SALVSYNC_clientReconnect(void); | |
154 | extern afs_int32 SALVSYNC_askSalv(SYNC_command * com, SYNC_response * res); | |
155 | extern afs_int32 SALVSYNC_SalvageVolume(VolumeId volume, char *partName, int com, int reason, | |
156 | afs_uint32 prio, SYNC_response * res); | |
157 | extern afs_int32 SALVSYNC_LinkVolume(VolumeId parent, VolumeId clone, | |
158 | char * partName, SYNC_response * res_in); | |
159 | ||
160 | /* salvage server interfaces */ | |
161 | extern void SALVSYNC_salvInit(void); | |
162 | extern struct SalvageQueueNode * SALVSYNC_getWork(void); | |
163 | extern void SALVSYNC_doneWorkByPid(int pid, int result); | |
164 | ||
165 | #endif /* AFS_DEMAND_ATTACH_FS */ | |
166 | ||
167 | #endif /* _AFS_VOL_SALVSYNC_H */ |