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);
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;
}
}
* 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
}
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);
* @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
}
#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 "