From 3e3fce24da31a31ca9a3f4ad356c4e4eaf0ad897 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Mon, 12 Nov 2018 15:01:18 -0600 Subject: [PATCH] vlserver: Warn when we cannot unhash deleted entry If we are trying to delete an entry from the vldb, we fail with VL_NOENT if we cannot find the given entry on one of its hash chains. This is indicative of corruption in the vldb (since we have an entry not on a hash chain), but we don't really indicate this clearly. There are no log messages, and the user running 'vos' only sees an error like this: $ vos delentry 123456 Could not delete entry for volume 123456 You must specify a RW volume name or ID (the entire VLDB entry will be deleted) VLDB: no such entry Deleted 0 VLDB entries Which is the exact same error message if the user tries to delete a volume that does not actually exist. We currently do not have an error code that clearly says that the database appears corrupted and needs to be fixed, but we can at least log an error in VLLog for this case, to give the administrator a chance at fixing the situation. So, log a message in this situation. Change-Id: I4f0ee8749a90441e1f8d779890293dc5d1d9dbee Reviewed-on: https://gerrit.openafs.org/13382 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/vlserver/vlutils.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/vlserver/vlutils.c b/src/vlserver/vlutils.c index d11917f..23bd838 100644 --- a/src/vlserver/vlutils.c +++ b/src/vlserver/vlutils.c @@ -894,13 +894,28 @@ UnthreadVLentry(struct vl_ctx *ctx, afs_int32 blockindex, /* Take the RO/RW entries of their respective hash linked lists. */ for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) { - if ((errorcode = UnhashVolid(ctx, typeindex, blockindex, aentry))) + if ((errorcode = UnhashVolid(ctx, typeindex, blockindex, aentry))) { + if (errorcode == VL_NOENT) { + VLog(0, ("Unable to unhash vlentry '%s' (address %d) from hash " + "chain for volid %u (type %d).\n", + aentry->name, blockindex, aentry->volumeId[typeindex], typeindex)); + VLog(0, ("... The VLDB may be partly corrupted; see vldb_check " + "for how to check for and fix errors.\n")); + } return errorcode; + } } /* Take it out of the Volname hash list */ - if ((errorcode = UnhashVolname(ctx, blockindex, aentry))) + if ((errorcode = UnhashVolname(ctx, blockindex, aentry))) { + if (errorcode == VL_NOENT) { + VLog(0, ("Unable to unhash vlentry '%s' (address %d) from name " + "hash chain.\n", aentry->name, blockindex)); + VLog(0, ("... The VLDB may be partly corrupted; see vldb_check " + "for how to check for and fix errors.\n")); + } return errorcode; + } /* Update cheader entry */ write_vital_vlheader(ctx); -- 1.9.4