aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_ialloc.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2018-06-07 10:53:33 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-06-08 13:07:51 -0400
commit86210fbebae6e60b1158ccd6b47ee7ae1abf5b2c (patch)
tree4d705bbf018694eb4ad9c8ba9a19721d8a5e2fdf /fs/xfs/libxfs/xfs_ialloc.c
parent4a2d01b076d231afebbea04647373644e767b453 (diff)
xfs: move various type verifiers to common file
New verification functions like xfs_verify_fsbno() and xfs_verify_agino() are spread across multiple files and different header files. They really don't fit cleanly into the places they've been put, and have wider scope than the current header includes. Move the type verifiers to a new file in libxfs (xfs-types.c) and the prototypes to xfs_types.h where they will be visible to all the code that uses the types. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_ialloc.c')
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c90
1 files changed, 0 insertions, 90 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 3f551eb29157..8ec39dad62d7 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2674,96 +2674,6 @@ xfs_ialloc_pagi_init(
2674 return 0; 2674 return 0;
2675} 2675}
2676 2676
2677/* Calculate the first and last possible inode number in an AG. */
2678void
2679xfs_ialloc_agino_range(
2680 struct xfs_mount *mp,
2681 xfs_agnumber_t agno,
2682 xfs_agino_t *first,
2683 xfs_agino_t *last)
2684{
2685 xfs_agblock_t bno;
2686 xfs_agblock_t eoag;
2687
2688 eoag = xfs_ag_block_count(mp, agno);
2689
2690 /*
2691 * Calculate the first inode, which will be in the first
2692 * cluster-aligned block after the AGFL.
2693 */
2694 bno = round_up(XFS_AGFL_BLOCK(mp) + 1,
2695 xfs_ialloc_cluster_alignment(mp));
2696 *first = XFS_OFFBNO_TO_AGINO(mp, bno, 0);
2697
2698 /*
2699 * Calculate the last inode, which will be at the end of the
2700 * last (aligned) cluster that can be allocated in the AG.
2701 */
2702 bno = round_down(eoag, xfs_ialloc_cluster_alignment(mp));
2703 *last = XFS_OFFBNO_TO_AGINO(mp, bno, 0) - 1;
2704}
2705
2706/*
2707 * Verify that an AG inode number pointer neither points outside the AG
2708 * nor points at static metadata.
2709 */
2710bool
2711xfs_verify_agino(
2712 struct xfs_mount *mp,
2713 xfs_agnumber_t agno,
2714 xfs_agino_t agino)
2715{
2716 xfs_agino_t first;
2717 xfs_agino_t last;
2718
2719 xfs_ialloc_agino_range(mp, agno, &first, &last);
2720 return agino >= first && agino <= last;
2721}
2722
2723/*
2724 * Verify that an FS inode number pointer neither points outside the
2725 * filesystem nor points at static AG metadata.
2726 */
2727bool
2728xfs_verify_ino(
2729 struct xfs_mount *mp,
2730 xfs_ino_t ino)
2731{
2732 xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, ino);
2733 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ino);
2734
2735 if (agno >= mp->m_sb.sb_agcount)
2736 return false;
2737 if (XFS_AGINO_TO_INO(mp, agno, agino) != ino)
2738 return false;
2739 return xfs_verify_agino(mp, agno, agino);
2740}
2741
2742/* Is this an internal inode number? */
2743bool
2744xfs_internal_inum(
2745 struct xfs_mount *mp,
2746 xfs_ino_t ino)
2747{
2748 return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino ||
2749 (xfs_sb_version_hasquota(&mp->m_sb) &&
2750 xfs_is_quota_inode(&mp->m_sb, ino));
2751}
2752
2753/*
2754 * Verify that a directory entry's inode number doesn't point at an internal
2755 * inode, empty space, or static AG metadata.
2756 */
2757bool
2758xfs_verify_dir_ino(
2759 struct xfs_mount *mp,
2760 xfs_ino_t ino)
2761{
2762 if (xfs_internal_inum(mp, ino))
2763 return false;
2764 return xfs_verify_ino(mp, ino);
2765}
2766
2767/* Is there an inode record covering a given range of inode numbers? */ 2677/* Is there an inode record covering a given range of inode numbers? */
2768int 2678int
2769xfs_ialloc_has_inode_record( 2679xfs_ialloc_has_inode_record(