Skip to content

Commit cb288c9

Browse files
committed
Merge tag 'rtgroups-prep-6.13_2024-11-05' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into staging-merge
xfs: preparation for realtime allocation groups [v5.5 05/10] Prepare for realtime groups by adding a few bug fixes and generic code that will be necessary. With a bit of luck, this should all go splendidly. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2 parents 6b3582a + 64c58d7 commit cb288c9

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

fs/iomap/buffered-io.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,8 @@ iomap_ioend_can_merge(struct iomap_ioend *ioend, struct iomap_ioend *next)
16011601
{
16021602
if (ioend->io_bio.bi_status != next->io_bio.bi_status)
16031603
return false;
1604+
if (next->io_flags & IOMAP_F_BOUNDARY)
1605+
return false;
16041606
if ((ioend->io_flags & IOMAP_F_SHARED) ^
16051607
(next->io_flags & IOMAP_F_SHARED))
16061608
return false;
@@ -1720,6 +1722,8 @@ static struct iomap_ioend *iomap_alloc_ioend(struct iomap_writepage_ctx *wpc,
17201722
INIT_LIST_HEAD(&ioend->io_list);
17211723
ioend->io_type = wpc->iomap.type;
17221724
ioend->io_flags = wpc->iomap.flags;
1725+
if (pos > wpc->iomap.offset)
1726+
wpc->iomap.flags &= ~IOMAP_F_BOUNDARY;
17231727
ioend->io_inode = inode;
17241728
ioend->io_size = 0;
17251729
ioend->io_offset = pos;
@@ -1731,6 +1735,8 @@ static struct iomap_ioend *iomap_alloc_ioend(struct iomap_writepage_ctx *wpc,
17311735

17321736
static bool iomap_can_add_to_ioend(struct iomap_writepage_ctx *wpc, loff_t pos)
17331737
{
1738+
if (wpc->iomap.offset == pos && (wpc->iomap.flags & IOMAP_F_BOUNDARY))
1739+
return false;
17341740
if ((wpc->iomap.flags & IOMAP_F_SHARED) !=
17351741
(wpc->ioend->io_flags & IOMAP_F_SHARED))
17361742
return false;

fs/xfs/xfs_discard.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ xfs_discard_rtdev_extents(
480480
trace_xfs_discard_rtextent(mp, busyp->bno, busyp->length);
481481

482482
error = __blkdev_issue_discard(bdev,
483-
XFS_FSB_TO_BB(mp, busyp->bno),
483+
xfs_rtb_to_daddr(mp, busyp->bno),
484484
XFS_FSB_TO_BB(mp, busyp->length),
485485
GFP_NOFS, &bio);
486486
if (error)
@@ -612,22 +612,25 @@ xfs_trim_rtdev_extents(
612612
xfs_rtblock_t start_rtbno, end_rtbno;
613613
xfs_rtxnum_t start_rtx, end_rtx;
614614
xfs_rgnumber_t start_rgno, end_rgno;
615+
xfs_daddr_t daddr_offset;
615616
int last_error = 0, error;
616617
struct xfs_rtgroup *rtg = NULL;
617618

618619
/* Shift the start and end downwards to match the rt device. */
619-
start_rtbno = xfs_daddr_to_rtb(mp, start);
620-
if (start_rtbno > mp->m_sb.sb_dblocks)
621-
start_rtbno -= mp->m_sb.sb_dblocks;
620+
daddr_offset = XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks);
621+
if (start > daddr_offset)
622+
start -= daddr_offset;
622623
else
623-
start_rtbno = 0;
624+
start = 0;
625+
start_rtbno = xfs_daddr_to_rtb(mp, start);
624626
start_rtx = xfs_rtb_to_rtx(mp, start_rtbno);
625627
start_rgno = xfs_rtb_to_rgno(mp, start_rtbno);
626628

627-
end_rtbno = xfs_daddr_to_rtb(mp, end);
628-
if (end_rtbno <= mp->m_sb.sb_dblocks)
629+
if (end <= daddr_offset)
629630
return 0;
630-
end_rtbno -= mp->m_sb.sb_dblocks;
631+
else
632+
end -= daddr_offset;
633+
end_rtbno = xfs_daddr_to_rtb(mp, end);
631634
end_rtx = xfs_rtb_to_rtx(mp, end_rtbno + mp->m_sb.sb_rextsize - 1);
632635
end_rgno = xfs_rtb_to_rgno(mp, end_rtbno);
633636

include/linux/iomap.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ struct vm_fault;
5353
*
5454
* IOMAP_F_XATTR indicates that the iomap is for an extended attribute extent
5555
* rather than a file data extent.
56+
*
57+
* IOMAP_F_BOUNDARY indicates that I/O and I/O completions for this iomap must
58+
* never be merged with the mapping before it.
5659
*/
5760
#define IOMAP_F_NEW (1U << 0)
5861
#define IOMAP_F_DIRTY (1U << 1)
@@ -64,6 +67,7 @@ struct vm_fault;
6467
#define IOMAP_F_BUFFER_HEAD 0
6568
#endif /* CONFIG_BUFFER_HEAD */
6669
#define IOMAP_F_XATTR (1U << 5)
70+
#define IOMAP_F_BOUNDARY (1U << 6)
6771

6872
/*
6973
* Flags set by the core iomap code during operations:

0 commit comments

Comments
 (0)