aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_alloc.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_alloc.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_alloc.c')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c49
1 files changed, 0 insertions, 49 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 1db50cfc0212..eef466260d43 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -3123,55 +3123,6 @@ xfs_alloc_query_all(
3123 return xfs_btree_query_all(cur, xfs_alloc_query_range_helper, &query); 3123 return xfs_btree_query_all(cur, xfs_alloc_query_range_helper, &query);
3124} 3124}
3125 3125
3126/* Find the size of the AG, in blocks. */
3127xfs_agblock_t
3128xfs_ag_block_count(
3129 struct xfs_mount *mp,
3130 xfs_agnumber_t agno)
3131{
3132 ASSERT(agno < mp->m_sb.sb_agcount);
3133
3134 if (agno < mp->m_sb.sb_agcount - 1)
3135 return mp->m_sb.sb_agblocks;
3136 return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks);
3137}
3138
3139/*
3140 * Verify that an AG block number pointer neither points outside the AG
3141 * nor points at static metadata.
3142 */
3143bool
3144xfs_verify_agbno(
3145 struct xfs_mount *mp,
3146 xfs_agnumber_t agno,
3147 xfs_agblock_t agbno)
3148{
3149 xfs_agblock_t eoag;
3150
3151 eoag = xfs_ag_block_count(mp, agno);
3152 if (agbno >= eoag)
3153 return false;
3154 if (agbno <= XFS_AGFL_BLOCK(mp))
3155 return false;
3156 return true;
3157}
3158
3159/*
3160 * Verify that an FS block number pointer neither points outside the
3161 * filesystem nor points at static AG metadata.
3162 */
3163bool
3164xfs_verify_fsbno(
3165 struct xfs_mount *mp,
3166 xfs_fsblock_t fsbno)
3167{
3168 xfs_agnumber_t agno = XFS_FSB_TO_AGNO(mp, fsbno);
3169
3170 if (agno >= mp->m_sb.sb_agcount)
3171 return false;
3172 return xfs_verify_agbno(mp, agno, XFS_FSB_TO_AGBNO(mp, fsbno));
3173}
3174
3175/* Is there a record covering a given extent? */ 3126/* Is there a record covering a given extent? */
3176int 3127int
3177xfs_alloc_has_record( 3128xfs_alloc_has_record(