2 * Copyright 2006-2008, 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
13 * OpenAFS demand attach fileserver
14 * Salvage server synchronization with fileserver.
17 #include <afsconfig.h>
18 #include <afs/param.h>
27 #include <afs/afsint.h>
29 #include <afs/errors.h>
33 #include <afs/afssyscalls.h>
37 #include "partition.h"
39 #include <rx/rx_queue.h>
41 #ifdef AFS_DEMAND_ATTACH_FS
43 * SALVSYNC is a feature specific to the demand attach fileserver
48 extern pthread_mutex_t vol_salvsync_mutex;
50 static SYNC_client_state salvsync_client_state =
51 { -1, /* file descriptor */
52 SALVSYNC_ENDPOINT_DECL, /* server endpoint */
53 SALVSYNC_PROTO_VERSION, /* protocol version */
54 5, /* connect retry limit */
55 120, /* hard timeout */
56 "SALVSYNC", /* protocol name string */
60 * client-side routines
64 SALVSYNC_clientInit(void)
66 return SYNC_connect(&salvsync_client_state);
70 SALVSYNC_clientFinis(void)
72 SYNC_closeChannel(&salvsync_client_state);
77 SALVSYNC_clientReconnect(void)
79 return SYNC_reconnect(&salvsync_client_state);
83 SALVSYNC_askSalv(SYNC_command * com, SYNC_response * res)
86 SALVSYNC_command_hdr * scom = com->payload.buf;
88 scom->hdr_version = SALVSYNC_PROTO_VERSION;
91 code = SYNC_ask(&salvsync_client_state, com, res);
99 case SYNC_BAD_COMMAND:
100 Log("SALVSYNC_askSalv: fatal SALVSYNC protocol error; online salvager functionality disabled until next fileserver restart\n");
103 Log("SALVSYNC_askSalv: SALVSYNC request denied for reason=%d\n", res->hdr.reason);
106 Log("SALVSYNC_askSalv: unknown protocol response %d\n", code);
114 SALVSYNC_SalvageVolume(VolumeId volume, char *partName, int command, int reason,
115 afs_uint32 prio, SYNC_response * res_in)
118 SYNC_response res_l, *res;
119 SALVSYNC_command_hdr scom;
120 SALVSYNC_response_hdr sres;
122 memset(&com, 0, sizeof(com));
123 memset(&scom, 0, sizeof(scom));
128 memset(&res_l, 0, sizeof(res_l));
129 memset(&sres, 0, sizeof(sres));
130 res_l.payload.buf = (void *) &sres;
131 res_l.payload.len = sizeof(sres);
135 com.payload.buf = (void *) &scom;
136 com.payload.len = sizeof(scom);
137 com.hdr.command = command;
138 com.hdr.reason = reason;
139 com.hdr.command_len = sizeof(com.hdr) + sizeof(scom);
140 scom.volume = volume;
141 scom.parent = volume;
145 strlcpy(scom.partName, partName, sizeof(scom.partName));
147 scom.partName[0] = '\0';
150 return SALVSYNC_askSalv(&com, res);
154 SALVSYNC_LinkVolume(VolumeId parent,
157 SYNC_response * res_in)
160 SYNC_response res_l, *res;
161 SALVSYNC_command_hdr scom;
162 SALVSYNC_response_hdr sres;
164 memset(&com, 0, sizeof(com));
165 memset(&scom, 0, sizeof(scom));
170 memset(&res_l, 0, sizeof(res_l));
171 memset(&sres, 0, sizeof(sres));
172 res_l.payload.buf = (void *) &sres;
173 res_l.payload.len = sizeof(sres);
177 com.payload.buf = (void *) &scom;
178 com.payload.len = sizeof(scom);
179 com.hdr.command = SALVSYNC_OP_LINK;
180 com.hdr.reason = SALVSYNC_REASON_WHATEVER;
181 com.hdr.command_len = sizeof(com.hdr) + sizeof(scom);
183 scom.parent = parent;
186 strlcpy(scom.partName, partName, sizeof(scom.partName));
188 scom.partName[0] = '\0';
191 return SALVSYNC_askSalv(&com, res);
194 #endif /* AFS_DEMAND_ATTACH_FS */