From 637f5b642aaee3a6f4642fd0ba15e2a9eec6c496 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 23 Mar 2011 17:25:03 -0500 Subject: [PATCH] salvager: Give back volumes when exiting early Sometimes the salvager exits a bit earlier than normal. For instance, when no applicable inodes are found for a volume group, or if the -inodes command line option was given. In these cases, we have already checked out singleVolumeNumber from the fileserver (if we're salvaging a single VG), so we need to give it back. So, give it back in those instances. Change-Id: I3ab732d3b640b76d3bdec7ac9d01e57dc5a54ade Reviewed-on: http://gerrit.openafs.org/4297 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/vol/vol-salvage.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index b1838d8..558623b 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -298,6 +298,7 @@ char *tmpdir = NULL; static int IsVnodeOrphaned(struct SalvInfo *salvinfo, VnodeId vnode); static int AskVolumeSummary(struct SalvInfo *salvinfo, VolumeId singleVolumeNumber); +static void MaybeAskOnline(struct SalvInfo *salvinfo, VolumeId volumeId); #ifdef AFS_DEMAND_ATTACH_FS static int LockVolume(struct SalvInfo *salvinfo, VolumeId volumeId); @@ -849,6 +850,11 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) if (GetInodeSummary(salvinfo, inodeFile, singleVolumeNumber) < 0) { OS_CLOSE(inodeFile); + if (singleVolumeNumber) { + /* the volume group -- let alone the volume -- does not exist, + * but we checked it out, so give it back to the fileserver */ + AskDelete(salvinfo, singleVolumeNumber); + } return; } salvinfo->inodeFd = inodeFile; @@ -857,6 +863,14 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) OS_SEEK(salvinfo->inodeFd, 0L, SEEK_SET); if (ListInodeOption) { PrintInodeList(salvinfo); + if (singleVolumeNumber) { + /* We've checked out the volume from the fileserver, and we need + * to give it back. We don't know if the volume exists or not, + * so we don't know whether to AskOnline or not. Try to determine + * if the volume exists by trying to read the volume header, and + * AskOnline if it is readable. */ + MaybeAskOnline(salvinfo, singleVolumeNumber); + } return; } /* enumerate volumes in the partition. @@ -4403,6 +4417,19 @@ AskDAFS(void) return ret; } +static void +MaybeAskOnline(struct SalvInfo *salvinfo, VolumeId volumeId) +{ + struct VolumeDiskHeader diskHdr; + int code; + code = VReadVolumeDiskHeader(volumeId, salvinfo->fileSysPartition, &diskHdr); + if (code) { + /* volume probably does not exist; no need to bring back online */ + return; + } + AskOnline(salvinfo, volumeId); +} + void AskOnline(struct SalvInfo *salvinfo, VolumeId volumeId) { -- 1.9.4