From 7fee28bae30c5a65898a2e3fd7149f07e8ca0df6 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 3 Nov 2011 13:17:33 -0500 Subject: [PATCH] salvager: Implement AskDAFS via SYNC flags Instead of probing the DAFS-ness of the fileserver by probing which FSSYNC opcodes it supports, detect DAFS-ness by looking at the SYNC response header flags, which explicitly state whether or not the endpoint is DAFS. This avoids unnecessary "protocol mismatch" log messages when the endpoint is not DAFS. Change-Id: Ie05a587951d6d5f69ae03cf3749f8c53e1eb6b62 Reviewed-on: http://gerrit.openafs.org/5800 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/vol/vol-salvage.c | 45 +++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index b8c3f3e3c..097573fb0 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -165,6 +165,7 @@ Vnodes with 0 inode pointers in RW volumes are now deleted. #include "daemon_com.h" #include "daemon_com_inline.h" #include "fssync.h" +#include "fssync_inline.h" #include "volume_inline.h" #include "salvsync.h" #include "viceinode.h" @@ -4442,8 +4443,8 @@ static int isDAFS = -1; int AskDAFS(void) { - afs_int32 code, i, ret = 0; SYNC_response res; + afs_int32 code = 1, i; /* we don't care if we race. the answer shouldn't change */ if (isDAFS != -1) @@ -4451,35 +4452,29 @@ AskDAFS(void) memset(&res, 0, sizeof(res)); - for (i = 0; i < 3; i++) { - code = FSYNC_VolOp(1, NULL, - FSYNC_VOL_QUERY_VOP, FSYNC_SALVAGE, &res); - - if (code == SYNC_OK) { - ret = 1; - break; - } else if (code == SYNC_DENIED) { - ret = 1; - break; - } else if (code == SYNC_BAD_COMMAND) { - ret = 0; - break; - } else if (code == SYNC_FAILED) { - if (res.hdr.reason == FSYNC_UNKNOWN_VOLID) - ret = 1; - else - ret = 0; - break; - } else if (i < 2) { - /* try it again */ - Log("AskDAFS: request to query fileserver failed; trying again...\n"); + for (i = 0; code && i < 3; i++) { + code = FSYNC_VolOp(0, NULL, FSYNC_VOL_LISTVOLUMES, FSYNC_SALVAGE, &res); + if (code) { + Log("AskDAFS: FSYNC_VOL_LISTVOLUMES failed with code %ld reason " + "%ld (%s); trying again...\n", (long)code, (long)res.hdr.reason, + FSYNC_reason2string(res.hdr.reason)); FSYNC_clientFinis(); FSYNC_clientInit(); } } - isDAFS = ret; - return ret; + if (code) { + Log("AskDAFS: could not determine DAFS-ness, assuming not DAFS\n"); + res.hdr.flags = 0; + } + + if ((res.hdr.flags & SYNC_FLAG_DAFS_EXTENSIONS)) { + isDAFS = 1; + } else { + isDAFS = 0; + } + + return isDAFS; } static void -- 2.39.5