diff options
author | Darrick J. Wong <djwong@kernel.org> | 2021-09-01 11:18:44 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-10-22 16:41:09 -0700 |
commit | 35499e0f8292fbc893e72747aeb1f971603b5bfb (patch) | |
tree | 59f2411c88bdf5a55e2fe3c2e88b8f968b7a54e1 | |
parent | 499ebb25e79afd208e85aa47dccc044f9d3a9b8c (diff) |
xfs: enable sharing of realtime file blocks
Update the remapping routines to be able to handle realtime files.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r-- | fs/xfs/xfs_reflink.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 904ace47c2d7..e3518a58df00 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -31,6 +31,7 @@ #include "xfs_ag_resv.h" #include "xfs_rtrefcount_btree.h" #include "xfs_rtalloc.h" +#include "xfs_imeta.h" /* * Copy on Write of Shared Blocks @@ -1041,14 +1042,23 @@ out_error: static int xfs_reflink_ag_has_free_space( struct xfs_mount *mp, - xfs_agnumber_t agno) + struct xfs_inode *ip, + xfs_fsblock_t bno) { struct xfs_perag *pag; + xfs_agnumber_t agno; int error = 0; if (!xfs_has_rmapbt(mp)) return 0; + if (XFS_IS_REALTIME_INODE(ip)) { + if (xfs_imeta_resv_critical(mp, mp->m_rrmapip) || + xfs_imeta_resv_critical(mp, mp->m_rrefcountip)) + return -ENOSPC; + return 0; + } + agno = XFS_FSB_TO_AGNO(mp, bno); pag = xfs_perag_get(mp, agno); if (xfs_ag_resv_critical(pag, XFS_AG_RESV_RMAPBT) || xfs_ag_resv_critical(pag, XFS_AG_RESV_METADATA)) @@ -1160,8 +1170,8 @@ xfs_reflink_remap_extent( /* No reflinking if the AG of the dest mapping is low on space. */ if (dmap_written) { - error = xfs_reflink_ag_has_free_space(mp, - XFS_FSB_TO_AGNO(mp, dmap->br_startblock)); + error = xfs_reflink_ag_has_free_space(mp, ip, + dmap->br_startblock); if (error) goto out_cancel; } @@ -1419,8 +1429,8 @@ xfs_reflink_remap_prep( /* Check file eligibility and prepare for block sharing. */ ret = -EINVAL; - /* Don't reflink realtime inodes */ - if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest)) + /* Can't reflink between data and rt volumes */ + if (XFS_IS_REALTIME_INODE(src) != XFS_IS_REALTIME_INODE(dest)) goto out_unlock; /* Don't share DAX file data for now. */ |