findparent.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (c) 2020-2024 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <djwong@kernel.org>
  5. */
  6. #ifndef __XFS_SCRUB_FINDPARENT_H__
  7. #define __XFS_SCRUB_FINDPARENT_H__
  8. struct xrep_parent_scan_info {
  9. struct xfs_scrub *sc;
  10. /* Inode scan cursor. */
  11. struct xchk_iscan iscan;
  12. /* Hook to capture directory entry updates. */
  13. struct xfs_dir_hook dhook;
  14. /* Lock protecting parent_ino. */
  15. struct mutex lock;
  16. /* Parent inode that we've found. */
  17. xfs_ino_t parent_ino;
  18. bool lookup_parent;
  19. };
  20. int __xrep_findparent_scan_start(struct xfs_scrub *sc,
  21. struct xrep_parent_scan_info *pscan,
  22. notifier_fn_t custom_fn);
  23. static inline int xrep_findparent_scan_start(struct xfs_scrub *sc,
  24. struct xrep_parent_scan_info *pscan)
  25. {
  26. return __xrep_findparent_scan_start(sc, pscan, NULL);
  27. }
  28. int xrep_findparent_scan(struct xrep_parent_scan_info *pscan);
  29. void xrep_findparent_scan_teardown(struct xrep_parent_scan_info *pscan);
  30. static inline void
  31. xrep_findparent_scan_found(
  32. struct xrep_parent_scan_info *pscan,
  33. xfs_ino_t ino)
  34. {
  35. mutex_lock(&pscan->lock);
  36. pscan->parent_ino = ino;
  37. mutex_unlock(&pscan->lock);
  38. }
  39. void xrep_findparent_scan_finish_early(struct xrep_parent_scan_info *pscan,
  40. xfs_ino_t ino);
  41. int xrep_findparent_confirm(struct xfs_scrub *sc, xfs_ino_t *parent_ino);
  42. xfs_ino_t xrep_findparent_self_reference(struct xfs_scrub *sc);
  43. xfs_ino_t xrep_findparent_from_dcache(struct xfs_scrub *sc);
  44. #endif /* __XFS_SCRUB_FINDPARENT_H__ */