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>
24 #include <afs/afsint.h>
25 #include <rx/rx_queue.h>
27 #include <afs/errors.h>
30 #include <afs/afssyscalls.h>
34 #include "partition.h"
36 #include <rx/rx_queue.h>
38 #ifdef AFS_DEMAND_ATTACH_FS
40 * SALVSYNC is a feature specific to the demand attach fileserver
44 extern pthread_mutex_t vol_salvsync_mutex;
46 static SYNC_client_state salvsync_client_state =
47 { -1, /* file descriptor */
48 SALVSYNC_ENDPOINT_DECL, /* server endpoint */
49 SALVSYNC_PROTO_VERSION, /* protocol version */
50 5, /* connect retry limit */
51 120, /* hard timeout */
52 "SALVSYNC", /* protocol name string */
56 * client-side routines
60 SALVSYNC_clientInit(void)
62 return SYNC_connect(&salvsync_client_state);
66 SALVSYNC_clientFinis(void)
68 SYNC_closeChannel(&salvsync_client_state);
73 SALVSYNC_clientReconnect(void)
75 return SYNC_reconnect(&salvsync_client_state);
79 SALVSYNC_askSalv(SYNC_command * com, SYNC_response * res)
82 SALVSYNC_command_hdr * scom = com->payload.buf;
84 scom->hdr_version = SALVSYNC_PROTO_VERSION;
87 code = SYNC_ask(&salvsync_client_state, com, res);
95 case SYNC_BAD_COMMAND:
96 Log("SALVSYNC_askSalv: internal SALVSYNC protocol error %d\n", code);
99 Log("SALVSYNC_askSalv: SALVSYNC request denied for reason=%d\n", res->hdr.reason);
102 Log("SALVSYNC_askSalv: unknown protocol response %d\n", code);
110 SALVSYNC_SalvageVolume(VolumeId volume, char *partName, int command, int reason,
111 afs_uint32 prio, SYNC_response * res_in)
114 SYNC_response res_l, *res;
115 SALVSYNC_command_hdr scom;
116 SALVSYNC_response_hdr sres;
118 memset(&com, 0, sizeof(com));
119 memset(&scom, 0, sizeof(scom));
124 memset(&res_l, 0, sizeof(res_l));
125 memset(&sres, 0, sizeof(sres));
126 res_l.payload.buf = (void *) &sres;
127 res_l.payload.len = sizeof(sres);
131 com.payload.buf = (void *) &scom;
132 com.payload.len = sizeof(scom);
133 com.hdr.command = command;
134 com.hdr.reason = reason;
135 com.hdr.command_len = sizeof(com.hdr) + sizeof(scom);
136 scom.volume = volume;
137 scom.parent = volume;
141 strlcpy(scom.partName, partName, sizeof(scom.partName));
143 scom.partName[0] = '\0';
146 return SALVSYNC_askSalv(&com, res);
150 SALVSYNC_LinkVolume(VolumeId parent,
153 SYNC_response * res_in)
156 SYNC_response res_l, *res;
157 SALVSYNC_command_hdr scom;
158 SALVSYNC_response_hdr sres;
160 memset(&com, 0, sizeof(com));
161 memset(&scom, 0, sizeof(scom));
166 memset(&res_l, 0, sizeof(res_l));
167 memset(&sres, 0, sizeof(sres));
168 res_l.payload.buf = (void *) &sres;
169 res_l.payload.len = sizeof(sres);
173 com.payload.buf = (void *) &scom;
174 com.payload.len = sizeof(scom);
175 com.hdr.command = SALVSYNC_OP_LINK;
176 com.hdr.reason = SALVSYNC_REASON_WHATEVER;
177 com.hdr.command_len = sizeof(com.hdr) + sizeof(scom);
179 scom.parent = parent;
182 strlcpy(scom.partName, partName, sizeof(scom.partName));
184 scom.partName[0] = '\0';
187 return SALVSYNC_askSalv(&com, res);
190 #endif /* AFS_DEMAND_ATTACH_FS */