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] GFS2: Prevent recovery before the local journal is set
Date: Tue, 25 Mar 2014 11:54:34 -0400 (EDT)	[thread overview]
Message-ID: <1825082538.1542312.1395762874059.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1815025558.1540922.1395762717202.JavaMail.zimbra@redhat.com>

Hi,

This patch repurposes the (formerly useless) sd_jindex_mutex lock to
prevent dlm's recover process from referencing and trying to recover a
journal before a journal has been opened.

Regards,

Bob Peterson
Red Hat File Systems

Signed-off-by: Bob Peterson <rpeterso@redhat.com> 
---
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index fba74a2..b5e844f 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -94,6 +94,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
 	INIT_LIST_HEAD(&sdp->sd_jindex_list);
 	spin_lock_init(&sdp->sd_jindex_spin);
 	mutex_init(&sdp->sd_jindex_mutex);
+	mutex_lock(&sdp->sd_jindex_mutex);
 
 	INIT_LIST_HEAD(&sdp->sd_quota_list);
 	mutex_init(&sdp->sd_quota_mutex);
@@ -548,8 +549,6 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
 
 	name.name = buf;
 
-	mutex_lock(&sdp->sd_jindex_mutex);
-
 	for (;;) {
 		error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, ji_gh);
 		if (error)
@@ -594,8 +593,6 @@ static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
 		spin_unlock(&sdp->sd_jindex_spin);
 	}
 
-	mutex_unlock(&sdp->sd_jindex_mutex);
-
 	return error;
 }
 
@@ -676,6 +673,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
 
 	if (sdp->sd_args.ar_spectator) {
 		sdp->sd_jdesc = gfs2_jdesc_find(sdp, 0);
+		mutex_unlock(&sdp->sd_jindex_mutex);
 		atomic_set(&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks);
 		atomic_set(&sdp->sd_log_thresh1, 2*sdp->sd_jdesc->jd_blocks/5);
 		atomic_set(&sdp->sd_log_thresh2, 4*sdp->sd_jdesc->jd_blocks/5);
@@ -686,9 +684,11 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
 			fs_err(sdp, "there are only %u journals (0 - %u)\n",
 			       gfs2_jindex_size(sdp),
 			       gfs2_jindex_size(sdp) - 1);
+			mutex_unlock(&sdp->sd_jindex_mutex);
 			goto fail_jindex;
 		}
 		sdp->sd_jdesc = gfs2_jdesc_find(sdp, sdp->sd_lockstruct.ls_jid);
+		mutex_unlock(&sdp->sd_jindex_mutex);
 
 		error = gfs2_glock_nq_num(sdp, sdp->sd_lockstruct.ls_jid,
 					  &gfs2_journal_glops,
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index de25d55..73bd32e 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -407,6 +407,7 @@ int gfs2_recover_set(struct gfs2_sbd *sdp, unsigned jid)
 	struct gfs2_jdesc *jd;
 	int rv;
 
+	mutex_lock(&sdp->sd_jindex_mutex);
 	spin_lock(&sdp->sd_jindex_spin);
 	rv = -EBUSY;
 	if (sdp->sd_jdesc->jd_jid == jid)
@@ -420,6 +421,7 @@ int gfs2_recover_set(struct gfs2_sbd *sdp, unsigned jid)
 	}
 out:
 	spin_unlock(&sdp->sd_jindex_spin);
+	mutex_unlock(&sdp->sd_jindex_mutex);
 	return rv;
 }
 



       reply	other threads:[~2014-03-25 15:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1815025558.1540922.1395762717202.JavaMail.zimbra@redhat.com>
2014-03-25 15:54 ` Bob Peterson [this message]
2014-03-26  9:08   ` [Cluster-devel] [GFS2 PATCH] GFS2: Prevent recovery before the local journal is set Steven Whitehouse

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=1825082538.1542312.1395762874059.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).