Commit 0906fbb
committed
libfs: Attempt exact-match comparison first during casefolded lookup
Casefolded comparisons are (obviously) way more costly than a simple
memcmp. Try the case-sensitive comparison first, falling-back to the
case-insensitive lookup only when needed. This allows any exact-match
lookup to complete without having to walk the utf8 trie.
Note that, for strict mode, generic_ci_d_compare used to reject an
invalid UTF-8 string, which would now be considered valid if it
exact-matches the disk-name. But, if that is the case, the filesystem
is corrupt. More than that, it really doesn't matter in practice,
because the name-under-lookup will have already been rejected by
generic_ci_d_hash and we won't even get here.
The memcmp is safe under RCU because we are operating on str/len instead
of dentry->d_name directly, and the caller guarantees their consistency
between each other in __d_lookup_rcu_op_compare.
Link: https://lore.kernel.org/r/87ttn2sip7.fsf_-_@mailhost.krisman.be
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>1 parent 052d534 commit 0906fbb
1 file changed
Lines changed: 23 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1704 | 1704 | | |
1705 | 1705 | | |
1706 | 1706 | | |
1707 | | - | |
1708 | | - | |
1709 | | - | |
1710 | | - | |
1711 | | - | |
| 1707 | + | |
| 1708 | + | |
1712 | 1709 | | |
1713 | | - | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
1714 | 1723 | | |
| 1724 | + | |
| 1725 | + | |
1715 | 1726 | | |
1716 | | - | |
| 1727 | + | |
| 1728 | + | |
1717 | 1729 | | |
1718 | 1730 | | |
1719 | 1731 | | |
| |||
1724 | 1736 | | |
1725 | 1737 | | |
1726 | 1738 | | |
1727 | | - | |
| 1739 | + | |
1728 | 1740 | | |
1729 | 1741 | | |
1730 | 1742 | | |
1731 | | - | |
1732 | | - | |
1733 | | - | |
| 1743 | + | |
| 1744 | + | |
1734 | 1745 | | |
1735 | | - | |
1736 | | - | |
1737 | | - | |
1738 | | - | |
1739 | | - | |
1740 | | - | |
| 1746 | + | |
1741 | 1747 | | |
1742 | 1748 | | |
1743 | 1749 | | |
| |||
0 commit comments