vol: avoid query for parent id when deleting disk header 96/13896/3
authorMichael Meffie <mmeffie@sinenomine.net>
Thu, 21 Dec 2017 16:59:38 +0000 (11:59 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Sun, 9 Feb 2020 17:48:33 +0000 (12:48 -0500)
When a DAFS volume server removes a volume disk header file (V*.vol),
the volume server invokes an fssync command to have the file server
delete the Volume Group Cache (VGC) entry corresponding to the volume id
and the parent id of the removed volume header.

The volume parent id is unknown to the volume server when removing a
volume disk header on behalf of a "vos zap -force" operation. In this
case, the volume server issues a fssync query to attempt look up to the
parent id from the file server's VGC.  If this fssync query fails for
some reason, volume server is unable to delete the VGC entry for the
deleted volume header. The volume server logs an error and vos zap
reports a undocumented error code.

One common way this can be encountered is to issue a "vos zap -force" on
a file server that has just been restarted. In this case, the VGC may
not be fully populated yet, so the volume server is not able to look up
the parent id of the given volume.

With this commit, relax the requirement for the parent id when deleting
VGC entries. A placeholder of 0 is used to mean any parent id for the
given volume id.

This obviates the need to query for the parent id when performing a "vos
zap -force", and allows the volume server to remove any VGC entries
associated with the volume id being zapped.

Reviewed-on: https://gerrit.openafs.org/12839
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 65b55bcc26f69f25c67518f672b34be73f3be370)

Change-Id: I2e927d7b388c7be36a67e196a3acb70e58c9a661
Reviewed-on: https://gerrit.openafs.org/13896
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>

src/vol/vg_cache.c
src/vol/vg_scan.c
src/vol/vutil.c

index 307b358..5a53a2f 100644 (file)
@@ -869,32 +869,37 @@ _VVGC_entry_purge_r(struct DiskPartition64 * dp,
                     VolumeId parent, VolumeId child)
 {
     int code = 0, res;
-    VVGCache_entry_t * parent_ent, * child_ent;
+    VVGCache_entry_t * child_ent;
     VVGCache_hash_entry_t * child_hent;
 
-    /* check mappings for each volid */
-    res = _VVGC_lookup(dp, parent, &parent_ent, NULL);
-    if (res) {
-       code = res;
-       goto done;
-    }
     res = _VVGC_lookup(dp, child, &child_ent, &child_hent);
     if (res) {
        code = res;
        goto done;
     }
 
-    /* if the mappings don't match, we have a serious error */
-    if (parent_ent != child_ent) {
-       ViceLog(0, ("VVGCache_entry_del: trying to delete vol %lu from VG %lu, "
-           "but vol %lu points to VGC entry %"AFS_PTR_FMT" and VG %lu "
-           "points to VGC entry %"AFS_PTR_FMT"\n",
-           afs_printable_uint32_lu(child),
-           afs_printable_uint32_lu(parent),
-           afs_printable_uint32_lu(child),
-           child_ent, afs_printable_uint32_lu(parent), parent_ent));
-       code = -1;
-       goto done;
+    if (parent != 0) {
+       VVGCache_entry_t * parent_ent;
+
+       res = _VVGC_lookup(dp, parent, &parent_ent, NULL);
+       if (res) {
+           code = res;
+           goto done;
+       }
+
+       /* if the mappings don't match, we have a serious error */
+       if (parent_ent != child_ent) {
+           ViceLog(0,
+                   ("VVGCache_entry_del: trying to delete vol %lu from VG %lu, "
+                    "but vol %lu points to VGC entry %" AFS_PTR_FMT
+                    " and VG %lu " "points to VGC entry %" AFS_PTR_FMT "\n",
+                    afs_printable_uint32_lu(child),
+                    afs_printable_uint32_lu(parent),
+                    afs_printable_uint32_lu(child), child_ent,
+                    afs_printable_uint32_lu(parent), parent_ent));
+           code = -1;
+           goto done;
+       }
     }
 
     code = _VVGC_hash_entry_del(child_hent);
index 509eade..5fb0c69 100644 (file)
@@ -452,8 +452,8 @@ _VVGC_dlist_lookup_r(struct DiskPartition64 *dp, VolumeId parent,
     for (queue_Scan(&VVGCache.part[dp->index].dlist_hash_buckets[bucket],
                     ent, nent,
                    VVGCache_dlist_entry)) {
-
-       if (ent->child == child && ent->parent == parent) {
+       if (ent->child == child
+           && (ent->parent == 0 || ent->parent == parent)) {
            return ent;
        }
     }
@@ -501,7 +501,7 @@ _VVGC_flush_dlist(struct DiskPartition64 *dp)
  * back onto the VGC.
  *
  * @param[in] dp      the partition to whose dlist we are adding
- * @param[in] parent  the parent volumeID of the VGC entry
+ * @param[in] parent  the parent volumeID of the VGC entry, or 0 for any
  * @param[in] child   the child volumeID of the VGC entry
  *
  * @return operation status
@@ -525,7 +525,7 @@ _VVGC_dlist_add_r(struct DiskPartition64 *dp, VolumeId parent,
     }
 
     entry->child = child;
-    entry->parent = parent;
+    entry->parent = parent; /* May be zero to match any child. */
 
     queue_Append(&VVGCache.part[dp->index].dlist_hash_buckets[bucket],
                  entry);
index dbdf10f..d5b8d8d 100644 (file)
@@ -670,9 +670,6 @@ VCreateVolumeDiskHeader(VolumeDiskHeader_t * hdr,
  * @return operation status
  *    @retval 0 success
  *
- * @note if parent is 0, the parent volume ID will be looked up from the
- * fileserver
- *
  * @note for non-DAFS, parent is currently ignored
  */
 afs_int32
@@ -695,22 +692,8 @@ VDestroyVolumeDiskHeader(struct DiskPartition64 * dp,
     }
 
 #ifdef AFS_DEMAND_ATTACH_FS
+    /* Remove the volume entry from the fileserver's volume group cache, if found. */
     memset(&res, 0, sizeof(res));
-    if (!parent) {
-       FSSYNC_VGQry_response_t q_res;
-
-       code = FSYNC_VGCQuery(dp->name, volid, &q_res, &res);
-       if (code) {
-           Log("VDestroyVolumeDiskHeader: FSYNC_VGCQuery(%s, %lu) failed "
-               "with code %ld, reason %ld\n", dp->name,
-               afs_printable_uint32_lu(volid), afs_printable_int32_ld(code),
-               afs_printable_int32_ld(res.hdr.reason));
-           goto done;
-       }
-
-       parent = q_res.rw;
-
-    }
     code = FSYNC_VGCDel(dp->name, parent, volid, FSYNC_WHATEVER, &res);
     if (code) {
        Log("VDestroyVolumeDiskHeader: FSYNC_VGCDel(%s, %" AFS_VOLID_FMT ", %" AFS_VOLID_FMT ") failed "