From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, david@fromorbit.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 4/9] xfs: create shadow transaction reservations for computing minimum log size
Date: Tue, 26 Apr 2022 17:52:14 -0700 [thread overview]
Message-ID: <165102073482.3922658.3874181264513799865.stgit@magnolia> (raw)
In-Reply-To: <165102071223.3922658.5241787533081256670.stgit@magnolia>
From: Darrick J. Wong <djwong@kernel.org>
Every time someone changes the transaction reservation sizes, they
introduce potential compatibility problems if the changes affect the
minimum log size that we validate at mount time. If the minimum log
size gets larger (which should be avoided because doing so presents a
serious risk of log livelock), filesystems created with old mkfs will
not mount on a newer kernel; if the minimum size shrinks, filesystems
created with newer mkfs will not mount on older kernels.
Therefore, enable the creation of a shadow log reservation structure
where we can "undo" the effects of tweaks when computing minimum log
sizes. These shadow reservations should never be used in practice, but
they insulate us from perturbations in minimum log size.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/libxfs/xfs_log_rlimit.c | 15 +++++++++++----
fs/xfs/xfs_trace.h | 12 ++++++++++--
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_log_rlimit.c b/fs/xfs/libxfs/xfs_log_rlimit.c
index 67798ff5e14e..4d04568ab07e 100644
--- a/fs/xfs/libxfs/xfs_log_rlimit.c
+++ b/fs/xfs/libxfs/xfs_log_rlimit.c
@@ -14,6 +14,7 @@
#include "xfs_trans_space.h"
#include "xfs_da_btree.h"
#include "xfs_bmap_btree.h"
+#include "xfs_trace.h"
/*
* Calculate the maximum length in bytes that would be required for a local
@@ -46,19 +47,25 @@ xfs_log_get_max_trans_res(
struct xfs_mount *mp,
struct xfs_trans_res *max_resp)
{
+ struct xfs_trans_resv resv;
struct xfs_trans_res *resp;
struct xfs_trans_res *end_resp;
+ unsigned int i;
int log_space = 0;
int attr_space;
attr_space = xfs_log_calc_max_attrsetm_res(mp);
- resp = (struct xfs_trans_res *)M_RES(mp);
- end_resp = (struct xfs_trans_res *)(M_RES(mp) + 1);
- for (; resp < end_resp; resp++) {
+ memcpy(&resv, M_RES(mp), sizeof(struct xfs_trans_resv));
+
+ resp = (struct xfs_trans_res *)&resv;
+ end_resp = (struct xfs_trans_res *)(&resv + 1);
+ for (i = 0; resp < end_resp; i++, resp++) {
int tmp = resp->tr_logcount > 1 ?
resp->tr_logres * resp->tr_logcount :
resp->tr_logres;
+
+ trace_xfs_trans_resv_calc_minlogsize(mp, i, resp);
if (log_space < tmp) {
log_space = tmp;
*max_resp = *resp; /* struct copy */
@@ -66,7 +73,7 @@ xfs_log_get_max_trans_res(
}
if (attr_space > log_space) {
- *max_resp = M_RES(mp)->tr_attrsetm; /* struct copy */
+ *max_resp = resv.tr_attrsetm; /* struct copy */
max_resp->tr_logres = attr_space;
}
}
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 91b916e82364..9110bb5dd866 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -3500,7 +3500,7 @@ DEFINE_GETFSMAP_EVENT(xfs_getfsmap_low_key);
DEFINE_GETFSMAP_EVENT(xfs_getfsmap_high_key);
DEFINE_GETFSMAP_EVENT(xfs_getfsmap_mapping);
-TRACE_EVENT(xfs_trans_resv_calc,
+DECLARE_EVENT_CLASS(xfs_trans_resv_class,
TP_PROTO(struct xfs_mount *mp, unsigned int type,
struct xfs_trans_res *res),
TP_ARGS(mp, type, res),
@@ -3524,7 +3524,15 @@ TRACE_EVENT(xfs_trans_resv_calc,
__entry->logres,
__entry->logcount,
__entry->logflags)
-);
+)
+
+#define DEFINE_TRANS_RESV_EVENT(name) \
+DEFINE_EVENT(xfs_trans_resv_class, name, \
+ TP_PROTO(struct xfs_mount *mp, unsigned int type, \
+ struct xfs_trans_res *res), \
+ TP_ARGS(mp, type, res))
+DEFINE_TRANS_RESV_EVENT(xfs_trans_resv_calc);
+DEFINE_TRANS_RESV_EVENT(xfs_trans_resv_calc_minlogsize);
DECLARE_EVENT_CLASS(xfs_trans_class,
TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip),
next prev parent reply other threads:[~2022-04-27 0:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 0:51 [PATCHSET v2 0/9] xfs: fix reflink inefficiencies Darrick J. Wong
2022-04-27 0:51 ` [PATCH 1/9] xfs: count EFIs when deciding to ask for a continuation of a refcount update Darrick J. Wong
2022-04-27 22:59 ` Darrick J. Wong
2022-04-28 12:46 ` Christoph Hellwig
2022-04-27 0:52 ` [PATCH 2/9] xfs: stop artificially limiting the length of bunmap calls Darrick J. Wong
2022-04-28 12:46 ` Christoph Hellwig
2022-04-27 0:52 ` [PATCH 3/9] xfs: remove a __xfs_bunmapi call from reflink Darrick J. Wong
2022-04-27 0:52 ` Darrick J. Wong [this message]
2022-04-27 4:28 ` [PATCH 4/9] xfs: create shadow transaction reservations for computing minimum log size Dave Chinner
2022-04-28 12:50 ` Christoph Hellwig
2022-04-27 0:52 ` [PATCH 5/9] xfs: report "max_resp" used for min log size computation Darrick J. Wong
2022-04-27 4:28 ` Dave Chinner
2022-04-28 12:51 ` Christoph Hellwig
2022-04-27 0:52 ` [PATCH 6/9] xfs: reduce the absurdly large log operation count Darrick J. Wong
2022-04-27 4:29 ` Dave Chinner
2022-04-28 12:54 ` Christoph Hellwig
2022-04-27 0:52 ` [PATCH 7/9] xfs: reduce transaction reservations with reflink Darrick J. Wong
2022-04-27 4:30 ` Dave Chinner
2022-04-28 12:55 ` Christoph Hellwig
2022-04-27 0:52 ` [PATCH 8/9] xfs: rewrite xfs_reflink_end_cow to use intents Darrick J. Wong
2022-04-28 12:56 ` Christoph Hellwig
2022-04-27 0:52 ` [PATCH 9/9] xfs: rename xfs_*alloc*_log_count to _block_count Darrick J. Wong
2022-04-27 4:32 ` Dave Chinner
2022-04-28 12:56 ` 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=165102073482.3922658.3874181264513799865.stgit@magnolia \
--to=djwong@kernel.org \
--cc=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 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.