mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 22:14:36 -04:00
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
This commit is contained in:
@@ -5459,7 +5459,7 @@ __xfs_bunmapi(
|
||||
if (del.br_startoff + del.br_blockcount > end + 1)
|
||||
del.br_blockcount = end + 1 - del.br_startoff;
|
||||
|
||||
if (!isrt)
|
||||
if (!isrt || (flags & XFS_BMAPI_REMAP))
|
||||
goto delete;
|
||||
|
||||
mod = xfs_rtb_to_rtxoff(mp,
|
||||
@@ -5477,7 +5477,7 @@ __xfs_bunmapi(
|
||||
* This piece is unwritten, or we're not
|
||||
* using unwritten extents. Skip over it.
|
||||
*/
|
||||
ASSERT(end >= mod);
|
||||
ASSERT((flags & XFS_BMAPI_REMAP) || end >= mod);
|
||||
end -= mod > del.br_blockcount ?
|
||||
del.br_blockcount : mod;
|
||||
if (end < got.br_startoff &&
|
||||
|
||||
@@ -838,10 +838,12 @@ struct xfs_cud_log_format {
|
||||
|
||||
#define XFS_BMAP_EXTENT_ATTR_FORK (1U << 31)
|
||||
#define XFS_BMAP_EXTENT_UNWRITTEN (1U << 30)
|
||||
#define XFS_BMAP_EXTENT_REALTIME (1U << 29)
|
||||
|
||||
#define XFS_BMAP_EXTENT_FLAGS (XFS_BMAP_EXTENT_TYPE_MASK | \
|
||||
XFS_BMAP_EXTENT_ATTR_FORK | \
|
||||
XFS_BMAP_EXTENT_UNWRITTEN)
|
||||
XFS_BMAP_EXTENT_UNWRITTEN | \
|
||||
XFS_BMAP_EXTENT_REALTIME)
|
||||
|
||||
/*
|
||||
* This is the structure used to lay out an bui log item in the
|
||||
|
||||
@@ -275,6 +275,8 @@ xfs_bmap_update_log_item(
|
||||
map->me_flags |= XFS_BMAP_EXTENT_UNWRITTEN;
|
||||
if (bi->bi_whichfork == XFS_ATTR_FORK)
|
||||
map->me_flags |= XFS_BMAP_EXTENT_ATTR_FORK;
|
||||
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
|
||||
map->me_flags |= XFS_BMAP_EXTENT_REALTIME;
|
||||
}
|
||||
|
||||
static struct xfs_log_item *
|
||||
@@ -324,6 +326,9 @@ xfs_bmap_update_get_group(
|
||||
{
|
||||
xfs_agnumber_t agno;
|
||||
|
||||
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
|
||||
return;
|
||||
|
||||
agno = XFS_FSB_TO_AGNO(mp, bi->bi_bmap.br_startblock);
|
||||
|
||||
/*
|
||||
@@ -353,6 +358,9 @@ static inline void
|
||||
xfs_bmap_update_put_group(
|
||||
struct xfs_bmap_intent *bi)
|
||||
{
|
||||
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
|
||||
return;
|
||||
|
||||
xfs_perag_intent_put(bi->bi_pag);
|
||||
}
|
||||
|
||||
@@ -427,6 +435,9 @@ xfs_bui_validate(
|
||||
if (!xfs_verify_fileext(mp, map->me_startoff, map->me_len))
|
||||
return false;
|
||||
|
||||
if (map->me_flags & XFS_BMAP_EXTENT_REALTIME)
|
||||
return xfs_verify_rtbext(mp, map->me_startblock, map->me_len);
|
||||
|
||||
return xfs_verify_fsbext(mp, map->me_startblock, map->me_len);
|
||||
}
|
||||
|
||||
@@ -502,6 +513,12 @@ xfs_bmap_recover_work(
|
||||
xfs_ilock(ip, XFS_ILOCK_EXCL);
|
||||
xfs_trans_ijoin(tp, ip, 0);
|
||||
|
||||
if (!!(map->me_flags & XFS_BMAP_EXTENT_REALTIME) !=
|
||||
xfs_ifork_is_realtime(ip, work->bi_whichfork)) {
|
||||
error = -EFSCORRUPTED;
|
||||
goto err_cancel;
|
||||
}
|
||||
|
||||
if (work->bi_type == XFS_BMAP_MAP)
|
||||
iext_delta = XFS_IEXT_ADD_NOSPLIT_CNT;
|
||||
else
|
||||
|
||||
@@ -2955,9 +2955,11 @@ DECLARE_EVENT_CLASS(xfs_bmap_deferred_class,
|
||||
TP_ARGS(bi),
|
||||
TP_STRUCT__entry(
|
||||
__field(dev_t, dev)
|
||||
__field(dev_t, opdev)
|
||||
__field(xfs_agnumber_t, agno)
|
||||
__field(xfs_ino_t, ino)
|
||||
__field(xfs_agblock_t, agbno)
|
||||
__field(xfs_fsblock_t, rtbno)
|
||||
__field(int, whichfork)
|
||||
__field(xfs_fileoff_t, l_loff)
|
||||
__field(xfs_filblks_t, l_len)
|
||||
@@ -2968,23 +2970,34 @@ DECLARE_EVENT_CLASS(xfs_bmap_deferred_class,
|
||||
struct xfs_inode *ip = bi->bi_owner;
|
||||
|
||||
__entry->dev = ip->i_mount->m_super->s_dev;
|
||||
__entry->agno = XFS_FSB_TO_AGNO(ip->i_mount,
|
||||
bi->bi_bmap.br_startblock);
|
||||
if (xfs_ifork_is_realtime(ip, bi->bi_whichfork)) {
|
||||
__entry->agno = 0;
|
||||
__entry->agbno = 0;
|
||||
__entry->rtbno = bi->bi_bmap.br_startblock;
|
||||
__entry->opdev = ip->i_mount->m_rtdev_targp->bt_dev;
|
||||
} else {
|
||||
__entry->agno = XFS_FSB_TO_AGNO(ip->i_mount,
|
||||
bi->bi_bmap.br_startblock);
|
||||
__entry->agbno = XFS_FSB_TO_AGBNO(ip->i_mount,
|
||||
bi->bi_bmap.br_startblock);
|
||||
__entry->rtbno = 0;
|
||||
__entry->opdev = __entry->dev;
|
||||
}
|
||||
__entry->ino = ip->i_ino;
|
||||
__entry->agbno = XFS_FSB_TO_AGBNO(ip->i_mount,
|
||||
bi->bi_bmap.br_startblock);
|
||||
__entry->whichfork = bi->bi_whichfork;
|
||||
__entry->l_loff = bi->bi_bmap.br_startoff;
|
||||
__entry->l_len = bi->bi_bmap.br_blockcount;
|
||||
__entry->l_state = bi->bi_bmap.br_state;
|
||||
__entry->op = bi->bi_type;
|
||||
),
|
||||
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",
|
||||
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",
|
||||
MAJOR(__entry->dev), MINOR(__entry->dev),
|
||||
__print_symbolic(__entry->op, XFS_BMAP_INTENT_STRINGS),
|
||||
MAJOR(__entry->opdev), MINOR(__entry->opdev),
|
||||
__entry->ino,
|
||||
__entry->agno,
|
||||
__entry->agbno,
|
||||
__entry->rtbno,
|
||||
__print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
|
||||
__entry->l_loff,
|
||||
__entry->l_len,
|
||||
|
||||
Reference in New Issue
Block a user