Skip to contentSkip to conversation

exfat: reuse valid negative dentries for file creation

PATCH Superseded Yang Wen 2 participants 2 messages Jun 10 – Jun 12

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yang Wen

author
#0 lore raw

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.

---
 fs/exfat/namei.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
fs/exfat/namei.c +4 -7
index b7d5e44ad38e..fe26fbf6a0f2 100644
@@ -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
maintainer
#1 lore raw
Quoted 21 lines
fs/exfat/namei.c +3 -6
index b7d5e44ad38e..fe26fbf6a0f2 100644
@@ -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
    foo

The 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.