From cd83dc79b719bcb4309c7645744a217b73adad32 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 11 May 2017 14:01:03 -0500 Subject: [PATCH] xfs: factor out a xfs_bmap_is_real_extent helper Source kernel commit: 9c4f29d39168bb9363189f0d54ee1202372e7d9b This checks for all the non-normal extent types, including handling both encodings of delayed allocations. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- libxfs/xfs_bmap.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libxfs/xfs_bmap.h b/libxfs/xfs_bmap.h index cdef87db5..a6e612cab 100644 --- a/libxfs/xfs_bmap.h +++ b/libxfs/xfs_bmap.h @@ -171,6 +171,18 @@ static inline int xfs_bmapi_whichfork(int bmapi_flags) { BMAP_COWFORK, "COW" } +/* + * Return true if the extent is a real, allocated extent, or false if it is a + * delayed allocation, and unwritten extent or a hole. + */ +static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec) +{ + return irec->br_state != XFS_EXT_UNWRITTEN && + irec->br_startblock != HOLESTARTBLOCK && + irec->br_startblock != DELAYSTARTBLOCK && + !isnullstartblock(irec->br_startblock); +} + /* * This macro is used to determine how many extents will be shifted * in one write transaction. We could require two splits, -- 2.47.2