fuse: back uncached readdir buffers with pages#1427
Open
vfsci-bot[bot] wants to merge 1 commit into
Open
Conversation
Commit dabb903 ("fuse: increase readdir buffer size") changed fuse_readdir_uncached() to size its temporary buffer from ctx->count. This is useful for overlayfs and other in-kernel callers that use INT_MAX to indicate an unlimited directory read. The buffer is capped by fc->max_pages converted to bytes with PAGE_SIZE. However, fc->max_pages is a page-count limit, not a byte-sized payload limit. READDIR is a read-side operation, so include fc->max_read in the cap. Also keep fc->max_write in the cap: it is the daemon-advertised byte-sized payload limit relevant to virtiofs in the failing configuration, while fc->max_read can remain effectively unlimited there. The larger buffer is also currently supplied as a kvec output argument. For virtiofs, kvec arguments are copied through req->argbuf, which is allocated with kmalloc(..., GFP_ATOMIC). A large readdir buffer can therefore require a multi-megabyte contiguous atomic allocation and fail with -ENOMEM. This was observed with a 64K-page guest on a 4K-page host, using an overlayfs mount whose lower directory is on virtiofs. Reading a merged directory through overlayfs failed with: ls: reading directory '<path>': Cannot allocate memory Avoid the oversized request and the large bounce-buffer allocation by capping the requested byte size by fc->max_pages, fc->max_read, and fc->max_write, then backing the uncached readdir output with pages and setting out_pages. The virtiofs transport can then pass the pages as scatter-gather entries instead of copying the output through argbuf. Map the pages with vm_map_ram() only while parsing the returned dirents, so the existing parser can continue to operate on a linear kernel mapping. Fixes: dabb903 ("fuse: increase readdir buffer size") Cc: stable@vger.kernel.org Signed-off-by: Matthew R. Ochs <mochs@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Series: https://patchwork.kernel.org/project/linux-fsdevel/list/?series=1096931
Submitter: Matthew R. Ochs
Version: 3
Patches: 1/1
Message-ID:
<20260519004746.3203156-1-mochs@nvidia.com>Base: vfs.base.ci
Lore: https://lore.kernel.org/linux-fsdevel/20260519004746.3203156-1-mochs@nvidia.com
Automated by ml2pr