Skip to contentSkip to conversation

xfs: set xefi_discard when creating a deferred agfl free log intent item

PATCH In review Darrick J. Wong 2 participants 2 messages Oct 22, 2020 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: set xefi_discard when creating a deferred agfl free log intent item

From: Darrick J. Wong <[email protected]>

Make sure that we actually initialize xefi_discard when we're scheduling a deferred free of an AGFL block. This was (eventually) found by the UBSAN while I was banging on realtime rmap problems, but it exists in the upstream codebase. While we're at it, rearrange the structure to reduce the struct size from 64 to 56 bytes.

Fixes fcb762f5de2e ("xfs: add bmapi nodiscard flag")
---
 fs/xfs/libxfs/xfs_alloc.c |    1 +
 fs/xfs/libxfs/xfs_bmap.h  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -0
index 852b536551b5..15640015be9d 100644
@@ -2467,6 +2467,7 @@ xfs_defer_agfl_block(
 	new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
 	new->xefi_blockcount = 1;
 	new->xefi_oinfo = *oinfo;
+	new->xefi_skip_discard = false;
 
 	trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
 
fs/xfs/libxfs/xfs_bmap.h +1 -1
index e1bd484e5548..6747e97a7949 100644
@@ -52,9 +52,9 @@ struct xfs_extent_free_item
 {
 	xfs_fsblock_t		xefi_startblock;/* starting fs block number */
 	xfs_extlen_t		xefi_blockcount;/* number of blocks in extent */
+	bool			xefi_skip_discard;
 	struct list_head	xefi_list;
 	struct xfs_owner_info	xefi_oinfo;	/* extent owner */
-	bool			xefi_skip_discard;
 };
 
 #define	XFS_BMAP_MAX_NMAP	4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Make sure that we actually initialize xefi_discard when we're scheduling a deferred free of an AGFL block. This was (eventually) found by the UBSAN while I was banging on realtime rmap problems, but it exists in the upstream codebase. While we're at it, rearrange the structure to reduce the struct size from 64 to 56 bytes.

Fixes fcb762f5de2e ("xfs: add bmapi nodiscard flag")

---

Quoted 32 lines
 fs/xfs/libxfs/xfs_alloc.c |    1 +
 fs/xfs/libxfs/xfs_bmap.h  |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
fs/xfs/libxfs/xfs_alloc.c +1 -0
index 852b536551b5..15640015be9d 100644
@@ -2467,6 +2467,7 @@ xfs_defer_agfl_block(
 	new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
 	new->xefi_blockcount = 1;
 	new->xefi_oinfo = *oinfo;
+	new->xefi_skip_discard = false;
 
 	trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
 
fs/xfs/libxfs/xfs_bmap.h +1 -1
index e1bd484e5548..6747e97a7949 100644
@@ -52,9 +52,9 @@ struct xfs_extent_free_item
 {
 	xfs_fsblock_t		xefi_startblock;/* starting fs block number */
 	xfs_extlen_t		xefi_blockcount;/* number of blocks in extent */
+	bool			xefi_skip_discard;
 	struct list_head	xefi_list;
 	struct xfs_owner_info	xefi_oinfo;	/* extent owner */
-	bool			xefi_skip_discard;
 };
 
 #define	XFS_BMAP_MAX_NMAP	4