From f695cfbcaba6dec50e54b8d6e38f78cfa3ba586d Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Wed, 11 Sep 2024 20:08:35 -0400 Subject: [PATCH] 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 Reviewed-by: Cheyenne Wills Reviewed-by: Andrew Deason --- src/volser/liboafs_volser.la.sym | 1 + src/volser/lockprocs.c | 20 ++++++++++++++++++++ src/volser/lockprocs_prototypes.h | 1 + src/volser/vos.c | 14 +++++++++++--- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/volser/liboafs_volser.la.sym b/src/volser/liboafs_volser.la.sym index 31ace7fad6..7f9d9e0842 100644 --- a/src/volser/liboafs_volser.la.sym +++ b/src/volser/liboafs_volser.la.sym @@ -7,6 +7,7 @@ AFSVolPartitionInfo64 AFSVolTransCreate AFSVolXListPartitions EnumerateEntry +Lp_AnyMatch Lp_GetRwIndex Lp_ROMatch MapHostToNetwork diff --git a/src/volser/lockprocs.c b/src/volser/lockprocs.c index 691a523138..0fed579bb7 100644 --- a/src/volser/lockprocs.c +++ b/src/volser/lockprocs.c @@ -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) diff --git a/src/volser/lockprocs_prototypes.h b/src/volser/lockprocs_prototypes.h index 67bb14cfc9..fa67c71850 100644 --- a/src/volser/lockprocs_prototypes.h +++ b/src/volser/lockprocs_prototypes.h @@ -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); diff --git a/src/volser/vos.c b/src/volser/vos.c index 42bfebcdc4..3b658c972d 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -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;