cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH 6/9] gfs2: Make secondary withdrawers wait for first withdrawer
Date: Wed, 13 Feb 2019 08:21:27 -0700	[thread overview]
Message-ID: <20190213152130.8047-7-rpeterso@redhat.com> (raw)
In-Reply-To: <20190213152130.8047-1-rpeterso@redhat.com>

Before this patch, if a process encountered an error and decided to
withdraw, if another process was already in the process of withdrawing,
the secondary withdraw would be silently ignored, which set it free
to proceed with its processing, unlock any locks, etc. That's correct
behavior if the original withdrawer encounters further errors down
the road. However, second withdrawers need to wait for the first
withdrawer to finish its withdraw before proceeding. If we don't wait
we could end up assuming everything is alright, unlock glocks and
telling other nodes they can have the glock, despite the fact that
a withdraw is still ongoing and may require a journal replay before
any locks are released. For example, if an rgrp glock is freed
by a process that didn't wait for the withdraw, a journal replay
could introduce file system corruption by replaying a rgrp block
that has already been granted to another node.

This patch makes secondary withdrawers wait until the primary
withdrawer is finished with its processing before proceeding.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
 fs/gfs2/incore.h | 3 +++
 fs/gfs2/util.c   | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 2ddae1326ce2..51ca34594ac2 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -626,6 +626,7 @@ enum {
 	SDF_REMOTE_WITHDRAW	= 12, /* Performing remote recovery */
 	SDF_WITHDRAW_RECOVERY	= 13, /* Wait for journal recovery when we are
 					 withdrawing */
+	SDF_WITHDRAW_COMPLETE	= 14, /* Withdraw is compete */
 };
 
 enum gfs2_freeze_state {
@@ -836,6 +837,8 @@ struct gfs2_sbd {
 	struct bio *sd_log_bio;
 	wait_queue_head_t sd_log_flush_wait;
 	int sd_log_error;
+	atomic_t sd_withdrawer;
+	wait_queue_head_t sd_withdraw_wait;
 
 	atomic_t sd_reserving_log;
 	wait_queue_head_t sd_reserving_log_wait;
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c
index 75f67284bba8..6e0a85fc1d46 100644
--- a/fs/gfs2/util.c
+++ b/fs/gfs2/util.c
@@ -188,9 +188,15 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...)
 	struct va_format vaf;
 
 	if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW &&
-	    test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags))
+	    test_and_set_bit(SDF_SHUTDOWN, &sdp->sd_flags)) {
+		fs_warn(sdp, "Waiting for process %d to withdraw.\n",
+			atomic_read(&sdp->sd_withdrawer));
+		wait_on_bit(&sdp->sd_flags, SDF_WITHDRAW_COMPLETE,
+			    TASK_UNINTERRUPTIBLE);
 		return 0;
+	}
 
+	atomic_set(&sdp->sd_withdrawer, pid_nr(task_pid(current)));
 	clear_bit(SDF_PENDING_WITHDRAW, &sdp->sd_flags);
 	if (fmt) {
 		va_start(args, fmt);
@@ -221,6 +227,7 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...)
 		set_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags);
 		fs_err(sdp, "File system withdrawn\n");
 		dump_stack();
+		wake_up_bit(&sdp->sd_flags, SDF_WITHDRAW_COMPLETE);
 	}
 
 	if (sdp->sd_args.ar_errors == GFS2_ERRORS_PANIC)
-- 
2.20.1



  parent reply	other threads:[~2019-02-13 15:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 15:21 [Cluster-devel] [GFS2 PATCH 0/9] GFS2: Withdraw corruption patches Bob Peterson
2019-02-13 15:21 ` [Cluster-devel] [GFS2 PATCH 1/9] gfs2: Introduce concept of a pending withdraw Bob Peterson
2019-02-15 11:37   ` Steven Whitehouse
2019-02-13 15:21 ` [Cluster-devel] [GFS2 PATCH 2/9] gfs2: Ignore recovery attempts if gfs2 has io error or is withdrawn Bob Peterson
2019-02-13 15:21 ` [Cluster-devel] [GFS2 PATCH 3/9] gfs2: Empty the ail for the glock when rgrps are invalidated Bob Peterson
2019-02-15 11:47   ` Steven Whitehouse
2019-02-13 15:21 ` [Cluster-devel] [GFS2 PATCH 4/9] gfs2: Force withdraw to replay journals and wait for it to finish Bob Peterson
2019-02-15 11:55   ` Steven Whitehouse
2019-02-13 15:21 ` [Cluster-devel] [GFS2 PATCH 5/9] gfs2: Keep transactions on ail1 list until after issuing revokes Bob Peterson
2019-02-15 11:56   ` Steven Whitehouse
2019-02-13 15:21 ` Bob Peterson [this message]
2019-02-13 15:21 ` [Cluster-devel] [GFS2 PATCH 7/9] gfs2: Check for log write errors and withdraw in rgrp_go_inval Bob Peterson
2019-02-13 15:21 ` [Cluster-devel] [GFS2 PATCH 8/9] gfs2: Do log_flush in gfs2_ail_empty_gl even if ail list is empty Bob Peterson
2019-02-15 12:01   ` Steven Whitehouse
2019-02-13 15:21 ` [Cluster-devel] [GFS2 PATCH 9/9] dlm: recover slot regardless of whether we still have a connection Bob Peterson

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=20190213152130.8047-7-rpeterso@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).