2 * Copyright 2000, International Business Machines Corporation 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
9 * Portions Copyright (c) 2006 Sine Nomine Associates
15 Institution: The Information Technology Center, Carnegie-Mellon University
20 /* All this is going away in early 1989 */
21 int newVLDB; /* Compatibility flag */
24 static int newVLDB = 1;
27 #ifndef AFS_PTHREAD_ENV
28 #define USUAL_PRIORITY (LWP_MAX_PRIORITY - 2)
31 * stack size increased from 8K because the HP machine seemed to have trouble
32 * with the smaller stack
34 #define USUAL_STACK_SIZE (24 * 1024)
35 #endif /* !AFS_PTHREAD_ENV */
39 File server synchronization with external volume utilities.
40 client-side implementation
43 #include <afsconfig.h>
44 #include <afs/param.h>
49 #include <sys/types.h>
55 #include <sys/param.h>
56 #include <sys/socket.h>
57 #include <netinet/in.h>
62 #ifdef AFS_PTHREAD_ENV
64 #else /* AFS_PTHREAD_ENV */
65 #include <afs/assert.h>
66 #endif /* AFS_PTHREAD_ENV */
79 #include <afs/afsint.h>
81 #include <afs/errors.h>
82 #include "daemon_com.h"
86 #include <afs/afssyscalls.h>
90 #include "partition.h"
92 #ifdef FSSYNC_BUILD_CLIENT
94 /*@printflike@*/ extern void Log(const char *format, ...);
99 #define osi_Assert(e) (void)(e)
103 static SYNC_client_state fssync_state = { -1, 2040, FSYNC_PROTO_VERSION, 5, 120 };
105 #ifdef AFS_PTHREAD_ENV
106 static pthread_mutex_t vol_fsync_mutex;
107 static volatile vol_fsync_mutex_init = 0;
108 #define VFSYNC_LOCK \
109 assert(pthread_mutex_lock(&vol_fsync_mutex) == 0)
110 #define VFSYNC_UNLOCK \
111 assert(pthread_mutex_unlock(&vol_fsync_mutex) == 0)
114 #define VFSYNC_UNLOCK
118 FSYNC_clientInit(void)
120 #ifdef AFS_PTHREAD_ENV
121 /* this is safe since it gets called with VOL_LOCK held, or before we go multithreaded */
122 if (!vol_fsync_mutex_init) {
123 assert(pthread_mutex_init(&vol_fsync_mutex, NULL) == 0);
124 vol_fsync_mutex_init = 1;
127 return SYNC_connect(&fssync_state);
131 FSYNC_clientFinis(void)
133 SYNC_closeChannel(&fssync_state);
137 FSYNC_clientChildProcReconnect(void)
139 return SYNC_reconnect(&fssync_state);
142 /* fsync client interface */
144 FSYNC_askfs(SYNC_command * com, SYNC_response * res)
149 code = SYNC_ask(&fssync_state, com, res);
157 case SYNC_BAD_COMMAND:
158 Log("FSYNC_askfs: fatal FSSYNC protocol error; volume management functionality disabled until next fileserver restart\n");
161 Log("FSYNC_askfs: FSSYNC request denied for reason=%d\n", res->hdr.reason);
164 Log("FSYNC_askfs: unknown protocol response %d\n", code);
171 FSYNC_GenericOp(void * ext_hdr, size_t ext_len,
172 int command, int reason,
173 SYNC_response * res_in)
175 SYNC_response res_l, *res;
182 res_l.payload.buf = NULL;
183 res_l.payload.len = 0;
186 memset(&com, 0, sizeof(com));
188 com.hdr.programType = programType;
189 com.hdr.command = command;
190 com.hdr.reason = reason;
191 com.hdr.command_len = sizeof(com.hdr) + ext_len;
192 com.payload.buf = ext_hdr;
193 com.payload.len = ext_len;
195 return FSYNC_askfs(&com, res);
199 FSYNC_VolOp(VolumeId volume, char * partition,
200 int command, int reason,
203 FSSYNC_VolOp_hdr vcom;
205 memset(&vcom, 0, sizeof(vcom));
207 vcom.volume = volume;
209 strlcpy(vcom.partName, partition, sizeof(vcom.partName));
211 return FSYNC_GenericOp(&vcom, sizeof(vcom), command, reason, res);
215 FSYNC_StatsOp(FSSYNC_StatsOp_hdr * scom, int command, int reason,
218 return FSYNC_GenericOp(scom, sizeof(*scom), command, reason, res);
222 #endif /* FSSYNC_BUILD_CLIENT */