]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
repair: don't duplicate names in phase 6
authorDave Chinner <dchinner@redhat.com>
Thu, 15 Apr 2021 19:44:49 +0000 (15:44 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Thu, 15 Apr 2021 19:44:49 +0000 (15:44 -0400)
commit1f7c7553489c234a0f6657f0e0cfa40ee19f3ef7
tree451f4f199375f594b9c7e8c5e479179bfb5e41f5
parent39054ffecbc7a463edb7cf3f56e1d13243ffde12
repair: don't duplicate names in phase 6

The name hash in phase 6 is constructed by using names that point
directly into the directory buffers. Hence before the buffers can be
released, the constructed name hash has to duplicate all those names
into meory it owns via dir_hash_dup_names().

Given that the structure that holds the name is dynamically
allocated, it makes no sense to store a pointer to the name
dir_hash_add() and then later have dynamically allocate the name.

Extend the name hash allocation to contain space for the name
itself, and copy the name into the name hash structure in
dir_hash_add(). This allows us to get rid of dir_hash_dup_names(),
and the directory checking code no longer needs to hold all the
directory buffers in memory until the entire directory walk is
complete and the names duplicated.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/phase6.c