aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2010-09-29 10:04:18 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2010-09-29 10:04:18 -0400
commitfeb47ca9314666d920855b8a235032dea2b2caa4 (patch)
tree163a391bda495826747eb249cf74b42ad35bd5ec /fs/gfs2
parent43f74c199563a4273e528e2166d0650625a1e05f (diff)
GFS2: Improve journal allocation via sysfs
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>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/incore.h2
-rw-r--r--fs/gfs2/ops_fstype.c16
-rw-r--r--fs/gfs2/sys.c17
3 files changed, 24 insertions, 11 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 6f6ff8aba99a..764fbb49efc8 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -494,7 +494,7 @@ struct gfs2_sb_host {
494 */ 494 */
495 495
496struct lm_lockstruct { 496struct lm_lockstruct {
497 unsigned int ls_jid; 497 int ls_jid;
498 unsigned int ls_first; 498 unsigned int ls_first;
499 unsigned int ls_first_done; 499 unsigned int ls_first_done;
500 unsigned int ls_nodir; 500 unsigned int ls_nodir;
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 5b11f3768144..aeafc233dc89 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1056,8 +1056,6 @@ static int gfs2_journalid_wait(void *word)
1056 1056
1057static int wait_on_journal(struct gfs2_sbd *sdp) 1057static int wait_on_journal(struct gfs2_sbd *sdp)
1058{ 1058{
1059 if (sdp->sd_args.ar_spectator)
1060 return 0;
1061 if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL) 1059 if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
1062 return 0; 1060 return 0;
1063 1061
@@ -1160,6 +1158,20 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
1160 if (error) 1158 if (error)
1161 goto fail_sb; 1159 goto fail_sb;
1162 1160
1161 /*
1162 * If user space has failed to join the cluster or some similar
1163 * failure has occurred, then the journal id will contain a
1164 * negative (error) number. This will then be returned to the
1165 * caller (of the mount syscall). We do this even for spectator
1166 * mounts (which just write a jid of 0 to indicate "ok" even though
1167 * the jid is unused in the spectator case)
1168 */
1169 if (sdp->sd_lockstruct.ls_jid < 0) {
1170 error = sdp->sd_lockstruct.ls_jid;
1171 sdp->sd_lockstruct.ls_jid = 0;
1172 goto fail_sb;
1173 }
1174
1163 error = init_inodes(sdp, DO); 1175 error = init_inodes(sdp, DO);
1164 if (error) 1176 if (error)
1165 goto fail_sb; 1177 goto fail_sb;
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index ccacffd2faaa..64082a5feae1 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)
399 399
400static ssize_t jid_show(struct gfs2_sbd *sdp, char *buf) 400static ssize_t jid_show(struct gfs2_sbd *sdp, char *buf)
401{ 401{
402 return sprintf(buf, "%u\n", sdp->sd_lockstruct.ls_jid); 402 return sprintf(buf, "%d\n", sdp->sd_lockstruct.ls_jid);
403} 403}
404 404
405static ssize_t jid_store(struct gfs2_sbd *sdp, const char *buf, size_t len) 405static ssize_t jid_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
406{ 406{
407 unsigned jid; 407 int jid;
408 int rv; 408 int rv;
409 409
410 rv = sscanf(buf, "%u", &jid); 410 rv = sscanf(buf, "%d", &jid);
411 if (rv != 1) 411 if (rv != 1)
412 return -EINVAL; 412 return -EINVAL;
413 413
414 spin_lock(&sdp->sd_jindex_spin); 414 spin_lock(&sdp->sd_jindex_spin);
415 rv = -EINVAL; 415 rv = -EINVAL;
416 if (sdp->sd_args.ar_spectator)
417 goto out;
418 if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL) 416 if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
419 goto out; 417 goto out;
420 rv = -EBUSY; 418 rv = -EBUSY;
421 if (test_and_clear_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0) 419 if (test_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0)
422 goto out; 420 goto out;
421 rv = 0;
422 if (sdp->sd_args.ar_spectator && jid > 0)
423 rv = jid = -EINVAL;
423 sdp->sd_lockstruct.ls_jid = jid; 424 sdp->sd_lockstruct.ls_jid = jid;
425 clear_bit(SDF_NOJOURNALID, &sdp->sd_flags);
424 smp_mb__after_clear_bit(); 426 smp_mb__after_clear_bit();
425 wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID); 427 wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID);
426 rv = 0;
427out: 428out:
428 spin_unlock(&sdp->sd_jindex_spin); 429 spin_unlock(&sdp->sd_jindex_spin);
429 return rv ? rv : len; 430 return rv ? rv : len;
@@ -617,7 +618,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
617 add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name); 618 add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name);
618 add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); 619 add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
619 if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags)) 620 if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags))
620 add_uevent_var(env, "JOURNALID=%u", sdp->sd_lockstruct.ls_jid); 621 add_uevent_var(env, "JOURNALID=%d", sdp->sd_lockstruct.ls_jid);
621 if (gfs2_uuid_valid(uuid)) 622 if (gfs2_uuid_valid(uuid))
622 add_uevent_var(env, "UUID=%pUB", uuid); 623 add_uevent_var(env, "UUID=%pUB", uuid);
623 return 0; 624 return 0;