]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fuse: reduce attributes invalidated on directory change
authorKonrad Sztyber <ksztyber@nvidia.com>
Tue, 14 Apr 2026 08:27:23 +0000 (10:27 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Mon, 15 Jun 2026 12:06:18 +0000 (14:06 +0200)
When the contents of a directory is modified, some of its attributes may
also change, so they need to be invalidated.  But this isn't the case
for every attribute.  For instance, unlinking or creating a file doesn't
change the uid/gid of its parent directory.

This can cause unnecessary FUSE_GETATTRs to be sent to user-space.  For
example, fuse_permission() checks if mode, uid, and gid are valid and
will issue a FUSE_GETATTR if they're not, which results in an extra
FUSE_GETATTR request for every FUSE_UNLINK when removing files in the
same directory.

Signed-off-by: Konrad Sztyber <ksztyber@nvidia.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dir.c
fs/fuse/fuse_i.h

index 2872e068c31784179164ecf136bf9a693c9fc11a..1b71fb5adc019d9490e56534e883ef0ac625a626 100644 (file)
@@ -318,7 +318,7 @@ void fuse_invalidate_attr(struct inode *inode)
 
 static void fuse_dir_changed(struct inode *dir)
 {
-       fuse_invalidate_attr(dir);
+       fuse_invalidate_attr_mask(dir, FUSE_STATX_MODDIR);
        inode_maybe_inc_iversion(dir, false);
 }
 
index 93087fc049752718888aa670c027fcc2b59aaf48..3a7ac74a23ed6904539b6e8c019b84b5c5aaae20 100644 (file)
@@ -1034,6 +1034,9 @@ void fuse_epoch_work(struct work_struct *work);
 /* Attributes possibly changed on data and/or size modification */
 #define FUSE_STATX_MODSIZE     (FUSE_STATX_MODIFY | STATX_SIZE)
 
+/* Attributes possibly changed on directory modification */
+#define FUSE_STATX_MODDIR      (FUSE_STATX_MODSIZE | STATX_NLINK)
+
 void fuse_invalidate_attr(struct inode *inode);
 void fuse_invalidate_attr_mask(struct inode *inode, u32 mask);