Skip to content

Commit 4e3f7e7

Browse files
author
Chandan Babu R
committed
Merge tag 'realtime-bmap-intents-6.9_2024-02-23' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.9-mergeC
xfs: widen BUI formats to support realtime Atomic extent swapping (and later, reverse mapping and reflink) on the realtime device needs to be able to defer file mapping and extent freeing work in much the same manner as is required on the data volume. Make the BUI log items operate on rt extents in preparation for atomic swapping and realtime rmap. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org> * tag 'realtime-bmap-intents-6.9_2024-02-23' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux: xfs: support recovering bmap intent items targetting realtime extents xfs: add a realtime flag to the bmap update log redo items xfs: fix xfs_bunmapi to allow unmapping of partial rt extents
2 parents 10ea615 + 1b5453b commit 4e3f7e7

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5459,7 +5459,7 @@ __xfs_bunmapi(
54595459
if (del.br_startoff + del.br_blockcount > end + 1)
54605460
del.br_blockcount = end + 1 - del.br_startoff;
54615461

5462-
if (!isrt)
5462+
if (!isrt || (flags & XFS_BMAPI_REMAP))
54635463
goto delete;
54645464

54655465
mod = xfs_rtb_to_rtxoff(mp,
@@ -5477,7 +5477,7 @@ __xfs_bunmapi(
54775477
* This piece is unwritten, or we're not
54785478
* using unwritten extents. Skip over it.
54795479
*/
5480-
ASSERT(end >= mod);
5480+
ASSERT((flags & XFS_BMAPI_REMAP) || end >= mod);
54815481
end -= mod > del.br_blockcount ?
54825482
del.br_blockcount : mod;
54835483
if (end < got.br_startoff &&

fs/xfs/libxfs/xfs_log_format.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,12 @@ struct xfs_cud_log_format {
838838

839839
#define XFS_BMAP_EXTENT_ATTR_FORK (1U << 31)
840840
#define XFS_BMAP_EXTENT_UNWRITTEN (1U << 30)
841+
#define XFS_BMAP_EXTENT_REALTIME (1U << 29)
841842

842843
#define XFS_BMAP_EXTENT_FLAGS (XFS_BMAP_EXTENT_TYPE_MASK | \
843844
XFS_BMAP_EXTENT_ATTR_FORK | \
844-
XFS_BMAP_EXTENT_UNWRITTEN)
845+
XFS_BMAP_EXTENT_UNWRITTEN | \
846+
XFS_BMAP_EXTENT_REALTIME)
845847

846848
/*
847849
* This is the structure used to lay out an bui log item in the

fs/xfs/xfs_bmap_item.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ xfs_bmap_update_log_item(
275275
map->me_flags |= XFS_BMAP_EXTENT_UNWRITTEN;
276276
if (bi->bi_whichfork == XFS_ATTR_FORK)
277277
map->me_flags |= XFS_BMAP_EXTENT_ATTR_FORK;
278+
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
279+
map->me_flags |= XFS_BMAP_EXTENT_REALTIME;
278280
}
279281

280282
static struct xfs_log_item *
@@ -324,6 +326,9 @@ xfs_bmap_update_get_group(
324326
{
325327
xfs_agnumber_t agno;
326328

329+
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
330+
return;
331+
327332
agno = XFS_FSB_TO_AGNO(mp, bi->bi_bmap.br_startblock);
328333

329334
/*
@@ -353,6 +358,9 @@ static inline void
353358
xfs_bmap_update_put_group(
354359
struct xfs_bmap_intent *bi)
355360
{
361+
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
362+
return;
363+
356364
xfs_perag_intent_put(bi->bi_pag);
357365
}
358366

@@ -427,6 +435,9 @@ xfs_bui_validate(
427435
if (!xfs_verify_fileext(mp, map->me_startoff, map->me_len))
428436
return false;
429437

438+
if (map->me_flags & XFS_BMAP_EXTENT_REALTIME)
439+
return xfs_verify_rtbext(mp, map->me_startblock, map->me_len);
440+
430441
return xfs_verify_fsbext(mp, map->me_startblock, map->me_len);
431442
}
432443

@@ -502,6 +513,12 @@ xfs_bmap_recover_work(
502513
xfs_ilock(ip, XFS_ILOCK_EXCL);
503514
xfs_trans_ijoin(tp, ip, 0);
504515

516+
if (!!(map->me_flags & XFS_BMAP_EXTENT_REALTIME) !=
517+
xfs_ifork_is_realtime(ip, work->bi_whichfork)) {
518+
error = -EFSCORRUPTED;
519+
goto err_cancel;
520+
}
521+
505522
if (work->bi_type == XFS_BMAP_MAP)
506523
iext_delta = XFS_IEXT_ADD_NOSPLIT_CNT;
507524
else

fs/xfs/xfs_trace.h

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,9 +2955,11 @@ DECLARE_EVENT_CLASS(xfs_bmap_deferred_class,
29552955
TP_ARGS(bi),
29562956
TP_STRUCT__entry(
29572957
__field(dev_t, dev)
2958+
__field(dev_t, opdev)
29582959
__field(xfs_agnumber_t, agno)
29592960
__field(xfs_ino_t, ino)
29602961
__field(xfs_agblock_t, agbno)
2962+
__field(xfs_fsblock_t, rtbno)
29612963
__field(int, whichfork)
29622964
__field(xfs_fileoff_t, l_loff)
29632965
__field(xfs_filblks_t, l_len)
@@ -2968,23 +2970,34 @@ DECLARE_EVENT_CLASS(xfs_bmap_deferred_class,
29682970
struct xfs_inode *ip = bi->bi_owner;
29692971

29702972
__entry->dev = ip->i_mount->m_super->s_dev;
2971-
__entry->agno = XFS_FSB_TO_AGNO(ip->i_mount,
2972-
bi->bi_bmap.br_startblock);
2973+
if (xfs_ifork_is_realtime(ip, bi->bi_whichfork)) {
2974+
__entry->agno = 0;
2975+
__entry->agbno = 0;
2976+
__entry->rtbno = bi->bi_bmap.br_startblock;
2977+
__entry->opdev = ip->i_mount->m_rtdev_targp->bt_dev;
2978+
} else {
2979+
__entry->agno = XFS_FSB_TO_AGNO(ip->i_mount,
2980+
bi->bi_bmap.br_startblock);
2981+
__entry->agbno = XFS_FSB_TO_AGBNO(ip->i_mount,
2982+
bi->bi_bmap.br_startblock);
2983+
__entry->rtbno = 0;
2984+
__entry->opdev = __entry->dev;
2985+
}
29732986
__entry->ino = ip->i_ino;
2974-
__entry->agbno = XFS_FSB_TO_AGBNO(ip->i_mount,
2975-
bi->bi_bmap.br_startblock);
29762987
__entry->whichfork = bi->bi_whichfork;
29772988
__entry->l_loff = bi->bi_bmap.br_startoff;
29782989
__entry->l_len = bi->bi_bmap.br_blockcount;
29792990
__entry->l_state = bi->bi_bmap.br_state;
29802991
__entry->op = bi->bi_type;
29812992
),
2982-
TP_printk("dev %d:%d op %s ino 0x%llx agno 0x%x agbno 0x%x %s fileoff 0x%llx fsbcount 0x%llx state %d",
2993+
TP_printk("dev %d:%d op %s opdev %d:%d ino 0x%llx agno 0x%x agbno 0x%x rtbno 0x%llx %s fileoff 0x%llx fsbcount 0x%llx state %d",
29832994
MAJOR(__entry->dev), MINOR(__entry->dev),
29842995
__print_symbolic(__entry->op, XFS_BMAP_INTENT_STRINGS),
2996+
MAJOR(__entry->opdev), MINOR(__entry->opdev),
29852997
__entry->ino,
29862998
__entry->agno,
29872999
__entry->agbno,
3000+
__entry->rtbno,
29883001
__print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
29893002
__entry->l_loff,
29903003
__entry->l_len,

0 commit comments

Comments
 (0)