/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (c) 2021-2024 Oracle. All Rights Reserved. * Author: Darrick J. Wong <[email protected]> */ #ifndef __XFS_SCRUB_NLINKS_H__ #define __XFS_SCRUB_NLINKS_H__ /* Live link count control structure. */ struct xchk_nlink_ctrs { … }; /* * In-core link counts for a given inode in the filesystem. * * For an empty rootdir, the directory entries and the field to which they are * accounted are as follows: * * Root directory: * * . points to self (root.child) * .. points to self (root.parent) * f1 points to a child file (f1.parent) * d1 points to a child dir (d1.parent, root.child) * * Subdirectory d1: * * . points to self (d1.child) * .. points to root dir (root.backref) * f2 points to child file (f2.parent) * f3 points to root.f1 (f1.parent) * * root.nlink == 3 (root.dot, root.dotdot, root.d1) * d1.nlink == 2 (root.d1, d1.dot) * f1.nlink == 2 (root.f1, d1.f3) * f2.nlink == 1 (d1.f2) */ struct xchk_nlink { … }; /* * This incore link count has been written at least once. We never want to * store an xchk_nlink that looks uninitialized. */ #define XCHK_NLINK_WRITTEN … /* Already checked this link count record. */ #define XCHK_NLINK_COMPARE_SCANNED … /* Already made a repair with this link count record. */ #define XREP_NLINK_DIRTY … /* Compute total link count, using large enough variables to detect overflow. */ static inline uint64_t xchk_nlink_total(struct xfs_inode *ip, const struct xchk_nlink *live) { … } #endif /* __XFS_SCRUB_NLINKS_H__ */