Cap getdents64 requests at 128 KiB for virtiofs compatibility

This commit is contained in:
Antonio SJ Musumeci 2026-11-05 15:55:28 -06:00 • committed by trapexit
parent bdfbedad8b
commit 2513d3c067
2 changed files with 9 additions and 1 deletions

View file

@ -39,5 +39,9 @@ situations.
[readdir](https://man7.org/linux/man-pages/man2/readdir.2.html) in
order to leverage larger buffers for better performance on larger
directory reads as well as have more control in concurrent policies.
Individual branch `getdents64` requests are capped at 128 KiB to work
around problems with larger requests on virtiofs. This applies to
`seq`, `cosr`, and `cor`; it does not limit the total directory listing
or change [fuse-msg-size](fuse-msg-size.md).
* [readdir](https://man7.org/linux/man-pages/man2/readdir.2.html) is
used on FreeBSD.

View file

@ -18,6 +18,7 @@
#include "to_neg_errno.hpp"
#include <algorithm>
#include <sys/types.h>
#if defined __linux__
@ -36,7 +37,10 @@ namespace fs
#if defined SYS_getdents64
ssize_t rv;
rv = ::syscall(SYS_getdents64,fd_,dirp_,count_);
// Avoid oversized requests on virtiofs-backed branches.
const size_t count = std::min<size_t>(count_,128 * 1024);
rv = ::syscall(SYS_getdents64,fd_,dirp_,count);
return ::to_neg_errno(rv);
#else