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 */
71 #include <afs/afsint.h>
73 #include <afs/errors.h>
74 #include "daemon_com.h"
78 #include <afs/afssyscalls.h>
82 #include "partition.h"
84 #ifdef FSSYNC_BUILD_CLIENT
86 /*@printflike@*/ extern void Log(const char *format, ...);
91 #define osi_Assert(e) (void)(e)
95 static SYNC_client_state fssync_state = { -1, 2040, FSYNC_PROTO_VERSION, 5, 120 };
97 #ifdef AFS_PTHREAD_ENV
98 static pthread_mutex_t vol_fsync_mutex;
99 static volatile vol_fsync_mutex_init = 0;
100 #define VFSYNC_LOCK \
101 assert(pthread_mutex_lock(&vol_fsync_mutex) == 0)
102 #define VFSYNC_UNLOCK \
103 assert(pthread_mutex_unlock(&vol_fsync_mutex) == 0)
106 #define VFSYNC_UNLOCK
110 FSYNC_clientInit(void)
112 #ifdef AFS_PTHREAD_ENV
113 /* this is safe since it gets called with VOL_LOCK held, or before we go multithreaded */
114 if (!vol_fsync_mutex_init) {
115 assert(pthread_mutex_init(&vol_fsync_mutex, NULL) == 0);
116 vol_fsync_mutex_init = 1;
119 return SYNC_connect(&fssync_state);
123 FSYNC_clientFinis(void)
125 SYNC_closeChannel(&fssync_state);
129 FSYNC_clientChildProcReconnect(void)
131 return SYNC_reconnect(&fssync_state);
134 /* fsync client interface */
136 FSYNC_askfs(SYNC_command * com, SYNC_response * res)
141 code = SYNC_ask(&fssync_state, com, res);
149 case SYNC_BAD_COMMAND:
150 Log("FSYNC_askfs: fatal FSSYNC protocol error; volume management functionality disabled until next fileserver restart\n");
153 Log("FSYNC_askfs: FSSYNC request denied for reason=%d\n", res->hdr.reason);
156 Log("FSYNC_askfs: unknown protocol response %d\n", code);
163 FSYNC_GenericOp(void * ext_hdr, size_t ext_len,
164 int command, int reason,
165 SYNC_response * res_in)
167 SYNC_response res_l, *res;
174 res_l.payload.buf = NULL;
175 res_l.payload.len = 0;
178 memset(&com, 0, sizeof(com));
180 com.hdr.programType = programType;
181 com.hdr.command = command;
182 com.hdr.reason = reason;
183 com.hdr.command_len = sizeof(com.hdr) + ext_len;
184 com.payload.buf = ext_hdr;
185 com.payload.len = ext_len;
187 return FSYNC_askfs(&com, res);
191 FSYNC_VolOp(VolumeId volume, char * partition,
192 int command, int reason,
195 FSSYNC_VolOp_hdr vcom;
197 memset(&vcom, 0, sizeof(vcom));
199 vcom.volume = volume;
201 strlcpy(vcom.partName, partition, sizeof(vcom.partName));
203 return FSYNC_GenericOp(&vcom, sizeof(vcom), command, reason, res);
207 FSYNC_StatsOp(FSSYNC_StatsOp_hdr * scom, int command, int reason,
210 return FSYNC_GenericOp(scom, sizeof(*scom), command, reason, res);
214 #endif /* FSSYNC_BUILD_CLIENT */