summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_discard.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-11-03 20:19:16 -0800
committerDarrick J. Wong <djwong@kernel.org>2024-11-05 13:38:38 -0800
commitdca94251f617942f05c7c6ff30a299f6b7dff770 (patch)
tree2be107d46a9d016426de504e2eb378c616357de9 /fs/xfs/xfs_discard.c
parentf220f6da5f4ad7da538c39075cf57e829d5202f7 (diff)
xfs: fix rt device offset calculations for FITRIM
FITRIM on xfs has this bizarro uapi where we flatten all the physically addressable storage across two block devices into a linear address space. In this address space, the realtime device comes immediately after the data device. Therefore, the xfs_trim_rtdev_extents has to convert its input parameters from the linear address space to actual rtdev block addresses on the realtime volume. Right now the address space conversion is done in units of rtblocks. However, a future patchset will convert xfs_rtblock_t to be a segmented address space (group:blkno) like the data device. Change the conversion code to be done in units of daddrs since those will never be segmented. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/xfs_discard.c')
-rw-r--r--fs/xfs/xfs_discard.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 4f3e4736f13e..42b8b5e0e931 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -480,7 +480,7 @@ xfs_discard_rtdev_extents(
trace_xfs_discard_rtextent(mp, busyp->bno, busyp->length);
error = __blkdev_issue_discard(bdev,
- XFS_FSB_TO_BB(mp, busyp->bno),
+ xfs_rtb_to_daddr(mp, busyp->bno),
XFS_FSB_TO_BB(mp, busyp->length),
GFP_NOFS, &bio);
if (error)
@@ -612,22 +612,25 @@ xfs_trim_rtdev_extents(
xfs_rtblock_t start_rtbno, end_rtbno;
xfs_rtxnum_t start_rtx, end_rtx;
xfs_rgnumber_t start_rgno, end_rgno;
+ xfs_daddr_t daddr_offset;
int last_error = 0, error;
struct xfs_rtgroup *rtg = NULL;
/* Shift the start and end downwards to match the rt device. */
- start_rtbno = xfs_daddr_to_rtb(mp, start);
- if (start_rtbno > mp->m_sb.sb_dblocks)
- start_rtbno -= mp->m_sb.sb_dblocks;
+ daddr_offset = XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks);
+ if (start > daddr_offset)
+ start -= daddr_offset;
else
- start_rtbno = 0;
+ start = 0;
+ start_rtbno = xfs_daddr_to_rtb(mp, start);
start_rtx = xfs_rtb_to_rtx(mp, start_rtbno);
start_rgno = xfs_rtb_to_rgno(mp, start_rtbno);
- end_rtbno = xfs_daddr_to_rtb(mp, end);
- if (end_rtbno <= mp->m_sb.sb_dblocks)
+ if (end <= daddr_offset)
return 0;
- end_rtbno -= mp->m_sb.sb_dblocks;
+ else
+ end -= daddr_offset;
+ end_rtbno = xfs_daddr_to_rtb(mp, end);
end_rtx = xfs_rtb_to_rtx(mp, end_rtbno + mp->m_sb.sb_rextsize - 1);
end_rgno = xfs_rtb_to_rgno(mp, end_rtbno);