From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH v3 18/20] gfs2: Remove sd_log_blks_reserved
Date: Wed, 27 Jan 2021 22:07:44 +0100 [thread overview]
Message-ID: <20210127210746.16958-19-agruenba@redhat.com> (raw)
In-Reply-To: <20210127210746.16958-1-agruenba@redhat.com>
Now that sdp->sd_log_tr is defined even when the transaction only
indicates revokes, tr_reserved is equivalent to sd_log_blks_reserved,
so we can remove it.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/incore.h | 1 -
fs/gfs2/log.c | 21 ++++++++++-----------
fs/gfs2/log.h | 2 +-
fs/gfs2/lops.c | 2 +-
4 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 3589d02d1df9..5d50c3695f17 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -819,7 +819,6 @@ struct gfs2_sbd {
spinlock_t sd_log_lock;
struct gfs2_trans *sd_log_tr;
- unsigned int sd_log_blks_reserved;
atomic_t sd_log_pinned;
unsigned int sd_log_num_revoke;
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 1ce4300aa81a..34c8291c9131 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -703,6 +703,7 @@ void gfs2_glock_remove_revoke(struct gfs2_glock *gl)
/**
* gfs2_flush_revokes - Add as many revokes to the system transaction as we can
* @sdp: The GFS2 superblock
+ * @tr: The transaction
*
* Our usual strategy is to defer writing revokes as much as we can in the hope
* that we'll eventually overwrite the journal, which will make those revokes
@@ -712,7 +713,7 @@ void gfs2_glock_remove_revoke(struct gfs2_glock *gl)
* been written back. This will basically come at no cost now, and will save
* us from having to keep track of those blocks on the AIL2 list later.
*/
-void gfs2_flush_revokes(struct gfs2_sbd *sdp)
+void gfs2_flush_revokes(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
{
/* number of revokes we still have room for */
unsigned int max_revokes;
@@ -727,7 +728,7 @@ void gfs2_flush_revokes(struct gfs2_sbd *sdp)
atomic_dec(&sdp->sd_log_blks_free);
/* If no blocks have been reserved, we need to also
* reserve a block for the header */
- if (!sdp->sd_log_blks_reserved) {
+ if (!tr) {
atomic_dec(&sdp->sd_log_blks_free);
trace_gfs2_log_blocks(sdp, -2);
} else {
@@ -739,7 +740,7 @@ void gfs2_flush_revokes(struct gfs2_sbd *sdp)
if (!sdp->sd_log_num_revoke) {
atomic_inc(&sdp->sd_log_blks_free);
- if (!sdp->sd_log_blks_reserved) {
+ if (!tr) {
atomic_inc(&sdp->sd_log_blks_free);
trace_gfs2_log_blocks(sdp, 2);
} else {
@@ -1019,7 +1020,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
gfs2_log_lock(sdp);
gfs2_log_update_head(sdp);
- sdp->sd_log_blks_reserved = 0;
spin_lock(&sdp->sd_ail_lock);
if (tr && !list_empty(&tr->tr_ail1_list)) {
@@ -1084,6 +1084,7 @@ static void gfs2_merge_trans(struct gfs2_sbd *sdp, struct gfs2_trans *new)
WARN_ON_ONCE(!test_bit(TR_ATTACHED, &old->tr_flags));
+ old->tr_reserved += new->tr_reserved;
old->tr_num_buf_new += new->tr_num_buf_new;
old->tr_num_databuf_new += new->tr_num_databuf_new;
old->tr_num_buf_rm += new->tr_num_buf_rm;
@@ -1104,24 +1105,23 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
{
unsigned int reserved;
unsigned int unused;
- unsigned int maxres;
gfs2_log_lock(sdp);
if (sdp->sd_log_tr) {
gfs2_merge_trans(sdp, tr);
+ tr = sdp->sd_log_tr;
} else {
sdp->sd_log_tr = tr;
set_bit(TR_ATTACHED, &tr->tr_flags);
}
- reserved = calc_reserved(sdp);
- maxres = sdp->sd_log_blks_reserved + tr->tr_reserved;
- gfs2_assert_withdraw(sdp, maxres >= reserved);
- unused = maxres - reserved;
+ reserved = tr->tr_reserved;
+ tr->tr_reserved = calc_reserved(sdp);
+ gfs2_assert_withdraw(sdp, reserved >= tr->tr_reserved);
+ unused = reserved - tr->tr_reserved;
if (unused)
gfs2_log_release(sdp, unused);
- sdp->sd_log_blks_reserved = reserved;
gfs2_log_unlock(sdp);
}
@@ -1159,7 +1159,6 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
static void gfs2_log_shutdown(struct gfs2_sbd *sdp)
{
- gfs2_assert_withdraw(sdp, !sdp->sd_log_blks_reserved);
gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke);
gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail1_list));
diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h
index b36a3539f352..f3c8e4285ec9 100644
--- a/fs/gfs2/log.h
+++ b/fs/gfs2/log.h
@@ -81,6 +81,6 @@ extern void log_flush_wait(struct gfs2_sbd *sdp);
extern int gfs2_logd(void *data);
extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
extern void gfs2_glock_remove_revoke(struct gfs2_glock *gl);
-extern void gfs2_flush_revokes(struct gfs2_sbd *sdp);
+extern void gfs2_flush_revokes(struct gfs2_sbd *sdp, struct gfs2_trans *tr);
#endif /* __LOG_DOT_H__ */
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 8658ebbcb4a9..db554f7623ec 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -845,7 +845,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
struct page *page;
unsigned int length;
- gfs2_flush_revokes(sdp);
+ gfs2_flush_revokes(sdp, tr);
if (!sdp->sd_log_num_revoke)
return;
--
2.26.2
next prev parent reply other threads:[~2021-01-27 21:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 21:07 [Cluster-devel] [PATCH v3 00/20] Some log space management cleanups Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 01/20] gfs2: Un-obfuscate function jdesc_find_i Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 02/20] gfs2: Simplify the buf_limit and databuf_limit definitions Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 03/20] gfs2: Minor gfs2_write_revokes cleanups Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 04/20] gfs2: Some documentation updates Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 05/20] gfs2: Minor debugging improvement Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 06/20] gfs2: Rename gfs2_{write => flush}_revokes Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 07/20] gfs2: Clean up ail2_empty Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 08/20] gfs2: Get rid of on-stack transactions Andreas Gruenbacher
2021-01-28 9:21 ` Steven Whitehouse
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 09/20] gfs2: Get rid of sd_reserving_log Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 10/20] gfs2: Move lock flush locking to gfs2_trans_{begin, end} Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 11/20] gfs2: Don't wait for journal flush in clean_journal Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 12/20] gfs2: Clean up gfs2_log_reserve Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 13/20] gfs2: Use a tighter bound in gfs2_trans_begin Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 14/20] gfs2: Get rid of current_tail() Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 15/20] gfs2: Move function gfs2_ail_empty_tr Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 16/20] gfs2: No revokes for transactions at the tail of the log Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 17/20] gfs2: Remove sd_log_committed_revoke Andreas Gruenbacher
2021-01-27 21:07 ` Andreas Gruenbacher [this message]
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 19/20] gfs2: Rework the log space allocation logic Andreas Gruenbacher
2021-01-27 21:07 ` [Cluster-devel] [PATCH v3 20/20] gfs2: Per-revoke accounting in transactions Andreas Gruenbacher
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=20210127210746.16958-19-agruenba@redhat.com \
--to=agruenba@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).