diff options
| author | Joseph Qi <joseph.qi@linux.alibaba.com> | 2026-10-08 20:27:42 +0800 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-08 23:06:53 -0700 |
| commit | d0f77a722746c9cb2153dc9c275f5c1218ffa841 (patch) | |
| tree | 70494946a8263233e3281a27c0832e6874a867b3 /tools/lib/python/kdoc/python_version.py | |
| parent | 9463bc0691968a3c7e21f2a02f62e7868eb8f13e (diff) | |
| download | linux-next-d0f77a722746c9cb2153dc9c275f5c1218ffa841.tar.gz linux-next-d0f77a722746c9cb2153dc9c275f5c1218ffa841.zip | |
ocfs2: deal with legacy signed dir index name hash values
Commit 3bc753c06dd0 ("kbuild: treat char as always unsigned") set
-funsigned-char globally, which changed the result of the naked 'char'
load in str2hashbuf():
val = msg[i] + (val << 8);
A name byte >= 0x80 used to sign-extend and now zero-extends, so
ocfs2_dx_dir_name_hash() computes a different hash pair for every name
containing one. The pair is written into the dx leaf when the entry is
created, so an index built by an older kernel no longer matches and
ocfs2_dx_dir_search() returns -ENOENT for a name that readdir still lists.
Search with the current unsigned hash and, on a miss, retry with the
legacy signed one, as ext4 does in commit f3bbac32475b2 ("ext4: deal with
legacy signed xattr name hash values"). New entries are always indexed
under the unsigned hash. Skip the retry when the two hashes are equal, so
that a miss on an ASCII name does not walk the index twice.
The retry costs a second walk of the dx tree, so a negative lookup of a
name containing a byte >= 0x80 does twice the work. That is bounded and
worth it, and directories whose dx root is still inline pay nothing extra,
since there the retry only rescans the root block that is already loaded.
Nothing retires it at runtime: a legacy entry keeps its legacy hash,
because neither deleting nor updating an entry rewrites the dx hash, and
the only code that rehashes existing dirents is ocfs2_expand_inline_dir()
on the inline to extent conversion. Rebuilding the index offline is what
removes the cost for good.
Also spell out the signedness in str2hashbuf() instead of leaving the
current hash to -funsigned-char, as commit 854f0912f813 ("ext4: make xattr
char unsignedness in hash explicit") did, so that both variants stay
correct if this is backported to a kernel without the flag.
Link: https://lore.kernel.org/20261008122743.616779-1-joseph.qi@linux.alibaba.com
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Anderson Ferneda <anderson.ferneda@braza.com.br>
Closes: https://lore.kernel.org/ocfs2-devel/CP5P284MB2780AC2C3C2AB2CF2B6CB7AFBE942@CP5P284MB2780.BRAP284.PROD.OUTLOOK.COM/
Exposed-by: 3bc753c06dd0 ("kbuild: treat char as always unsigned")
Reviewed-by: Heming Zhao <heming.zhao@suse.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: <stable@vger.kernel.org> # 6.2+
Diffstat (limited to 'tools/lib/python/kdoc/python_version.py')
0 files changed, 0 insertions, 0 deletions
