Skip to content

Commit

Permalink
Try a simple local stat instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
mufucaw committed Dec 19, 2022
1 parent 6b46e43 commit eae4795
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 9 additions & 4 deletions src/filecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 0 additions & 2 deletions src/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit eae4795

Please sign in to comment.