Whamcloud - gitweb
LU-11446 e2fsck: check trusted.link when fixing nlink
authorLi Dongyang <dongyangli@ddn.com>
Tue, 30 Mar 2021 11:22:40 +0000 (22:22 +1100)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 15 Dec 2022 22:29:59 +0000 (15:29 -0700)
commit50b0b6dd9ff203dd1669438c275c060d0b72926b
tree128ee2333371ffa0090b29cf02e39b5ec063b613
parent8a7017d79e0bbe23d81d13416d08a873ac6f1ce0
LU-11446 e2fsck: check trusted.link when fixing nlink

The inode link count could be higher than what is stored in the
local MDT inode because of remote file links from DNE MDTs.
If we find a mismatched link count, look up the "trusted.link"
xattr.  If it exists, do a sanity check on it, and use the
leh_reccount stored there if larger than the local link count.

If leh_overflow_time is set, then the "trusted.link" xattr may
not hold all of the links, so assume the maximum of available
link counts is valid until LFSCK clears leh_overflow_time.

If the inode is not linked into the namespace, link it into
lost+found before checking trusted.link for the DNE link count.

Update the f_trusted_link test case to include a locally
unreferenced inode that has a trusted.link xattr.  The
inode should be linked into lost+found because of the xattr,
even if it has no blocks/data, and the link cound should be
extracted from the trusted.link xattr.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Change-Id: I213d816a92043c348eb55374aaa98e98957ccf23
Reviewed-on: https://review.whamcloud.com/43169
Reviewed-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
e2fsck/pass4.c
lib/ext2fs/ext2fs.h
lib/ext2fs/ext_attr.c
tests/f_trusted_link/expect.1 [new file with mode: 0644]
tests/f_trusted_link/expect.2 [new file with mode: 0644]
tests/f_trusted_link/image.gz [new file with mode: 0644]
tests/f_trusted_link/name [new file with mode: 0644]