cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 19/22] GFS2: Improve journal allocation via sysfs
Date: Mon, 18 Oct 2010 15:15:43 +0100	[thread overview]
Message-ID: <1287411346-17855-20-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1287411346-17855-1-git-send-email-swhiteho@redhat.com>

Recently a feature was added to GFS2 to allow journal id allocation
via sysfs. This patch builds upon that so that a negative journal id
will be treated as an error code to be passed back as the return code
from mount. This allows termination of the mount process if there is
a failure.

Also, the process has been updated so that the kernel will wait
for a journal id, even in the "spectator" case. This is required
in order to avoid mounting a filesystem in case there is an error
while joining the cluster. In the spectator case, 0 is written into
the file to indicate that all is well, and that mount should continue.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 6f6ff8a..764fbb4 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -494,7 +494,7 @@ struct gfs2_sb_host {
  */
 
 struct lm_lockstruct {
-	unsigned int ls_jid;
+	int ls_jid;
 	unsigned int ls_first;
 	unsigned int ls_first_done;
 	unsigned int ls_nodir;
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 5b11f37..aeafc23 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1056,8 +1056,6 @@ static int gfs2_journalid_wait(void *word)
 
 static int wait_on_journal(struct gfs2_sbd *sdp)
 {
-	if (sdp->sd_args.ar_spectator)
-		return 0;
 	if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
 		return 0;
 
@@ -1160,6 +1158,20 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
 	if (error)
 		goto fail_sb;
 
+	/*
+	 * If user space has failed to join the cluster or some similar
+	 * failure has occurred, then the journal id will contain a
+	 * negative (error) number. This will then be returned to the
+	 * caller (of the mount syscall). We do this even for spectator
+	 * mounts (which just write a jid of 0 to indicate "ok" even though
+	 * the jid is unused in the spectator case)
+	 */
+	if (sdp->sd_lockstruct.ls_jid < 0) {
+		error = sdp->sd_lockstruct.ls_jid;
+		sdp->sd_lockstruct.ls_jid = 0;
+		goto fail_sb;
+	}
+
 	error = init_inodes(sdp, DO);
 	if (error)
 		goto fail_sb;
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index ccacffd..64082a5 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -399,31 +399,32 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf)
 
 static ssize_t jid_show(struct gfs2_sbd *sdp, char *buf)
 {
-	return sprintf(buf, "%u\n", sdp->sd_lockstruct.ls_jid);
+	return sprintf(buf, "%d\n", sdp->sd_lockstruct.ls_jid);
 }
 
 static ssize_t jid_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
 {
-        unsigned jid;
+        int jid;
 	int rv;
 
-	rv = sscanf(buf, "%u", &jid);
+	rv = sscanf(buf, "%d", &jid);
 	if (rv != 1)
 		return -EINVAL;
 
 	spin_lock(&sdp->sd_jindex_spin);
 	rv = -EINVAL;
-	if (sdp->sd_args.ar_spectator)
-		goto out;
 	if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
 		goto out;
 	rv = -EBUSY;
-	if (test_and_clear_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0)
+	if (test_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0)
 		goto out;
+	rv = 0;
+	if (sdp->sd_args.ar_spectator && jid > 0)
+		rv = jid = -EINVAL;
 	sdp->sd_lockstruct.ls_jid = jid;
+	clear_bit(SDF_NOJOURNALID, &sdp->sd_flags);
 	smp_mb__after_clear_bit();
 	wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID);
-	rv = 0;
 out:
 	spin_unlock(&sdp->sd_jindex_spin);
 	return rv ? rv : len;
@@ -617,7 +618,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
 	add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name);
 	add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
 	if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags))
-		add_uevent_var(env, "JOURNALID=%u", sdp->sd_lockstruct.ls_jid);
+		add_uevent_var(env, "JOURNALID=%d", sdp->sd_lockstruct.ls_jid);
 	if (gfs2_uuid_valid(uuid))
 		add_uevent_var(env, "UUID=%pUB", uuid);
 	return 0;
-- 
1.7.1.1



  parent reply	other threads:[~2010-10-18 14:15 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-18 14:15 [Cluster-devel] GFS2: Pre-pull patch posting Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 01/22] GFS2: New truncate sequence Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 02/22] GFS2: Remove i_disksize Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 03/22] GFS2: No longer experimental Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 04/22] GFS2: Add a bug trap in allocation code Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 05/22] GFS2: fallocate support Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 06/22] GFS2: Fix whitespace in previous patch Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 07/22] GFS2: Don't enforce min hold time when two demotes occur in rapid succession Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 08/22] GFS2: Update handling of DLM return codes to match reality Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 09/22] GFS2: Use new workqueue scheme Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 10/22] GFS2: Make . and .. qstrs constant Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 11/22] GFS2: Remove ignore_local_fs mount argument Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 12/22] GFS2: Remove localcaching mount option Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 13/22] GFS2: Remove upgrade " Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 14/22] GFS2: Fix journal check for spectator mounts Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 15/22] GFS2: reserve more blocks for transactions Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 16/22] GFS2: Fix compiler warning from previous patch Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 17/22] GFS2: Fix spectator umount issue Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 18/22] GFS2: Add "norecovery" mount option as a synonym for "spectator" Steven Whitehouse
2010-10-18 14:15 ` Steven Whitehouse [this message]
2010-10-18 14:15 ` [Cluster-devel] [PATCH 20/22] GFS2 fatal: filesystem consistency error on rename Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 21/22] GFS2: Fix type mapping for demote_rq interface Steven Whitehouse
2010-10-18 14:15 ` [Cluster-devel] [PATCH 22/22] GFS2: fixed typo 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=1287411346-17855-20-git-send-email-swhiteho@redhat.com \
    --to=swhiteho@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).