exfat: reuse valid negative dentries for file creation
Subsystems (2)
PATCH 1/2 exfat: reuse valid negative dentries for file creation
exfat does not generate FAT-style 8.3 aliases, so LOOKUP_CREATE does not need to unconditionally invalidate negative dentries.
Use the parent i_version check instead, avoiding a redundant directory scan when an existence check is followed by file creation. Keep LOOKUP_RENAME_TARGET unchanged.
Signed-off-by Yang Wen <[email protected]>
--- fs/exfat/namei.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
fs/exfat/namei.c +4 -7
@@ -24,12 +24,9 @@ static inline void exfat_d_version_set(struct dentry *dentry, }/* -* If new entry was created in the parent, it could create the 8.3 alias (the -* shortname of logname). So, the parent may have the negative-dentry which -* matches the created 8.3 alias. -* -* If it happened, the negative dentry isn't actually negative anymore. So, -* drop it. +* exFAT has no FAT-style 8.3 alias entries. A negative dentry can therefore +* be reused for creation as long as the parent directory version did not +* change since the lookup that created it. */ static int exfat_d_revalidate (struct inode *dir,const struct qstr *name,struct dentry *dentry,unsigned int flags)
@@ -54,7 +51,7 @@ static int exfat_d_revalidate(struct inode *dir, const struct qstr *name,* Drop the negative dentry, in order to make sure to use the case * sensitive name which is specified by user if this is for creation. */ -if (flags & (LOOKUP_CREATE |LOOKUP_RENAME_TARGET )) +if (flags &LOOKUP_RENAME_TARGET )return 0 ;return inode_eq_iversion (dir,exfat_d_version (dentry));
Signature · 1 line
2.34.1
Namjae Jeon
maintainerQuoted 21 lines
fs/exfat/namei.c +3
-6@@ -24,12 +24,9 @@ static inline void exfat_d_version_set(struct dentry *dentry, }/* -* If new entry was created in the parent, it could create the 8.3 alias (the -* shortname of logname). So, the parent may have the negative-dentry which -* matches the created 8.3 alias. -* -* If it happened, the negative dentry isn't actually negative anymore. So, -* drop it. +* exFAT has no FAT-style 8.3 alias entries. A negative dentry can therefore +* be reused for creation as long as the parent directory version did not +* change since the lookup that created it. */ static int exfat_d_revalidate (struct inode *dir,const struct qstr *name,struct dentry *dentry,unsigned int flags)
fs/exfat/namei.c static int exfat_d_revalidate(struct inode *dir, const struct qstr *name, · line 54
Quoted 5 lines
fs/exfat/namei.c +1
-1@@ -54,7 +51,7 @@ static int exfat_d_revalidate(struct inode *dir, const struct qstr *name,* Drop the negative dentry, in order to make sure to use the case * sensitive name which is specified by user if this is for creation. */ -if (flags & (LOOKUP_CREATE |LOOKUP_RENAME_TARGET )) +if (flags &LOOKUP_RENAME_TARGET )
Removing LOOKUP_CREATE breaks case-preserving creation.
$ stat foo 2>/dev/null || true
$ touch FOO
$ ls
fooThe cached negative dentry for "foo" is reused for "FOO". I think only the obsolete 8.3 alias comment should be updated, while keeping the LOOKUP_CREATE check.