提交 9c4f29d3 编写于 作者: C Christoph Hellwig 提交者: Darrick J. Wong

xfs: factor out a xfs_bmap_is_real_extent helper

This checks for all the non-normal extent types, including handling both
encodings of delayed allocations.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
上级 696a5620
...@@ -171,6 +171,18 @@ static inline int xfs_bmapi_whichfork(int bmapi_flags) ...@@ -171,6 +171,18 @@ static inline int xfs_bmapi_whichfork(int bmapi_flags)
{ BMAP_COWFORK, "COW" } { 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 * This macro is used to determine how many extents will be shifted
* in one write transaction. We could require two splits, * in one write transaction. We could require two splits,
......
...@@ -1276,9 +1276,7 @@ xfs_get_blocks( ...@@ -1276,9 +1276,7 @@ xfs_get_blocks(
* For unwritten extents do not report a disk address in the buffered * For unwritten extents do not report a disk address in the buffered
* read case (treat as if we're reading into a hole). * read case (treat as if we're reading into a hole).
*/ */
if (imap.br_startblock != HOLESTARTBLOCK && if (xfs_bmap_is_real_extent(&imap))
imap.br_startblock != DELAYSTARTBLOCK &&
!ISUNWRITTEN(&imap))
xfs_map_buffer(inode, bh_result, &imap, offset); xfs_map_buffer(inode, bh_result, &imap, offset);
/* /*
......
...@@ -448,10 +448,9 @@ xfs_getbmap_adjust_shared( ...@@ -448,10 +448,9 @@ xfs_getbmap_adjust_shared(
next_map->br_blockcount = 0; next_map->br_blockcount = 0;
/* Only written data blocks can be shared. */ /* Only written data blocks can be shared. */
if (!xfs_is_reflink_inode(ip) || whichfork != XFS_DATA_FORK || if (!xfs_is_reflink_inode(ip) ||
map->br_startblock == DELAYSTARTBLOCK || whichfork != XFS_DATA_FORK ||
map->br_startblock == HOLESTARTBLOCK || !xfs_bmap_is_real_extent(map))
ISUNWRITTEN(map))
return 0; return 0;
agno = XFS_FSB_TO_AGNO(mp, map->br_startblock); agno = XFS_FSB_TO_AGNO(mp, map->br_startblock);
......
...@@ -206,11 +206,7 @@ xfs_reflink_trim_around_shared( ...@@ -206,11 +206,7 @@ xfs_reflink_trim_around_shared(
int error = 0; int error = 0;
/* Holes, unwritten, and delalloc extents cannot be shared */ /* Holes, unwritten, and delalloc extents cannot be shared */
if (!xfs_is_reflink_inode(ip) || if (!xfs_is_reflink_inode(ip) || !xfs_bmap_is_real_extent(irec)) {
ISUNWRITTEN(irec) ||
irec->br_startblock == HOLESTARTBLOCK ||
irec->br_startblock == DELAYSTARTBLOCK ||
isnullstartblock(irec->br_startblock)) {
*shared = false; *shared = false;
return 0; return 0;
} }
...@@ -1045,12 +1041,12 @@ xfs_reflink_remap_extent( ...@@ -1045,12 +1041,12 @@ xfs_reflink_remap_extent(
xfs_off_t new_isize) xfs_off_t new_isize)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
bool real_extent = xfs_bmap_is_real_extent(irec);
struct xfs_trans *tp; struct xfs_trans *tp;
xfs_fsblock_t firstfsb; xfs_fsblock_t firstfsb;
unsigned int resblks; unsigned int resblks;
struct xfs_defer_ops dfops; struct xfs_defer_ops dfops;
struct xfs_bmbt_irec uirec; struct xfs_bmbt_irec uirec;
bool real_extent;
xfs_filblks_t rlen; xfs_filblks_t rlen;
xfs_filblks_t unmap_len; xfs_filblks_t unmap_len;
xfs_off_t newlen; xfs_off_t newlen;
...@@ -1059,11 +1055,6 @@ xfs_reflink_remap_extent( ...@@ -1059,11 +1055,6 @@ xfs_reflink_remap_extent(
unmap_len = irec->br_startoff + irec->br_blockcount - destoff; unmap_len = irec->br_startoff + irec->br_blockcount - destoff;
trace_xfs_reflink_punch_range(ip, destoff, unmap_len); trace_xfs_reflink_punch_range(ip, destoff, unmap_len);
/* Only remap normal extents. */
real_extent = (irec->br_startblock != HOLESTARTBLOCK &&
irec->br_startblock != DELAYSTARTBLOCK &&
!ISUNWRITTEN(irec));
/* No reflinking if we're low on space */ /* No reflinking if we're low on space */
if (real_extent) { if (real_extent) {
error = xfs_reflink_ag_has_free_space(mp, error = xfs_reflink_ag_has_free_space(mp,
...@@ -1359,9 +1350,7 @@ xfs_reflink_dirty_extents( ...@@ -1359,9 +1350,7 @@ xfs_reflink_dirty_extents(
goto out; goto out;
if (nmaps == 0) if (nmaps == 0)
break; break;
if (map[0].br_startblock == HOLESTARTBLOCK || if (!xfs_bmap_is_real_extent(&map[0]))
map[0].br_startblock == DELAYSTARTBLOCK ||
ISUNWRITTEN(&map[0]))
goto next; goto next;
map[1] = map[0]; map[1] = map[0];
...@@ -1435,9 +1424,7 @@ xfs_reflink_clear_inode_flag( ...@@ -1435,9 +1424,7 @@ xfs_reflink_clear_inode_flag(
return error; return error;
if (nmaps == 0) if (nmaps == 0)
break; break;
if (map.br_startblock == HOLESTARTBLOCK || if (!xfs_bmap_is_real_extent(&map))
map.br_startblock == DELAYSTARTBLOCK ||
ISUNWRITTEN(&map))
goto next; goto next;
agno = XFS_FSB_TO_AGNO(mp, map.br_startblock); agno = XFS_FSB_TO_AGNO(mp, map.br_startblock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册