From 0dbe0a8dc7306b17a05685fc5e224b0a4eb0223d Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 31 May 2012 16:15:33 -0500 Subject: [PATCH] vol-salvage: Unlock volumes before exiting Normally, volume locks acquired by an exiting salvaging process would be automatically given up when the process exits, since our FDs are closed. However, if we exit by calling Exit() or Abort(), we gracefully shutdown our SYNC channels before exiting. For FSSYNC, this can result in the fileserver trying to online the volumes we had checked out but had not yet checked back in, so the fileserver may try to online a volume we have locked, before the locks have been released. To avoid this, unlock all volume locks for all partitions before we shutdown SYNC channels on exit. Reviewed-on: http://gerrit.openafs.org/7514 Tested-by: BuildBot Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit fff80cb1983a8cf7ccf1c1dc4f69e232785700c5) Change-Id: I08f0ac2c4fb803cf7553a03beaa30439abab4e61 Reviewed-on: http://gerrit.openafs.org/9480 Reviewed-by: Derrick Brashear Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/vol/vol-salvage.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index fb8859b27..e4a590254 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -4714,6 +4714,18 @@ Exit(int code) #ifdef AFS_DEMAND_ATTACH_FS if (programType == salvageServer) { + /* release all volume locks before closing down our SYNC channels. + * the fileserver may try to online volumes we have checked out when + * we close down FSSYNC, so we should make sure we don't have those + * volumes locked when it does */ + struct DiskPartition64 *dp; + int i; + for (i = 0; i <= VOLMAXPARTS; i++) { + dp = VGetPartitionById(i, 0); + if (dp) { + VLockFileReinit(&dp->volLockFile); + } + } # ifdef SALVSYNC_BUILD_CLIENT VDisconnectSALV(); # endif -- 2.39.5