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>
41 #include <afs/afsint.h>
43 #include <afs/errors.h>
47 #include <afs/afssyscalls.h>
51 #include "partition.h"
52 #include <rx/rx_queue.h>
54 /*@printflike@*/ extern void Log(const char *format, ...);
59 #define osi_Assert(e) (void)(e)
62 #ifdef AFS_DEMAND_ATTACH_FS
64 * SALVSYNC is a feature specific to the demand attach fileserver
69 extern pthread_mutex_t vol_salvsync_mutex;
71 static SYNC_client_state salvsync_client_state = { -1, 2041, SALVSYNC_PROTO_VERSION, 5, 120 };
74 * client-side routines
78 SALVSYNC_clientInit(void)
80 return SYNC_connect(&salvsync_client_state);
84 SALVSYNC_clientFinis(void)
86 SYNC_closeChannel(&salvsync_client_state);
91 SALVSYNC_clientReconnect(void)
93 return SYNC_reconnect(&salvsync_client_state);
97 SALVSYNC_askSalv(SYNC_command * com, SYNC_response * res)
102 code = SYNC_ask(&salvsync_client_state, com, res);
110 case SYNC_BAD_COMMAND:
111 Log("SALVSYNC_askSalv: fatal SALVSYNC protocol error; online salvager functionality disabled until next fileserver restart\n");
114 Log("SALVSYNC_askSalv: SALVSYNC request denied for reason=%d\n", res->hdr.reason);
117 Log("SALVSYNC_askSalv: unknown protocol response %d\n", code);
125 SALVSYNC_SalvageVolume(VolumeId volume, char *partName, int command, int reason,
126 afs_uint32 prio, SYNC_response * res_in)
129 SYNC_response res_l, *res;
130 SALVSYNC_command_hdr scom;
131 SALVSYNC_response_hdr sres;
134 memset(&com, 0, sizeof(com));
135 memset(&scom, 0, sizeof(scom));
140 memset(&res_l, 0, sizeof(res_l));
141 memset(&sres, 0, sizeof(sres));
142 res_l.payload.buf = (void *) &sres;
143 res_l.payload.len = sizeof(sres);
147 com.payload.buf = (void *) &scom;
148 com.payload.len = sizeof(scom);
149 com.hdr.command = command;
150 com.hdr.reason = reason;
151 com.hdr.command_len = sizeof(com.hdr) + sizeof(scom);
152 scom.volume = volume;
156 strlcpy(scom.partName, partName, sizeof(scom.partName));
158 scom.partName[0] = '\0';
161 return SALVSYNC_askSalv(&com, res);
164 #endif /* AFS_DEMAND_ATTACH_FS */