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,2008 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, ...);
90 static SYNC_client_state fssync_state =
91 { -1, /* file descriptor */
92 FSSYNC_ENDPOINT_DECL, /* server endpoint */
93 FSYNC_PROTO_VERSION, /* protocol version */
94 5, /* connect retry limit */
95 120, /* hard timeout */
96 "FSSYNC", /* protocol name string */
99 #ifdef AFS_PTHREAD_ENV
100 static pthread_mutex_t vol_fsync_mutex;
101 static volatile vol_fsync_mutex_init = 0;
102 #define VFSYNC_LOCK \
103 assert(pthread_mutex_lock(&vol_fsync_mutex) == 0)
104 #define VFSYNC_UNLOCK \
105 assert(pthread_mutex_unlock(&vol_fsync_mutex) == 0)
108 #define VFSYNC_UNLOCK
112 FSYNC_clientInit(void)
114 #ifdef AFS_PTHREAD_ENV
115 /* this is safe since it gets called with VOL_LOCK held, or before we go multithreaded */
116 if (!vol_fsync_mutex_init) {
117 assert(pthread_mutex_init(&vol_fsync_mutex, NULL) == 0);
118 vol_fsync_mutex_init = 1;
121 return SYNC_connect(&fssync_state);
125 FSYNC_clientFinis(void)
127 SYNC_closeChannel(&fssync_state);
131 FSYNC_clientChildProcReconnect(void)
133 return SYNC_reconnect(&fssync_state);
136 /* fsync client interface */
138 FSYNC_askfs(SYNC_command * com, SYNC_response * res)
143 code = SYNC_ask(&fssync_state, com, res);
151 case SYNC_BAD_COMMAND:
152 Log("FSYNC_askfs: fatal FSSYNC protocol error; volume management functionality disabled until next fileserver restart\n");
155 Log("FSYNC_askfs: FSSYNC request denied for reason=%d\n", res->hdr.reason);
158 Log("FSYNC_askfs: unknown protocol response %d\n", code);
165 FSYNC_GenericOp(void * ext_hdr, size_t ext_len,
166 int command, int reason,
167 SYNC_response * res_in)
169 SYNC_response res_l, *res;
176 res_l.payload.buf = NULL;
177 res_l.payload.len = 0;
180 memset(&com, 0, sizeof(com));
182 com.hdr.programType = programType;
183 com.hdr.command = command;
184 com.hdr.reason = reason;
185 com.hdr.command_len = sizeof(com.hdr) + ext_len;
186 com.payload.buf = ext_hdr;
187 com.payload.len = ext_len;
189 return FSYNC_askfs(&com, res);
193 FSYNC_VolOp(VolumeId volume, char * partition,
194 int command, int reason,
197 FSSYNC_VolOp_hdr vcom;
199 memset(&vcom, 0, sizeof(vcom));
201 vcom.volume = volume;
203 strlcpy(vcom.partName, partition, sizeof(vcom.partName));
205 return FSYNC_GenericOp(&vcom, sizeof(vcom), command, reason, res);
209 FSYNC_StatsOp(FSSYNC_StatsOp_hdr * scom, int command, int reason,
212 return FSYNC_GenericOp(scom, sizeof(*scom), command, reason, res);
216 #endif /* FSSYNC_BUILD_CLIENT */