vos: Avoid 'vos zap' warning on unrelated VL sites

vos zap currently prints a warning message when a VLDB entry is found
for the volume being zapped:

    $ vos zap fs.example.com vicepa 1234
    Warning: Entry for volume number 1234 exists in VLDB (but we're zapping it anyway!)

However, vos only checks whether the VLDB entry exists at all, and
doesn't check the location being zapped. If the VLDB entry exists, but
it does not reference the specific server and partition being zapped,
the warning message is still printed, which is confusing.

Update vos zap to print the warning message only when zapping a location
that exists in the VLDB entry, and to print the location we checked. The
warning now looks like:

    $ vos zap fs.example.com vicepa 1234
    Warning: Entry for volume 1234 on server fs.example.com /vicepa exists in VLDB (but we're zapping it anyway!)

Change-Id: I382d9b3a5960deb06e7774b8ab6a8b36b92cc0a6
Reviewed-on: https://gerrit.openafs.org/15849
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
This commit is contained in:
Michael Meffie 2024-09-11 20:08:35 -04:00 committed by Andrew Deason
parent d86c4d632e
commit f695cfbcab
4 changed files with 33 additions and 3 deletions

View File

@ -7,6 +7,7 @@ AFSVolPartitionInfo64
AFSVolTransCreate
AFSVolXListPartitions
EnumerateEntry
Lp_AnyMatch
Lp_GetRwIndex
Lp_ROMatch
MapHostToNetwork

View File

@ -125,6 +125,26 @@ Lp_ROMatch(afs_uint32 server, afs_int32 part, struct nvldbentry *entry)
return (FindIndex(entry, server, part, VLSF_ROVOL) + 1);
}
/**
* Check if this server and partition matches any volume type.
*
* @param server server address in network byte order
* @param part partition number
* @param entry VLDB entry in network byte order
*
* @return whether the given server and partition is present in the VLDB entry
* @retval 1 The server and partition is present.
* @retval 0 The server and partition is not present.
*/
int
Lp_AnyMatch(afs_uint32 server, afs_int32 part, struct nvldbentry *entry)
{
if (FindIndex(entry, server, part, 0) == -1) {
return 0;
}
return 1;
}
/* Return the index of the RW entry if it exists, else return -1 */
int
Lp_GetRwIndex(struct nvldbentry *entry)

View File

@ -6,6 +6,7 @@ extern void Lp_SetROValue(struct nvldbentry *entry, afs_uint32 oserver,
afs_int32 opart, afs_uint32 nserver, afs_int32 npart);
extern int Lp_Match(afs_uint32 server, afs_int32 part, struct nvldbentry *entry);
extern int Lp_ROMatch(afs_uint32 server, afs_int32 part, struct nvldbentry *entry);
extern int Lp_AnyMatch(afs_uint32 server, afs_int32 part, struct nvldbentry *entry);
extern int Lp_GetRwIndex(struct nvldbentry *entry);
extern void Lp_QInit(struct qHead *ahead);
extern void Lp_QAdd(struct qHead *ahead, struct aqueue *elem);

View File

@ -3988,9 +3988,17 @@ VolumeZap(struct cmd_syndesc *as, void *arock)
if (!code) {
if (volid == entry.volumeId[RWVOL])
backupid = entry.volumeId[BACKVOL];
fprintf(STDERR,
"Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
(unsigned long)volid);
MapHostToNetwork(&entry);
if (Lp_AnyMatch(server, part, &entry)) {
char pname[16];
MapPartIdIntoName(part, pname);
fprintf(STDERR,
"Warning: Entry for volume %lu on server %s %s exists "
"in VLDB (but we're zapping it anyway!)\n",
(unsigned long)volid,
hostutil_GetNameByINet(server),
pname);
}
}
if (zapbackupid) {
volintInfo *pntr = (volintInfo *) 0;