diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2010-09-29 10:04:18 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2010-09-29 10:04:18 -0400 |
commit | feb47ca9314666d920855b8a235032dea2b2caa4 (patch) | |
tree | 163a391bda495826747eb249cf74b42ad35bd5ec /fs/gfs2/sys.c | |
parent | 43f74c199563a4273e528e2166d0650625a1e05f (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/sys.c')
-rw-r--r-- | fs/gfs2/sys.c | 17 |
1 files changed, 9 insertions, 8 deletions
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 | ||
400 | static ssize_t jid_show(struct gfs2_sbd *sdp, char *buf) | 400 | static 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 | ||
405 | static ssize_t jid_store(struct gfs2_sbd *sdp, const char *buf, size_t len) | 405 | static 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; | ||
427 | out: | 428 | out: |
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; |