summaryrefslogtreecommitdiff
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-01-05 17:45:56 -0800
committerDarrick J. Wong <djwong@kernel.org>2021-03-25 17:08:43 -0700
commitd3bca84994625cb31f1b0d19053c9d3cd0a837ed (patch)
treeb4cfb8b84ffd4e1f65f865bf6930339d5dad0c4d /fs/xfs
parente86b015e0b2a647dca46381ca442bae41f4b4714 (diff)
xfs: add a realtime flag to the rmap update log redo items
Extend the rmap update (RUI) log items with a new realtime flag that indicates that the updates apply against the realtime rmapbt. We'll wire up the actual rmap code later. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_log_format.h4
-rw-r--r--fs/xfs/libxfs/xfs_refcount.c4
-rw-r--r--fs/xfs/libxfs/xfs_rmap.c66
-rw-r--r--fs/xfs/libxfs/xfs_rmap.h5
-rw-r--r--fs/xfs/scrub/alloc_repair.c2
-rw-r--r--fs/xfs/xfs_rmap_item.c26
6 files changed, 73 insertions, 34 deletions
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index 637d43d512b0..f0c0e690f659 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -656,11 +656,13 @@ struct xfs_map_extent {
#define XFS_RMAP_EXTENT_ATTR_FORK (1U << 31)
#define XFS_RMAP_EXTENT_BMBT_BLOCK (1U << 30)
#define XFS_RMAP_EXTENT_UNWRITTEN (1U << 29)
+#define XFS_RMAP_EXTENT_REALTIME (1U << 28)
#define XFS_RMAP_EXTENT_FLAGS (XFS_RMAP_EXTENT_TYPE_MASK | \
XFS_RMAP_EXTENT_ATTR_FORK | \
XFS_RMAP_EXTENT_BMBT_BLOCK | \
- XFS_RMAP_EXTENT_UNWRITTEN)
+ XFS_RMAP_EXTENT_UNWRITTEN | \
+ XFS_RMAP_EXTENT_REALTIME)
/*
* This is the structure used to lay out an rui log item in the
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index a4895c4fef35..bc62d5cc9bf9 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1657,7 +1657,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, fsb, len, XFS_RMAP_OWN_COW, false);
}
/* Forget a CoW staging event in the refcount btree. */
@@ -1673,7 +1673,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, fsb, len, XFS_RMAP_OWN_COW, false);
__xfs_refcount_add(tp, XFS_REFCOUNT_FREE_COW, fsb, len);
}
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index 1e2b85c9db2b..8097dee31e7e 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -2586,18 +2586,25 @@ __xfs_rmap_add(
enum xfs_rmap_intent_type type,
uint64_t owner,
int whichfork,
- struct xfs_bmbt_irec *bmap)
+ struct xfs_bmbt_irec *bmap,
+ bool realtime)
{
struct xfs_rmap_intent *ri;
- trace_xfs_rmap_defer(tp->t_mountp,
- XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
- type,
- XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
- owner, whichfork,
- bmap->br_startoff,
- bmap->br_blockcount,
- bmap->br_state);
+ if (realtime)
+ trace_xfs_rmap_defer(tp->t_mountp, NULLAGNUMBER, type,
+ bmap->br_startblock, owner, whichfork,
+ bmap->br_startoff, bmap->br_blockcount,
+ bmap->br_state);
+ else
+ trace_xfs_rmap_defer(tp->t_mountp,
+ XFS_FSB_TO_AGNO(tp->t_mountp,
+ bmap->br_startblock),
+ type,
+ XFS_FSB_TO_AGBNO(tp->t_mountp,
+ bmap->br_startblock),
+ owner, whichfork, bmap->br_startoff,
+ bmap->br_blockcount, bmap->br_state);
ri = kmem_alloc(sizeof(struct xfs_rmap_intent), KM_NOFS);
INIT_LIST_HEAD(&ri->ri_list);
@@ -2605,6 +2612,7 @@ __xfs_rmap_add(
ri->ri_owner = owner;
ri->ri_whichfork = whichfork;
ri->ri_bmap = *bmap;
+ ri->ri_realtime = realtime;
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_RMAP, &ri->ri_list);
}
@@ -2618,14 +2626,18 @@ xfs_rmap_map_extent(
struct xfs_bmbt_irec *PREV)
{
enum xfs_rmap_intent_type type = XFS_RMAP_MAP;
+ bool isrt = false;
if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
return;
- if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
- type = XFS_RMAP_MAP_SHARED;
+ if (whichfork != XFS_ATTR_FORK) {
+ if (xfs_is_reflink_inode(ip))
+ type = XFS_RMAP_MAP_SHARED;
+ isrt = XFS_IS_REALTIME_INODE(ip);
+ }
- __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
+ __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV, isrt);
}
/* Unmap an extent out of a file. */
@@ -2637,14 +2649,18 @@ xfs_rmap_unmap_extent(
struct xfs_bmbt_irec *PREV)
{
enum xfs_rmap_intent_type type = XFS_RMAP_UNMAP;
+ bool isrt = false;
if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
return;
- if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
- type = XFS_RMAP_UNMAP_SHARED;
+ if (whichfork != XFS_ATTR_FORK) {
+ if (xfs_is_reflink_inode(ip))
+ type = XFS_RMAP_UNMAP_SHARED;
+ isrt = XFS_IS_REALTIME_INODE(ip);
+ }
- __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
+ __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV, isrt);
}
/*
@@ -2662,14 +2678,18 @@ xfs_rmap_convert_extent(
struct xfs_bmbt_irec *PREV)
{
enum xfs_rmap_intent_type type = XFS_RMAP_CONVERT;
+ bool isrt = false;
if (!xfs_rmap_update_is_needed(mp, whichfork))
return;
- if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip))
- type = XFS_RMAP_CONVERT_SHARED;
+ if (whichfork != XFS_ATTR_FORK) {
+ if (xfs_is_reflink_inode(ip))
+ type = XFS_RMAP_CONVERT_SHARED;
+ isrt = XFS_IS_REALTIME_INODE(ip);
+ }
- __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV);
+ __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV, isrt);
}
/* Schedule the creation of an rmap for non-file data. */
@@ -2678,7 +2698,8 @@ xfs_rmap_alloc_extent(
struct xfs_trans *tp,
xfs_fsblock_t fsbno,
xfs_filblks_t len,
- uint64_t owner)
+ uint64_t owner,
+ bool isrt)
{
struct xfs_bmbt_irec bmap;
@@ -2690,7 +2711,7 @@ 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, XFS_DATA_FORK, &bmap, isrt);
}
/* Schedule the deletion of an rmap for non-file data. */
@@ -2699,7 +2720,8 @@ xfs_rmap_free_extent(
struct xfs_trans *tp,
xfs_fsblock_t fsbno,
xfs_filblks_t len,
- uint64_t owner)
+ uint64_t owner,
+ bool isrt)
{
struct xfs_bmbt_irec bmap;
@@ -2711,7 +2733,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, XFS_DATA_FORK, &bmap, isrt);
}
/* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */
diff --git a/fs/xfs/libxfs/xfs_rmap.h b/fs/xfs/libxfs/xfs_rmap.h
index c187f1a678dd..2d4badc4a531 100644
--- a/fs/xfs/libxfs/xfs_rmap.h
+++ b/fs/xfs/libxfs/xfs_rmap.h
@@ -159,6 +159,7 @@ struct xfs_rmap_intent {
uint64_t ri_owner;
int ri_whichfork;
struct xfs_bmbt_irec ri_bmap;
+ bool ri_realtime;
};
/* functions for updating the rmapbt based on bmbt map/unmap operations */
@@ -170,9 +171,9 @@ void xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_trans *tp,
struct xfs_inode *ip, int whichfork,
struct xfs_bmbt_irec *imap);
void xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_fsblock_t fsbno,
- xfs_filblks_t len, uint64_t owner);
+ xfs_filblks_t len, uint64_t owner, bool isrt);
void xfs_rmap_free_extent(struct xfs_trans *tp, xfs_fsblock_t fsbno,
- xfs_filblks_t len, uint64_t owner);
+ xfs_filblks_t len, uint64_t owner, bool isrt);
void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp,
struct xfs_btree_cur *rcur, int error);
diff --git a/fs/xfs/scrub/alloc_repair.c b/fs/xfs/scrub/alloc_repair.c
index 5c12f83bda27..b5524db983b9 100644
--- a/fs/xfs/scrub/alloc_repair.c
+++ b/fs/xfs/scrub/alloc_repair.c
@@ -449,7 +449,7 @@ xrep_abt_dispose_reservations(
/* Add a deferred rmap for each extent we used. */
if (resv->used > 0)
xfs_rmap_alloc_extent(sc->tp, resv->fsbno, resv->used,
- XFS_RMAP_OWN_AG);
+ XFS_RMAP_OWN_AG, false);
/*
* Add a deferred free for each block we didn't use and now
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index deb852a3c5f6..e3f98d46dda8 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -260,13 +260,16 @@ xfs_trans_set_rmap_flags(
struct xfs_map_extent *rmap,
enum xfs_rmap_intent_type type,
int whichfork,
- xfs_exntst_t state)
+ xfs_exntst_t state,
+ bool rt)
{
rmap->me_flags = 0;
if (state == XFS_EXT_UNWRITTEN)
rmap->me_flags |= XFS_RMAP_EXTENT_UNWRITTEN;
if (whichfork == XFS_ATTR_FORK)
rmap->me_flags |= XFS_RMAP_EXTENT_ATTR_FORK;
+ if (rt)
+ rmap->me_flags |= XFS_RMAP_EXTENT_REALTIME;
switch (type) {
case XFS_RMAP_MAP:
rmap->me_flags |= XFS_RMAP_EXTENT_MAP;
@@ -313,6 +316,7 @@ xfs_trans_log_finish_rmap_update(
xfs_fsblock_t startblock,
xfs_filblks_t blockcount,
xfs_exntst_t state,
+ bool rt,
struct xfs_btree_cur **pcur)
{
int error;
@@ -343,11 +347,19 @@ xfs_rmap_update_diff_items(
struct xfs_mount *mp = priv;
struct xfs_rmap_intent *ra;
struct xfs_rmap_intent *rb;
+ xfs_agnumber_t a_ag, b_ag;
ra = container_of(a, struct xfs_rmap_intent, ri_list);
rb = container_of(b, struct xfs_rmap_intent, ri_list);
- return XFS_FSB_TO_AGNO(mp, ra->ri_bmap.br_startblock) -
- XFS_FSB_TO_AGNO(mp, rb->ri_bmap.br_startblock);
+ if (ra->ri_realtime)
+ a_ag = NULLAGNUMBER;
+ else
+ a_ag = XFS_FSB_TO_AGNO(mp, ra->ri_bmap.br_startblock);
+ if (rb->ri_realtime)
+ b_ag = NULLAGNUMBER;
+ else
+ b_ag = XFS_FSB_TO_AGNO(mp, rb->ri_bmap.br_startblock);
+ return a_ag - b_ag;
}
/* Log rmap updates in the intent item. */
@@ -376,7 +388,7 @@ xfs_rmap_update_log_item(
map->me_startoff = rmap->ri_bmap.br_startoff;
map->me_len = rmap->ri_bmap.br_blockcount;
xfs_trans_set_rmap_flags(map, rmap->ri_type, rmap->ri_whichfork,
- rmap->ri_bmap.br_state);
+ rmap->ri_bmap.br_state, rmap->ri_realtime);
}
static struct xfs_log_item *
@@ -426,7 +438,7 @@ xfs_rmap_update_finish_item(
rmap->ri_type, rmap->ri_owner, rmap->ri_whichfork,
rmap->ri_bmap.br_startoff, rmap->ri_bmap.br_startblock,
rmap->ri_bmap.br_blockcount, rmap->ri_bmap.br_state,
- state);
+ rmap->ri_realtime, state);
kmem_free(rmap);
return error;
}
@@ -513,6 +525,7 @@ xfs_rui_item_recover(
struct xfs_mount *mp = lip->li_mountp;
enum xfs_rmap_intent_type type;
xfs_exntst_t state;
+ bool rt;
int i;
int whichfork;
int error = 0;
@@ -544,6 +557,7 @@ xfs_rui_item_recover(
XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
whichfork = (rmap->me_flags & XFS_RMAP_EXTENT_ATTR_FORK) ?
XFS_ATTR_FORK : XFS_DATA_FORK;
+ rt = !!(rmap->me_flags & XFS_RMAP_EXTENT_REALTIME);
switch (rmap->me_flags & XFS_RMAP_EXTENT_TYPE_MASK) {
case XFS_RMAP_EXTENT_MAP:
type = XFS_RMAP_MAP;
@@ -577,7 +591,7 @@ xfs_rui_item_recover(
error = xfs_trans_log_finish_rmap_update(tp, rudp, type,
rmap->me_owner, whichfork,
rmap->me_startoff, rmap->me_startblock,
- rmap->me_len, state, &rcur);
+ rmap->me_len, state, rt, &rcur);
if (error)
goto abort_error;