vol: remove SYNC fatal_error processing
[openafs.git] / src / vol / fssync-client.c
index 4fa6448..d605797 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #include <afsconfig.h>
 #include <afs/param.h>
 
-
-#include <sys/types.h>
-#include <stdio.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#include <time.h>
-#else
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/time.h>
-#endif
-#include <errno.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
-#include <afs/assert.h>
-#endif /* AFS_PTHREAD_ENV */
-#include <signal.h>
-#include <string.h>
+#include <roken.h>
 
 #include <rx/xdr.h>
 #include <afs/afsint.h>
-#include "nfs.h"
 #include <afs/errors.h>
+#include <afs/afssyscalls.h>
+
+#include "nfs.h"
 #include "daemon_com.h"
 #include "fssync.h"
 #include "lwp.h"
 #include "lock.h"
-#include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
 #include "volume.h"
 #include "partition.h"
+#include "common.h"
 
 #ifdef FSSYNC_BUILD_CLIENT
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 extern int LogLevel;
 
-static SYNC_client_state fssync_state = 
+static SYNC_client_state fssync_state =
     { -1,                    /* file descriptor */
       FSSYNC_ENDPOINT_DECL,  /* server endpoint */
       FSYNC_PROTO_VERSION,   /* protocol version */
@@ -89,10 +69,8 @@ static SYNC_client_state fssync_state =
 #ifdef AFS_PTHREAD_ENV
 static pthread_mutex_t vol_fsync_mutex;
 static volatile int vol_fsync_mutex_init = 0;
-#define VFSYNC_LOCK \
-    assert(pthread_mutex_lock(&vol_fsync_mutex) == 0)
-#define VFSYNC_UNLOCK \
-    assert(pthread_mutex_unlock(&vol_fsync_mutex) == 0)
+#define VFSYNC_LOCK MUTEX_ENTER(&vol_fsync_mutex)
+#define VFSYNC_UNLOCK MUTEX_EXIT(&vol_fsync_mutex)
 #else
 #define VFSYNC_LOCK
 #define VFSYNC_UNLOCK
@@ -104,7 +82,7 @@ FSYNC_clientInit(void)
 #ifdef AFS_PTHREAD_ENV
     /* this is safe since it gets called with VOL_LOCK held, or before we go multithreaded */
     if (!vol_fsync_mutex_init) {
-       assert(pthread_mutex_init(&vol_fsync_mutex, NULL) == 0);
+       MUTEX_INIT(&vol_fsync_mutex, "vol fsync", MUTEX_DEFAULT, 0);
        vol_fsync_mutex_init = 1;
     }
 #endif
@@ -139,7 +117,7 @@ FSYNC_askfs(SYNC_command * com, SYNC_response * res)
        break;
     case SYNC_COM_ERROR:
     case SYNC_BAD_COMMAND:
-       Log("FSYNC_askfs: fatal FSSYNC protocol error; volume management functionality disabled until next fileserver restart\n");
+       Log("FSYNC_askfs: internal FSSYNC protocol error %d\n", code);
        break;
     case SYNC_DENIED:
        Log("FSYNC_askfs: FSSYNC request denied for reason=%d\n", res->hdr.reason);
@@ -193,7 +171,7 @@ FSYNC_GenericOp(void * ext_hdr, size_t ext_len,
 }
 
 afs_int32
-FSYNC_VolOp(VolumeId volume, char * partition, 
+FSYNC_VolOp(VolumeId volume, char * partition,
            int command, int reason,
            SYNC_response * res)
 {
@@ -255,9 +233,11 @@ FSYNC_VerifyCheckout(VolumeId volume, char * partition,
            return SYNC_DENIED;
        }
 
-       if (res.hdr.reason == FSYNC_UNKNOWN_VOLID) {
-           /* if the fileserver does not know about this volume, there's no
-            * way it could have attached it, so we're fine */
+       if (res.hdr.reason == FSYNC_UNKNOWN_VOLID ||
+           res.hdr.reason == FSYNC_WRONG_PART) {
+           /* if the fileserver does not know about this volume on this
+            * partition, there's no way it could have attached it, so we're
+            * fine */
            return SYNC_OK;
        }