Commit 9e823fc2 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: add a realtime flag to the rmap update log redo items



Extend the rmap update (RUI) log items to handle realtime volumes by
adding a new log intent item type.

Signed-off-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent adafb31c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ struct xfs_defer_op_type {
extern const struct xfs_defer_op_type xfs_bmap_update_defer_type;
extern const struct xfs_defer_op_type xfs_refcount_update_defer_type;
extern const struct xfs_defer_op_type xfs_rmap_update_defer_type;
extern const struct xfs_defer_op_type xfs_rtrmap_update_defer_type;
extern const struct xfs_defer_op_type xfs_extent_free_defer_type;
extern const struct xfs_defer_op_type xfs_agfl_free_defer_type;
extern const struct xfs_defer_op_type xfs_rtextent_free_defer_type;
+5 −1
Original line number Diff line number Diff line
@@ -250,6 +250,8 @@ typedef struct xfs_trans_header {
#define	XFS_LI_XMD		0x1249  /* mapping exchange done */
#define	XFS_LI_EFI_RT		0x124a	/* realtime extent free intent */
#define	XFS_LI_EFD_RT		0x124b	/* realtime extent free done */
#define	XFS_LI_RUI_RT		0x124c	/* realtime rmap update intent */
#define	XFS_LI_RUD_RT		0x124d	/* realtime rmap update done */

#define XFS_LI_TYPE_DESC \
	{ XFS_LI_EFI,		"XFS_LI_EFI" }, \
@@ -271,7 +273,9 @@ typedef struct xfs_trans_header {
	{ XFS_LI_XMI,		"XFS_LI_XMI" }, \
	{ XFS_LI_XMD,		"XFS_LI_XMD" }, \
	{ XFS_LI_EFI_RT,	"XFS_LI_EFI_RT" }, \
	{ XFS_LI_EFD_RT,	"XFS_LI_EFD_RT" }
	{ XFS_LI_EFD_RT,	"XFS_LI_EFD_RT" }, \
	{ XFS_LI_RUI_RT,	"XFS_LI_RUI_RT" }, \
	{ XFS_LI_RUD_RT,	"XFS_LI_RUD_RT" }

/*
 * Inode Log Item Format definitions.
+2 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ extern const struct xlog_recover_item_ops xlog_xmi_item_ops;
extern const struct xlog_recover_item_ops xlog_xmd_item_ops;
extern const struct xlog_recover_item_ops xlog_rtefi_item_ops;
extern const struct xlog_recover_item_ops xlog_rtefd_item_ops;
extern const struct xlog_recover_item_ops xlog_rtrui_item_ops;
extern const struct xlog_recover_item_ops xlog_rtrud_item_ops;

/*
 * Macros, structures, prototypes for internal log manager use.
+2 −2
Original line number Diff line number Diff line
@@ -1831,7 +1831,7 @@ xfs_refcount_alloc_cow_extent(
	__xfs_refcount_add(tp, XFS_REFCOUNT_ALLOC_COW, fsb, len);

	/* Add rmap entry */
	xfs_rmap_alloc_extent(tp, fsb, len, XFS_RMAP_OWN_COW);
	xfs_rmap_alloc_extent(tp, false, fsb, len, XFS_RMAP_OWN_COW);
}

/* Forget a CoW staging event in the refcount btree. */
@@ -1847,7 +1847,7 @@ xfs_refcount_free_cow_extent(
		return;

	/* Remove rmap entry */
	xfs_rmap_free_extent(tp, fsb, len, XFS_RMAP_OWN_COW);
	xfs_rmap_free_extent(tp, false, fsb, len, XFS_RMAP_OWN_COW);
	__xfs_refcount_add(tp, XFS_REFCOUNT_FREE_COW, fsb, len);
}

+12 −5
Original line number Diff line number Diff line
@@ -2710,6 +2710,7 @@ __xfs_rmap_add(
	struct xfs_trans		*tp,
	enum xfs_rmap_intent_type	type,
	uint64_t			owner,
	bool				isrt,
	int				whichfork,
	struct xfs_bmbt_irec		*bmap)
{
@@ -2721,6 +2722,7 @@ __xfs_rmap_add(
	ri->ri_owner = owner;
	ri->ri_whichfork = whichfork;
	ri->ri_bmap = *bmap;
	ri->ri_realtime = isrt;

	xfs_rmap_defer_add(tp, ri);
}
@@ -2734,6 +2736,7 @@ xfs_rmap_map_extent(
	struct xfs_bmbt_irec	*PREV)
{
	enum xfs_rmap_intent_type type = XFS_RMAP_MAP;
	bool			isrt = xfs_ifork_is_realtime(ip, whichfork);

	if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
		return;
@@ -2741,7 +2744,7 @@ xfs_rmap_map_extent(
	if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
		type = XFS_RMAP_MAP_SHARED;

	__xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
	__xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV);
}

/* Unmap an extent out of a file. */
@@ -2753,6 +2756,7 @@ xfs_rmap_unmap_extent(
	struct xfs_bmbt_irec	*PREV)
{
	enum xfs_rmap_intent_type type = XFS_RMAP_UNMAP;
	bool			isrt = xfs_ifork_is_realtime(ip, whichfork);

	if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
		return;
@@ -2760,7 +2764,7 @@ xfs_rmap_unmap_extent(
	if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
		type = XFS_RMAP_UNMAP_SHARED;

	__xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
	__xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV);
}

/*
@@ -2778,6 +2782,7 @@ xfs_rmap_convert_extent(
	struct xfs_bmbt_irec	*PREV)
{
	enum xfs_rmap_intent_type type = XFS_RMAP_CONVERT;
	bool			isrt = xfs_ifork_is_realtime(ip, whichfork);

	if (!xfs_rmap_update_is_needed(mp, whichfork))
		return;
@@ -2785,13 +2790,14 @@ xfs_rmap_convert_extent(
	if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
		type = XFS_RMAP_CONVERT_SHARED;

	__xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
	__xfs_rmap_add(tp, type, ip->i_ino, isrt, whichfork, PREV);
}

/* Schedule the creation of an rmap for non-file data. */
void
xfs_rmap_alloc_extent(
	struct xfs_trans	*tp,
	bool			isrt,
	xfs_fsblock_t		fsbno,
	xfs_extlen_t		len,
	uint64_t		owner)
@@ -2806,13 +2812,14 @@ xfs_rmap_alloc_extent(
	bmap.br_startoff = 0;
	bmap.br_state = XFS_EXT_NORM;

	__xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, XFS_DATA_FORK, &bmap);
	__xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, isrt, XFS_DATA_FORK, &bmap);
}

/* Schedule the deletion of an rmap for non-file data. */
void
xfs_rmap_free_extent(
	struct xfs_trans	*tp,
	bool			isrt,
	xfs_fsblock_t		fsbno,
	xfs_extlen_t		len,
	uint64_t		owner)
@@ -2827,7 +2834,7 @@ xfs_rmap_free_extent(
	bmap.br_startoff = 0;
	bmap.br_state = XFS_EXT_NORM;

	__xfs_rmap_add(tp, XFS_RMAP_FREE, owner, XFS_DATA_FORK, &bmap);
	__xfs_rmap_add(tp, XFS_RMAP_FREE, owner, isrt, XFS_DATA_FORK, &bmap);
}

/* Compare rmap records.  Returns -1 if a < b, 1 if a > b, and 0 if equal. */
Loading