]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
salvager: Give back volumes when exiting early
authorAndrew Deason <adeason@sinenomine.net>
Wed, 23 Mar 2011 22:25:03 +0000 (17:25 -0500)
committerDerrick Brashear <shadow@dementix.org>
Wed, 2 Nov 2011 02:34:25 +0000 (19:34 -0700)
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.

Reviewed-on: http://gerrit.openafs.org/4297
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 637f5b642aaee3a6f4642fd0ba15e2a9eec6c496)

Change-Id: Ib40ffb84fa6c40cfd692c561b913decb97268403
Reviewed-on: http://gerrit.openafs.org/5762
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
src/vol/vol-salvage.c

index 31ab2374a762d2117c477909d6f987180edc9466..20ef0aea1e502373b78f4b69bca08afcea4ff903 100644 (file)
@@ -318,6 +318,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);
 
 #if defined(AFS_DEMAND_ATTACH_FS) || defined(AFS_DEMAND_ATTACH_UTIL)
 static int LockVolume(struct SalvInfo *salvinfo, VolumeId volumeId);
@@ -869,6 +870,11 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
 
     if (GetInodeSummary(salvinfo, inodeFile, singleVolumeNumber) < 0) {
        fclose(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 = fileno(inodeFile);
@@ -877,6 +883,14 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
     afs_lseek(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.
@@ -4461,6 +4475,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)
 {