diff --git a/mkdocs/docs/config/func_readdir.md b/mkdocs/docs/config/func_readdir.md index e8d3ba57..1a928daf 100644 --- a/mkdocs/docs/config/func_readdir.md +++ b/mkdocs/docs/config/func_readdir.md @@ -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. diff --git a/src/fs_getdents64.cpp b/src/fs_getdents64.cpp index 054e8046..770cc45c 100644 --- a/src/fs_getdents64.cpp +++ b/src/fs_getdents64.cpp @@ -18,6 +18,7 @@ #include "to_neg_errno.hpp" +#include #include #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(count_,128 * 1024); + + rv = ::syscall(SYS_getdents64,fd_,dirp_,count); return ::to_neg_errno(rv); #else