From 1073e9477950a5b73ec60226c91a0f1ba1e3e493 Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Wed, 9 Sep 2020 17:22:44 -0400 Subject: [PATCH] volser: remove check for VL_ENTDELETED Since the original IBM code import, UV_RestoreVolume2 (originally UV_RestoreVolume) has checked for VL_ENTDELETED from VLDB_GetEntryByID. However, if VL_ENTDELETED is received, we will act like we retrieved the vlentry successfully. If the -verbose flag is given, we'll try to print the entry (even though one was not returned), and we'll call VL_SetLock for the volume, which will almost certainly also fail with VL_ENTDELETED and bail out. Furthermore (also since the original IBM import), there is no longer any code path to set the volume entry flag VLDELETED. So it should be rare for any VL_* RPC to return VL_ENTDELETED; that would require an entry to have the VLDELETED flag carried over from a very old database. Therefore, it is safe and reasonable to simply remove the check for VL_ENTDELETED from UV_RestoreVolume2. If we do somehow receive the VL_ENTDELETED error code, vos will terminate with an error instead of possibly printing an uninitialized entry. In addition, remove the same check for VL_ENTDELETED in the equivalent code path in libadmin's UV_RestoreVolume. Change-Id: I11d1c3306f67d68de54780f6aac75e4c27779db4 Reviewed-on: https://gerrit.openafs.org/14357 Reviewed-by: Michael Meffie Reviewed-by: Andrew Deason Tested-by: Andrew Deason --- src/libadmin/vos/vsprocs.c | 2 +- src/volser/vsprocs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libadmin/vos/vsprocs.c b/src/libadmin/vos/vsprocs.c index 67bd35ab09..c1172bce62 100644 --- a/src/libadmin/vos/vsprocs.c +++ b/src/libadmin/vos/vsprocs.c @@ -2306,7 +2306,7 @@ UV_RestoreVolume(afs_cell_handle_p cellHandle, afs_int32 toserver, * VLDB to reflect the change. */ aVLDB_GetEntryByID(cellHandle, pvolid, RWVOL, &entry, &tst); - if (tst && tst != VL_NOENT && tst != VL_ENTDELETED) { + if (tst != 0 && tst != VL_NOENT) { goto fail_UV_RestoreVolume; } if (tst == VL_NOENT) { /* it doesnot exist already */ diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c index 225472df9c..5bc899553a 100644 --- a/src/volser/vsprocs.c +++ b/src/volser/vsprocs.c @@ -4676,7 +4676,7 @@ UV_RestoreVolume2(afs_uint32 toserver, afs_int32 topart, afs_uint32 tovolid, * VLDB to reflect the change. */ vcode = VLDB_GetEntryByID(pvolid, voltype, &entry); - if (vcode && vcode != VL_NOENT && vcode != VL_ENTDELETED) { + if (vcode != 0 && vcode != VL_NOENT) { fprintf(STDERR, "Could not fetch the entry for volume number %lu from VLDB \n", (unsigned long)pvolid);