2 * Copyright 2006-2007, Sine Nomine Associates and others.
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
12 * salvage server interface
14 #ifndef _AFS_VOL_SALVSYNC_H
15 #define _AFS_VOL_SALVSYNC_H
17 #define SALSRV_EXIT_VOLGROUP_LINK 10
20 #ifdef AFS_DEMAND_ATTACH_FS
21 #include "daemon_com.h"
25 #define SALVSYNC_PROTO_VERSION_V1 1
26 #define SALVSYNC_PROTO_VERSION_V2 2
27 #define SALVSYNC_PROTO_VERSION SALVSYNC_PROTO_VERSION_V2
31 * SALVSYNC protocol command codes.
34 SALVSYNC_OP_NOP = SYNC_COM_CODE_DECL(0), /**< just return stats */
35 SALVSYNC_OP_SALVAGE = SYNC_COM_CODE_DECL(1), /**< schedule a salvage */
36 SALVSYNC_OP_CANCEL = SYNC_COM_CODE_DECL(2), /**< cancel a salvage */
37 SALVSYNC_OP_RAISEPRIO = SYNC_COM_CODE_DECL(3), /**< raise salvage priority */
38 SALVSYNC_OP_QUERY = SYNC_COM_CODE_DECL(4), /**< query status of a salvage */
39 SALVSYNC_OP_CANCELALL = SYNC_COM_CODE_DECL(5), /**< cancel all pending salvages */
40 SALVSYNC_OP_LINK = SYNC_COM_CODE_DECL(6), /**< link a clone to its parent */
41 SALVSYNC_OP_MAX_ID /* must be at end of enum */
44 #define SALVSYNC_NOP SALVSYNC_OP_NOP
45 #define SALVSYNC_SALVAGE SALVSYNC_OP_SALVAGE
46 #define SALVSYNC_CANCEL SALVSYNC_OP_CANCEL
47 #define SALVSYNC_RAISEPRIO SALVSYNC_OP_RAISEPRIO
48 #define SALVSYNC_QUERY SALVSYNC_OP_QUERY
49 #define SALVSYNC_CANCELALL SALVSYNC_OP_CANCELALL
50 #define SALVSYNC_LINK SALVSYNC_OP_LINK
53 * SALVSYNC protocol reason codes.
56 SALVSYNC_REASON_WHATEVER = SYNC_REASON_CODE_DECL(0), /**< XXX */
57 SALVSYNC_REASON_ERROR = SYNC_REASON_CODE_DECL(1), /**< volume is in error state */
58 SALVSYNC_REASON_OPERATOR = SYNC_REASON_CODE_DECL(2), /**< operator forced salvage */
59 SALVSYNC_REASON_SHUTDOWN = SYNC_REASON_CODE_DECL(3), /**< cancel due to shutdown */
60 SALVSYNC_REASON_NEEDED = SYNC_REASON_CODE_DECL(4), /**< needsSalvaged flag set */
61 SALVSYNC_REASON_MAX_ID /* must be at end of enum */
62 } SALVSYNC_reason_code_t;
64 #define SALVSYNC_WHATEVER SALVSYNC_REASON_WHATEVER
65 #define SALVSYNC_ERROR SALVSYNC_REASON_ERROR
66 #define SALVSYNC_OPERATOR SALVSYNC_REASON_OPERATOR
67 #define SALVSYNC_SHUTDOWN SALVSYNC_REASON_SHUTDOWN
68 #define SALVSYNC_NEEDED SALVSYNC_REASON_NEEDED
70 /* SALVSYNC response codes */
73 #define SALVSYNC_FLAG_VOL_STATS_VALID SYNC_FLAG_CODE_DECL(0) /* volume stats in response are valid */
76 * SALVSYNC command state.
79 SALVSYNC_STATE_UNKNOWN = 0, /**< unknown state */
80 SALVSYNC_STATE_QUEUED = 1, /**< salvage request is queued */
81 SALVSYNC_STATE_SALVAGING = 2, /**< salvage is happening now */
82 SALVSYNC_STATE_ERROR = 3, /**< salvage ended in an error */
83 SALVSYNC_STATE_DONE = 4 /**< last salvage ended successfully */
84 } SALVSYNC_command_state_t;
88 * on-wire salvsync protocol payload.
90 typedef struct SALVSYNC_command_hdr {
91 afs_uint32 hdr_version; /**< salvsync protocol header version */
92 afs_uint32 prio; /**< salvage priority */
93 afs_uint32 volume; /**< volume on which to operate */
94 afs_uint32 parent; /**< parent volume (for vol group linking command) */
95 char partName[16]; /**< partition name, e.g. /vicepa */
96 afs_uint32 reserved[6];
97 } SALVSYNC_command_hdr;
99 typedef struct SALVSYNC_response_hdr {
104 afs_uint32 reserved[4];
105 } SALVSYNC_response_hdr;
107 typedef struct SALVSYNC_command {
108 SYNC_command_hdr * hdr;
109 SALVSYNC_command_hdr * sop;
113 typedef struct SALVSYNC_response {
114 SYNC_response_hdr * hdr;
115 SALVSYNC_response_hdr * sop;
119 typedef struct SALVSYNC_command_info {
120 SYNC_command_hdr com;
121 SALVSYNC_command_hdr sop;
122 } SALVSYNC_command_info;
125 SALVSYNC_VOLGROUP_PARENT,
126 SALVSYNC_VOLGROUP_CLONE
127 } SalvageQueueNodeType_t;
129 struct SalvageQueueNode {
131 struct rx_queue hash_chain;
132 SalvageQueueNodeType_t type;
134 struct SalvageQueueNode * parent;
135 struct SalvageQueueNode * children[VOLMAXTYPES];
137 SALVSYNC_command_state_t state;
138 struct SALVSYNC_command_info command;
139 afs_int32 partition_id;
144 /* Prototypes from salvsync.c */
146 /* online salvager client interfaces */
147 extern int SALVSYNC_clientFinis(void);
148 extern int SALVSYNC_clientInit(void);
149 extern int SALVSYNC_clientReconnect(void);
150 extern afs_int32 SALVSYNC_askSalv(SYNC_command * com, SYNC_response * res);
151 extern afs_int32 SALVSYNC_SalvageVolume(VolumeId volume, char *partName, int com, int reason,
152 afs_uint32 prio, SYNC_response * res);
153 extern afs_int32 SALVSYNC_LinkVolume(VolumeId parent, VolumeId clone,
154 char * partName, SYNC_response * res_in);
156 /* salvage server interfaces */
157 extern void SALVSYNC_salvInit(void);
158 extern struct SalvageQueueNode * SALVSYNC_getWork(void);
159 extern void SALVSYNC_doneWork(struct SalvageQueueNode *, int result);
160 extern void SALVSYNC_doneWorkByPid(int pid, int result);
162 #endif /* AFS_DEMAND_ATTACH_FS */
164 #endif /* _AFS_VOL_SALVSYNC_H */