Skip to contentSkip to conversation

fuse: reduce attributes invalidated on directory change

PATCH In review Konrad Sztyber 2 participants 2 messages Apr 14 – Apr 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: reduce attributes invalidated on directory change

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.

---
 fs/fuse/dir.c    | 2 +-
 fs/fuse/fuse_i.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
fs/fuse/dir.c +1 -1
index 7ac6b232ef12..fc4ae408a9cf 100644
@@ -317,7 +317,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);
 }
 
fs/fuse/fuse_i.h +3 -0
index 7f16049387d1..18ebb2ab3dd9 100644
@@ -1305,6 +1305,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);
 
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 6 lines · Konrad Sztyber

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.

Quoted 7 lines

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.

Makes sense, applied.

Thanks,
Miklos