From eae47958eff95e8995e3846696d9d390e1b24b38 Mon Sep 17 00:00:00 2001 From: mufucaw Date: Mon, 19 Dec 2022 12:48:53 -0800 Subject: [PATCH] Try a simple local stat instead. --- src/filecache.c | 13 +++++++++---- src/stats.c | 5 ----- src/stats.h | 2 -- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/filecache.c b/src/filecache.c index e925652d..3b93c25b 100644 --- a/src/filecache.c +++ b/src/filecache.c @@ -164,9 +164,14 @@ struct curl_slist* enhanced_logging(struct curl_slist *slist, int log_level, int // creates a new cache file static void new_cache_file(const char *cache_path, char *cache_file_path, fd_t *fd, GError **gerr) { char entropy[CACHE_FILE_ENTROPY + 1]; + const float samplerate = 1.0; // REMOVE after testing BUMP(filecache_cache_file); + // For testing purposes ONLY, remove before merging! + stats_counter("unexpected-not-found", 1, samplerate); + log_print(LOG_WARNING, SECTION_FUSEDAV_STAT, "Encountered an unexpected 404/410"); + for (size_t pos = 0; pos <= CACHE_FILE_ENTROPY; ++pos) { entropy[pos] = 65 + rand() % 26; } @@ -614,9 +619,6 @@ static void get_fresh_fd(filecache_t *cache, bool unlink_old = false; const float samplerate = 1.0; // always sample stat - // For testing purposes ONLY, remove before merging! - BUMP(conflicting_404); - if (pdata == NULL) { *pdatap = calloc(1, sizeof(struct filecache_pdata)); pdata = *pdatap; @@ -755,10 +757,13 @@ static void get_fresh_fd(filecache_t *cache, * Not sure how to remediate without doing way more work and * introducing way more problems than the fix will fix. */ + const float samplerate = 1.0; // always sample stat + stats_counter("unexpected-not-found", 1, samplerate); + log_print(LOG_WARNING, SECTION_FUSEDAV_STAT, "Encountered an unexpected 404/410: Repsonse code: %u: ", response_code); + struct stat_cache_value *value; g_set_error(gerr, filecache_quark(), ENOENT, "%s: File %s expected to exist returns %ld.", funcname, path, response_code); - BUMP(conflicting_404); /* we get a 404 because the stat_cache returned that the file existed, but it * was not on the server. Deleting it from the stat_cache makes the stat_cache * consistent, so the next access to the file will be handled correctly. diff --git a/src/stats.c b/src/stats.c index f18fb0c1..2574ff19 100644 --- a/src/stats.c +++ b/src/stats.c @@ -300,11 +300,6 @@ void dump_stats(bool log, const char *cache_path) { print_line(log, fd, LOG_NOTICE, SECTION_FILECACHE_OUTPUT, str); } - snprintf(str, MAX_LINE_LEN, "Notable Events:"); - print_line(log, fd, LOG_NOTICE, SECTION_FUSEDAV_OUTPUT, str); - snprintf(str, MAX_LINE_LEN, " conflicting 404: %u", FETCH(conflicting_404)); - print_line(log, fd, LOG_NOTICE, SECTION_FUSEDAV_OUTPUT, str); - snprintf(str, MAX_LINE_LEN, "Stat Cache Operations:"); print_line(log, fd, LOG_NOTICE, SECTION_STATCACHE_OUTPUT, str); snprintf(str, MAX_LINE_LEN, " local_gen: %u", FETCH(statcache_local_gen)); diff --git a/src/stats.h b/src/stats.h index 1b8b2d60..d2a33ece 100644 --- a/src/stats.h +++ b/src/stats.h @@ -46,8 +46,6 @@ struct statistics { unsigned propfind_progressive_cache; unsigned propfind_complete_cache; - unsigned conflicting_404; - unsigned filecache_cache_file; unsigned filecache_pdata_set; unsigned filecache_create_file;