[PATCH 1/2] xfs: Introduce XFS_EXTENT_BUSY_IN_TRANS busy extent flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This commit adds the busy extent flag XFS_EXTENT_BUSY_IN_TRANS which can be
used to check if a busy extent is still on a transaction's t_busy list. The
flag will be set when an extent is freed by __xfs_free_extent() and it is
cleared when the busy extent is moved to CIL's busy extent list.

This flag will be used in a future commit to prevent a deadlock when
populating an AG's AGFL.

Signed-off-by: Chandan Babu R <chandanrlinux@xxxxxxxxx>
---
 fs/xfs/libxfs/xfs_alloc.c | 2 +-
 fs/xfs/xfs_extent_busy.h  | 1 +
 fs/xfs/xfs_log_cil.c      | 4 ++++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index aaa19101bb2a..7dc50a435cf4 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -3332,7 +3332,7 @@ __xfs_free_extent(
 	xfs_agblock_t			agbno = XFS_FSB_TO_AGBNO(mp, bno);
 	struct xfs_agf			*agf;
 	int				error;
-	unsigned int			busy_flags = 0;
+	unsigned int			busy_flags = XFS_EXTENT_BUSY_IN_TRANS;
 
 	ASSERT(len != 0);
 	ASSERT(type != XFS_AG_RESV_AGFL);
diff --git a/fs/xfs/xfs_extent_busy.h b/fs/xfs/xfs_extent_busy.h
index 8aea07100092..929f72d1c699 100644
--- a/fs/xfs/xfs_extent_busy.h
+++ b/fs/xfs/xfs_extent_busy.h
@@ -28,6 +28,7 @@ struct xfs_extent_busy {
 	unsigned int	flags;
 #define XFS_EXTENT_BUSY_DISCARDED	0x01	/* undergoing a discard op. */
 #define XFS_EXTENT_BUSY_SKIP_DISCARD	0x02	/* do not discard */
+#define XFS_EXTENT_BUSY_IN_TRANS	0x04
 };
 
 void
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index b0ef071b3cb5..f91b69e92b85 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -390,6 +390,7 @@ xlog_cil_insert_items(
 	struct xfs_cil		*cil = log->l_cilp;
 	struct xfs_cil_ctx	*ctx = cil->xc_ctx;
 	struct xfs_log_item	*lip;
+	struct xfs_extent_busy	*busy;
 	int			len = 0;
 	int			diff_iovecs = 0;
 	int			iclog_space;
@@ -410,6 +411,9 @@ xlog_cil_insert_items(
 	len += iovhdr_res;
 	ctx->nvecs += diff_iovecs;
 
+	list_for_each_entry(busy, &tp->t_busy, list)
+		busy->flags &= ~XFS_EXTENT_BUSY_IN_TRANS;
+
 	/* attach the transaction to the CIL if it has any busy extents */
 	if (!list_empty(&tp->t_busy))
 		list_splice_init(&tp->t_busy, &ctx->busy_extents);
-- 
2.30.2




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux