All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: [PATCH] libxfs: add realtime extent reservation and usage tracking to transactions
Date: Thu, 12 Nov 2020 09:43:45 -0800	[thread overview]
Message-ID: <20201112174345.GT9695@magnolia> (raw)

From: Darrick J. Wong <darrick.wong@oracle.com>

An upcoming patch will add to the deferred ops code the ability to
capture the unfinished deferred ops and transaction reservation for
later replay during log recovery.  This requires transactions to have
the ability to track rt extent reservations and usage, so add that
missing piece now.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
FWIW this should have been a prep patch ahead of "xfs: xfs_defer_capture
should absorb remaining block reservations" but I goofed.  Sorry about
that... :(
---
 include/xfs_trans.h |    2 ++
 libxfs/trans.c      |   14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/include/xfs_trans.h b/include/xfs_trans.h
index 9292a4a54237..f19914068030 100644
--- a/include/xfs_trans.h
+++ b/include/xfs_trans.h
@@ -64,9 +64,11 @@ typedef struct xfs_trans {
 	unsigned int	t_log_res;		/* amt of log space resvd */
 	unsigned int	t_log_count;		/* count for perm log res */
 	unsigned int	t_blk_res;		/* # of blocks resvd */
+	unsigned int	t_rtx_res;
 	xfs_fsblock_t	t_firstblock;		/* first block allocated */
 	struct xfs_mount *t_mountp;		/* ptr to fs mount struct */
 	unsigned int	t_blk_res_used;		/* # of resvd blocks used */
+	unsigned int	t_rtx_res_used;
 	unsigned int	t_flags;		/* misc flags */
 	long		t_icount_delta;		/* superblock icount change */
 	long		t_ifree_delta;		/* superblock ifree change */
diff --git a/libxfs/trans.c b/libxfs/trans.c
index 6838b727350b..912e95b8d708 100644
--- a/libxfs/trans.c
+++ b/libxfs/trans.c
@@ -230,6 +230,7 @@ xfs_trans_reserve(
 			error = -ENOSPC;
 			goto undo_blocks;
 		}
+		tp->t_rtx_res += rtextents;
 	}
 
 	return 0;
@@ -765,6 +766,19 @@ _("Transaction block reservation exceeded! %u > %u\n"),
 		tp->t_ifree_delta += delta;
 		break;
 	case XFS_TRANS_SB_FREXTENTS:
+		/*
+		 * Track the number of rt extents allocated in the transaction.
+		 * Make sure it does not exceed the number reserved.
+		 */
+		if (delta < 0) {
+			tp->t_rtx_res_used += (uint)-delta;
+			if (tp->t_rtx_res_used > tp->t_rtx_res) {
+				fprintf(stderr,
+_("Transaction rt block reservation exceeded! %u > %u\n"),
+					tp->t_rtx_res_used, tp->t_rtx_res);
+				ASSERT(0);
+			}
+		}
 		tp->t_frextents_delta += delta;
 		break;
 	default:

             reply	other threads:[~2020-11-12 17:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 17:43 Darrick J. Wong [this message]
2020-11-14 10:48 ` [PATCH] libxfs: add realtime extent reservation and usage tracking to transactions Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201112174345.GT9695@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.