Skip to content

vfs: fetch stat in PseudoFs access check only when required - #184

Merged
kofemann merged 1 commit into
dCache:masterfrom
iterate-ch:vfs-pseudofs-lazy-stat
Nov 2, 2026
Merged

kofemann merged 1 commit into
dCache:masterfrom
iterate-ch:vfs-pseudofs-lazy-stat

Conversation

@ylangisc

@ylangisc ylangisc commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Motivation

PseudoFs#checkAccess fetches the inode's stat from the inner file system up front, as the stat is needed for the unix permission check. That check is the last resort though: it's skipped when the export has the all_root option or when the file system's AclCheckable grants or denies the access. In these cases the stat is fetched for nothing, costing an extra getattr on the inner file system for every LOOKUP (stat of the parent directory) and every ACL read.

For file systems where getattr is not a cheap local call this adds up quickly when listing large directories. dc8d38d already removed the fetch for ACE4_READ_ATTRIBUTES; this change covers the remaining cases without changing semantics.

Modification

Pass a null stat from the convenience overload and fetch it right before the unix permission check, if the caller hasn't provided one. access, which already has the stat at hand, passes it as before.

Tests added: no getattr on the inner file system when the AclCheckable allows the access or the export has all_root; getattr is still performed when the unix permission check is reached.

Result

No extra getattr on the inner file system when all_root or the AclCheckable decides the access. Behaviour is unchanged otherwise, including the error returned when the access is denied.

Fixes: #183
Target: master

Motivation:
PseudoFs#checkAccess fetches the inode's stat from the inner file system
before evaluating the access request, as the stat is needed for the unix
permission check. However, that check is the last resort and is skipped
when the export has the all_root option or the file system's AclCheckable
grants or denies the access. In these cases the stat is fetched for
nothing, which costs an extra getattr on the inner file system for every
LOOKUP (stat of the parent) and every ACL read.

Modification:
Pass a null stat from the convenience overload and fetch it right before
the unix permission check, if the caller hasn't provided one. The access
operation, which already has the stat at hand, passes it as before.

Result:
No extra getattr on the inner file system when all_root or the
AclCheckable decides the access. Behaviour is unchanged otherwise.

Fixes: dCache#183
Target: master
Signed-off-by: Yves Langisch <yla@iterate.ch>
@kofemann

kofemann commented Nov 2, 2026

Copy link
Copy Markdown
Member

@ylangisc, thanks for your contribution

@kofemann
kofemann merged commit 5288ba6 into dCache:master Nov 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PseudoFs fetches the stat for the access check even when it isn't needed

2 participants