Commit feb47ca9 authored by Steven Whitehouse's avatar Steven Whitehouse

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: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent 43f74c19
...@@ -494,7 +494,7 @@ struct gfs2_sb_host { ...@@ -494,7 +494,7 @@ struct gfs2_sb_host {
*/ */
struct lm_lockstruct { struct lm_lockstruct {
unsigned int ls_jid; int ls_jid;
unsigned int ls_first; unsigned int ls_first;
unsigned int ls_first_done; unsigned int ls_first_done;
unsigned int ls_nodir; unsigned int ls_nodir;
......
...@@ -1056,8 +1056,6 @@ static int gfs2_journalid_wait(void *word) ...@@ -1056,8 +1056,6 @@ static int gfs2_journalid_wait(void *word)
static int wait_on_journal(struct gfs2_sbd *sdp) 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) if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
return 0; return 0;
...@@ -1160,6 +1158,20 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent ...@@ -1160,6 +1158,20 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
if (error) if (error)
goto fail_sb; 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); error = init_inodes(sdp, DO);
if (error) if (error)
goto fail_sb; goto fail_sb;
......
...@@ -399,31 +399,32 @@ static ssize_t recover_status_show(struct gfs2_sbd *sdp, char *buf) ...@@ -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) 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) static ssize_t jid_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
{ {
unsigned jid; int jid;
int rv; int rv;
rv = sscanf(buf, "%u", &jid); rv = sscanf(buf, "%d", &jid);
if (rv != 1) if (rv != 1)
return -EINVAL; return -EINVAL;
spin_lock(&sdp->sd_jindex_spin); spin_lock(&sdp->sd_jindex_spin);
rv = -EINVAL; rv = -EINVAL;
if (sdp->sd_args.ar_spectator)
goto out;
if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL) if (sdp->sd_lockstruct.ls_ops->lm_mount == NULL)
goto out; goto out;
rv = -EBUSY; rv = -EBUSY;
if (test_and_clear_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0) if (test_bit(SDF_NOJOURNALID, &sdp->sd_flags) == 0)
goto out; goto out;
rv = 0;
if (sdp->sd_args.ar_spectator && jid > 0)
rv = jid = -EINVAL;
sdp->sd_lockstruct.ls_jid = jid; sdp->sd_lockstruct.ls_jid = jid;
clear_bit(SDF_NOJOURNALID, &sdp->sd_flags);
smp_mb__after_clear_bit(); smp_mb__after_clear_bit();
wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID); wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID);
rv = 0;
out: out:
spin_unlock(&sdp->sd_jindex_spin); spin_unlock(&sdp->sd_jindex_spin);
return rv ? rv : len; return rv ? rv : len;
...@@ -617,7 +618,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj, ...@@ -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, "LOCKTABLE=%s", sdp->sd_table_name);
add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags)) 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)) if (gfs2_uuid_valid(uuid))
add_uevent_var(env, "UUID=%pUB", uuid); add_uevent_var(env, "UUID=%pUB", uuid);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment