From: Dave Chinner <david@fromorbit.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 2/3] xfs: add a free space extent change reservation
Date: Wed, 9 Sep 2020 18:19:11 +1000 [thread overview]
Message-ID: <20200909081912.1185392-3-david@fromorbit.com> (raw)
In-Reply-To: <20200909081912.1185392-1-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
Lots of the transaction reservation code reserves space for an
extent allocation. It is inconsistently implemented, and many of
them get it wrong. Introduce a new function to calculate the log
space reservation for adding or removing an extent from the free
space btrees.
This function reserves space for logging the AGF, the AGFL and the
free space btrees, avoiding the need to account for them seperately
in every reservation that manipulates free space.
Convert the EFI recovery reservation to use this transaction
reservation as EFI recovery only needs to manipulate the free space
index.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/libxfs/xfs_trans_resv.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c
index da2ec052ac0a..621ddb277dfa 100644
--- a/fs/xfs/libxfs/xfs_trans_resv.c
+++ b/fs/xfs/libxfs/xfs_trans_resv.c
@@ -79,6 +79,23 @@ xfs_allocfree_log_count(
return blocks;
}
+/*
+ * Log reservation required to add or remove a single extent to the free space
+ * btrees. This requires modifying:
+ *
+ * the agf header: 1 sector
+ * the agfl header: 1 sector
+ * the allocation btrees: 2 trees * (max depth - 1) * block size
+ */
+uint
+xfs_allocfree_extent_res(
+ struct xfs_mount *mp)
+{
+ return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
+ xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
+ XFS_FSB_TO_B(mp, 1));
+}
+
/*
* Logging inodes is really tricksy. They are logged in memory format,
* which means that what we write into the log doesn't directly translate into
@@ -922,7 +939,7 @@ xfs_trans_resv_calc(
* EFI recovery is itruncate minus the initial transaction that logs
* logs the EFI.
*/
- resp->tr_efi.tr_logres = resp->tr_itruncate.tr_logres;
+ resp->tr_efi.tr_logres = xfs_allocfree_extent_res(mp);
resp->tr_efi.tr_logcount = resp->tr_itruncate.tr_logcount - 1;
resp->tr_efi.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
--
2.28.0
next prev parent reply other threads:[~2020-09-09 8:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 8:19 [PATCH 0/3] [RFC] xfs: intent recovery reservation changes Dave Chinner
2020-09-09 8:19 ` [PATCH 1/3] xfs: EFI recovery needs it's own transaction reservation Dave Chinner
2020-09-09 13:31 ` Brian Foster
2020-09-09 21:44 ` Dave Chinner
2020-09-10 13:18 ` Brian Foster
2020-09-10 21:29 ` Dave Chinner
2020-09-11 12:37 ` Brian Foster
2020-09-09 8:19 ` Dave Chinner [this message]
2020-09-09 13:35 ` [PATCH 2/3] xfs: add a free space extent change reservation Brian Foster
2020-09-09 22:51 ` Dave Chinner
2020-09-10 13:19 ` Brian Foster
2020-09-09 8:19 ` [PATCH 3/3] xfs: factor free space tree transaciton reservations Dave Chinner
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=20200909081912.1185392-3-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox