From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH v2 12/20] gfs2: Clean up gfs2_log_reserve
Date: Tue, 22 Dec 2020 09:19:26 -0500 (EST) [thread overview]
Message-ID: <2102390291.38869885.1608646766751.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20201219204848.285781-13-agruenba@redhat.com>
Hi,
Comments inline.
----- Original Message -----
> Wake up log waiters in gfs2_log_release when log space has actually become
> available. This is a much better place for the wakeup than gfs2_logd.
>
> Check if enough log space is immeditely available before anything else. If
> there isn't, use io_wait_event to wait instead of open-coding it.
>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
> fs/gfs2/log.c | 54 ++++++++++++++++++++++-----------------------------
> 1 file changed, 23 insertions(+), 31 deletions(-)
>
> diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
> index 95ad444bd3dc..7a65823ad1f3 100644
> --- a/fs/gfs2/log.c
> +++ b/fs/gfs2/log.c
> @@ -420,6 +420,8 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int
> blks)
> trace_gfs2_log_blocks(sdp, blks);
> gfs2_assert_withdraw(sdp, atomic_read(&sdp->sd_log_blks_free) <=
> sdp->sd_jdesc->jd_blocks);
> + if (atomic_read(&sdp->sd_log_blks_needed))
> + wake_up(&sdp->sd_log_waitq);
> }
>
> /**
> @@ -444,36 +446,33 @@ void gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned
> int blks)
> {
> unsigned reserved_blks = 7 * (4096 / sdp->sd_vfs->s_blocksize);
> unsigned wanted = blks + reserved_blks;
> - DEFINE_WAIT(wait);
> - int did_wait = 0;
> unsigned int free_blocks;
>
> - atomic_add(blks, &sdp->sd_log_blks_needed);
> -retry:
> free_blocks = atomic_read(&sdp->sd_log_blks_free);
> - if (unlikely(free_blocks <= wanted)) {
> - do {
> - prepare_to_wait_exclusive(&sdp->sd_log_waitq, &wait,
> - TASK_UNINTERRUPTIBLE);
> + while (free_blocks >= wanted) {
> + if (atomic_try_cmpxchg(&sdp->sd_log_blks_free, &free_blocks,
> + free_blocks - blks))
> + return;
This would be a good place to have cond_resched() or schedule() or something, no?
> + }
> +
> + atomic_add(blks, &sdp->sd_log_blks_needed);
> + for (;;) {
> + if (current != sdp->sd_logd_process)
> wake_up(&sdp->sd_logd_waitq);
> - did_wait = 1;
> - if (atomic_read(&sdp->sd_log_blks_free) <= wanted)
> - io_schedule();
> - free_blocks = atomic_read(&sdp->sd_log_blks_free);
> - } while(free_blocks <= wanted);
> - finish_wait(&sdp->sd_log_waitq, &wait);
> + io_wait_event(sdp->sd_log_waitq,
> + (free_blocks = atomic_read(&sdp->sd_log_blks_free),
> + free_blocks >= wanted));
> + do {
> + if (atomic_try_cmpxchg(&sdp->sd_log_blks_free,
> + &free_blocks,
> + free_blocks - blks))
> + goto reserved;
Same here. We need to test these patches with a minimal number of cpus.
> + } while (free_blocks >= wanted);
> }
> - if (atomic_cmpxchg(&sdp->sd_log_blks_free, free_blocks,
> - free_blocks - blks) != free_blocks)
> - goto retry;
> - atomic_sub(blks, &sdp->sd_log_blks_needed);
> - trace_gfs2_log_blocks(sdp, -blks);
>
> - /*
> - * If we waited, then so might others, wake them up _after_ we get
> - * our share of the log.
> - */
> - if (unlikely(did_wait))
> +reserved:
> + trace_gfs2_log_blocks(sdp, -blks);
> + if (atomic_sub_return(blks, &sdp->sd_log_blks_needed))
> wake_up(&sdp->sd_log_waitq);
> }
>
> @@ -1190,7 +1189,6 @@ int gfs2_logd(void *data)
> struct gfs2_sbd *sdp = data;
> unsigned long t = 1;
> DEFINE_WAIT(wait);
> - bool did_flush;
>
> while (!kthread_should_stop()) {
>
> @@ -1209,12 +1207,10 @@ int gfs2_logd(void *data)
> continue;
> }
>
> - did_flush = false;
> if (gfs2_jrnl_flush_reqd(sdp) || t == 0) {
> gfs2_ail1_empty(sdp, 0);
> gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL |
> GFS2_LFC_LOGD_JFLUSH_REQD);
> - did_flush = true;
> }
>
> if (gfs2_ail_flush_reqd(sdp)) {
> @@ -1223,12 +1219,8 @@ int gfs2_logd(void *data)
> gfs2_ail1_empty(sdp, 0);
> gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL |
> GFS2_LFC_LOGD_AIL_FLUSH_REQD);
> - did_flush = true;
> }
>
> - if (!gfs2_ail_flush_reqd(sdp) || did_flush)
> - wake_up(&sdp->sd_log_waitq);
> -
> t = gfs2_tune_get(sdp, gt_logd_secs) * HZ;
>
> try_to_freeze();
> --
> 2.26.2
>
>
next prev parent reply other threads:[~2020-12-22 14:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-19 20:48 [Cluster-devel] [PATCH v2 00/20] Some log space management cleanups Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 01/20] gfs2: Deobfuscate function jdesc_find_i Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 02/20] gfs2: Simplify the buf_limit and databuf_limit definitions Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 03/20] gfs2: Minor gfs2_write_revokes cleanups Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 04/20] gfs2: Some documentation updates Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 05/20] gfs2: A minor debugging improvement Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 06/20] gfs2: Rename gfs2_{write => add_aux}_revokes Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 07/20] gfs2: Clean up ail2_empty Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 08/20] gfs2: Get rid of on-stack transactions Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 09/20] gfs2: Get rid of sd_reserving_log Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 10/20] gfs2: Move lock flush locking to gfs2_trans_{begin, end} Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 11/20] gfs2: Don't wait for journal flush in clean_journal Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 12/20] gfs2: Clean up gfs2_log_reserve Andreas Gruenbacher
2020-12-22 14:19 ` Bob Peterson [this message]
2020-12-22 15:12 ` Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 13/20] gfs2: Use a tighter bound in gfs2_trans_begin Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 14/20] gfs2: Get rid of current_tail() Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 15/20] gfs2: Move function gfs2_ail_empty_tr Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 16/20] gfs2: No revokes for transactions at the tail of the log Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 17/20] gfs2: Remove sd_log_committed_revoke Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 18/20] gfs2: Remove sd_log_blks_reserved Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 19/20] gfs2: Rework the log space allocation logic Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 20/20] gfs2: Hand out revokes to transactions one by one 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=2102390291.38869885.1608646766751.JavaMail.zimbra@redhat.com \
--to=rpeterso@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).