Skip to content

Commit

Permalink
Enforce dirent count limit [FS-1222] (#527)
Browse files Browse the repository at this point in the history
... to prevent painful site outages.  Follow-up to FS-1111.
  • Loading branch information
djschaap committed Aug 19, 2024
1 parent 9f8be35 commit bea41f8
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/fusedav.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,14 +1396,9 @@ static int dav_mkdir(const char *path, mode_t mode) {
} else {
direntcnt = log_dirent_count(config->cache, parentpath);
if(direntcnt > MAX_DIRENTS_IN_DIR) {
log_print(LOG_WARNING, SECTION_FUSEDAV_DIR, "dav_mkdir: %s; dirent count (%u) above threshold for %s", path, direntcnt, parentpath);
// TODO: This is currently just logging but not preventing the dav_mkdir operation.
// Once we are confident on the decision to go ahead with blocking the writes,
// uncomment/modify the code below to enforce it.

// log_print(LOG_WARNING, SECTION_FUSEDAV_DIR, "dav_mkdir: %s aborted; dirent count (%u) above threshold for %s", path, direntcnt, parentpath);
// g_set_error(&gerr, fusedav_quark(), ENOSPC, "aborted; dirent count above threshold");
// return processed_gerror("dav_mkdir: ", path, &gerr);
log_print(LOG_WARNING, SECTION_FUSEDAV_DIR, "dav_mkdir: %s aborted; dirent count (%u) above threshold for %s", path, direntcnt, parentpath);
g_set_error(&gerr, fusedav_quark(), ENOSPC, "aborted; dirent count above threshold");
return processed_gerror("dav_mkdir: ", path, &gerr);
}
}
free(parentpath);
Expand Down Expand Up @@ -2170,14 +2165,9 @@ static int dav_create(const char *path, mode_t mode, struct fuse_file_info *info
} else {
direntcnt = log_dirent_count(config->cache, parentpath);
if(direntcnt > MAX_DIRENTS_IN_DIR) {
log_print(LOG_WARNING, SECTION_FUSEDAV_FILE, "dav_create: %s; dirent count (%u) above threshold for %s", path, direntcnt, parentpath);
// TODO: This is currently just logging but not preventing the dav_create operation.
// Once we are confident on the decision to go ahead with blocking the writes,
// uncomment/modify the code below to enforce it.

// log_print(LOG_WARNING, SECTION_FUSEDAV_FILE, "dav_create: %s aborted; dirent count (%u) above threshold for %s", path, direntcnt, parentpath);
// g_set_error(&gerr, fusedav_quark(), ENOSPC, "aborted; dirent count above threshold");
// return processed_gerror("dav_create: ", path, &gerr);
log_print(LOG_WARNING, SECTION_FUSEDAV_FILE, "dav_create: %s aborted; dirent count (%u) above threshold for %s", path, direntcnt, parentpath);
g_set_error(&gerr, fusedav_quark(), ENOSPC, "aborted; dirent count above threshold");
return processed_gerror("dav_create: ", path, &gerr);
}
}
free(parentpath);
Expand Down

0 comments on commit bea41f8

Please sign in to comment.