From: Michael Meffie Date: Thu, 21 Dec 2017 16:59:38 +0000 (-0500) Subject: vol: avoid query for parent id when deleting disk header X-Git-Tag: openafs-devel-1_9_0~407 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=65b55bcc26f69f25c67518f672b34be73f3be370;hp=2f2c2ce62aa17ecac3651d64c1168af926f7458b vol: avoid query for parent id when deleting disk header 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. Change-Id: Iee8647902d93a3c992fca4c4f3880a3393f0b95f Reviewed-on: https://gerrit.openafs.org/12839 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- diff --git a/src/vol/vg_cache.c b/src/vol/vg_cache.c index 307b358..5a53a2f 100644 --- a/src/vol/vg_cache.c +++ b/src/vol/vg_cache.c @@ -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); diff --git a/src/vol/vg_scan.c b/src/vol/vg_scan.c index 509eade..5fb0c69 100644 --- a/src/vol/vg_scan.c +++ b/src/vol/vg_scan.c @@ -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); diff --git a/src/vol/vutil.c b/src/vol/vutil.c index cafed4d..96c6eed 100644 --- a/src/vol/vutil.c +++ b/src/vol/vutil.c @@ -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 "