2 * Copyright 2006, 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>
23 #include <sys/types.h>
29 #include <sys/param.h>
30 #include <sys/socket.h>
31 #include <netinet/in.h>
49 #include <afs/afsint.h>
51 #include <afs/errors.h>
55 #include <afs/afssyscalls.h>
59 #include "partition.h"
60 #include <rx/rx_queue.h>
62 /*@printflike@*/ extern void Log(const char *format, ...);
67 #define osi_Assert(e) (void)(e)
70 #ifdef AFS_DEMAND_ATTACH_FS
72 * SALVSYNC is a feature specific to the demand attach fileserver
77 extern pthread_mutex_t vol_salvsync_mutex;
79 static SYNC_client_state salvsync_client_state = { -1, 2041, SALVSYNC_PROTO_VERSION, 5, 120 };
82 * client-side routines
86 SALVSYNC_clientInit(void)
88 return SYNC_connect(&salvsync_client_state);
92 SALVSYNC_clientFinis(void)
94 SYNC_closeChannel(&salvsync_client_state);
99 SALVSYNC_clientReconnect(void)
101 return SYNC_reconnect(&salvsync_client_state);
105 SALVSYNC_askSalv(SYNC_command * com, SYNC_response * res)
110 code = SYNC_ask(&salvsync_client_state, com, res);
118 case SYNC_BAD_COMMAND:
119 Log("SALVSYNC_askSalv: fatal SALVSYNC protocol error; online salvager functionality disabled until next fileserver restart\n");
122 Log("SALVSYNC_askSalv: SALVSYNC request denied for reason=%d\n", res->hdr.reason);
125 Log("SALVSYNC_askSalv: unknown protocol response %d\n", code);
133 SALVSYNC_SalvageVolume(VolumeId volume, char *partName, int command, int reason,
134 afs_uint32 prio, SYNC_response * res_in)
137 SYNC_response res_l, *res;
138 SALVSYNC_command_hdr scom;
139 SALVSYNC_response_hdr sres;
142 memset(&com, 0, sizeof(com));
143 memset(&scom, 0, sizeof(scom));
148 memset(&res_l, 0, sizeof(res_l));
149 memset(&sres, 0, sizeof(sres));
150 res_l.payload.buf = (void *) &sres;
151 res_l.payload.len = sizeof(sres);
155 com.payload.buf = (void *) &scom;
156 com.payload.len = sizeof(scom);
157 com.hdr.command = command;
158 com.hdr.reason = reason;
159 com.hdr.command_len = sizeof(com.hdr) + sizeof(scom);
160 scom.volume = volume;
164 strlcpy(scom.partName, partName, sizeof(scom.partName));
166 scom.partName[0] = '\0';
169 return SALVSYNC_askSalv(&com, res);
172 #endif /* AFS_DEMAND_ATTACH_FS */