]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_repair: Bump link count if longform_dir2_rebuild yields shortform dir
authorEric Sandeen <sandeen@redhat.com>
Tue, 15 Apr 2025 18:09:23 +0000 (13:09 -0500)
committerAndrey Albershteyn <aalbersh@kernel.org>
Mon, 28 Apr 2025 11:00:33 +0000 (13:00 +0200)
commit454fab69c484c24d8fb76ac3676553a54af381f7
tree17558ca793db5911aded6c12e290c22a93ccaecc
parent81f646b0d6afb797fdd14eccc9965a3212ba358e
xfs_repair: Bump link count if longform_dir2_rebuild yields shortform dir

If longform_dir2_rebuild() has so few entries in *hashtab that it results
in a short form directory, bump the link count manually as shortform
directories have no explicit "." entry.

Without this, repair will end with i.e.:

resetting inode 131 nlinks from 2 to 1

in this case, because it thinks this directory inode only has 1 link
discovered, and then a 2nd repair will fix it:

resetting inode 131 nlinks from 1 to 2

because shortform_dir2_entry_check() explicitly adds the extra ref when
the (newly-created)shortform directory is checked:

        /*
         * no '.' entry in shortform dirs, just bump up ref count by 1
         * '..' was already (or will be) accounted for and checked when
         * the directory is reached or will be taken care of when the
         * directory is moved to orphanage.
         */
        add_inode_ref(current_irec, current_ino_offset);

Avoid this by adding the extra ref if we convert from longform to
shortform.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
[aalbersh drop SoB with user.mail as name]
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
repair/phase6.c