Commit badb55ec authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Bob Peterson

gfs2: Split gfs2_lm_withdraw into two functions

Split gfs2_lm_withdraw into a function that prints an error message and a
function that withdraws the filesystem.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
parent 6e5e41e2
...@@ -39,7 +39,8 @@ static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh) ...@@ -39,7 +39,8 @@ static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh)
fs_err(gl->gl_name.ln_sbd, "AIL glock %u:%llu mapping %p\n", fs_err(gl->gl_name.ln_sbd, "AIL glock %u:%llu mapping %p\n",
gl->gl_name.ln_type, gl->gl_name.ln_number, gl->gl_name.ln_type, gl->gl_name.ln_number,
gfs2_glock2aspace(gl)); gfs2_glock2aspace(gl));
gfs2_lm_withdraw(gl->gl_name.ln_sbd, "AIL error\n"); gfs2_lm(gl->gl_name.ln_sbd, "AIL error\n");
gfs2_withdraw(gl->gl_name.ln_sbd);
} }
/** /**
......
...@@ -165,7 +165,7 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc) ...@@ -165,7 +165,7 @@ void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)
spin_unlock(&sdp->sd_ail_lock); spin_unlock(&sdp->sd_ail_lock);
blk_finish_plug(&plug); blk_finish_plug(&plug);
if (withdraw) if (withdraw)
gfs2_lm_withdraw(sdp, NULL); gfs2_withdraw(sdp);
trace_gfs2_ail_flush(sdp, wbc, 0); trace_gfs2_ail_flush(sdp, wbc, 0);
} }
...@@ -239,8 +239,10 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp) ...@@ -239,8 +239,10 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp)
ret = list_empty(&sdp->sd_ail1_list); ret = list_empty(&sdp->sd_ail1_list);
spin_unlock(&sdp->sd_ail_lock); spin_unlock(&sdp->sd_ail_lock);
if (withdraw) if (withdraw) {
gfs2_lm_withdraw(sdp, "fatal: I/O error(s)\n"); gfs2_lm(sdp, "fatal: I/O error(s)\n");
gfs2_withdraw(sdp);
}
return ret; return ret;
} }
...@@ -1016,11 +1018,12 @@ int gfs2_logd(void *data) ...@@ -1016,11 +1018,12 @@ int gfs2_logd(void *data)
/* Check for errors writing to the journal */ /* Check for errors writing to the journal */
if (sdp->sd_log_error) { if (sdp->sd_log_error) {
gfs2_lm_withdraw(sdp, gfs2_lm(sdp,
"GFS2: fsid=%s: error %d: " "GFS2: fsid=%s: error %d: "
"withdrawing the file system to " "withdrawing the file system to "
"prevent further damage.\n", "prevent further damage.\n",
sdp->sd_fsname, sdp->sd_log_error); sdp->sd_fsname, sdp->sd_log_error);
gfs2_withdraw(sdp);
} }
did_flush = false; did_flush = false;
......
...@@ -136,7 +136,8 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len) ...@@ -136,7 +136,8 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
if (val != 1) if (val != 1)
return -EINVAL; return -EINVAL;
gfs2_lm_withdraw(sdp, "withdrawing from cluster at user's request\n"); gfs2_lm(sdp, "withdrawing from cluster at user's request\n");
gfs2_withdraw(sdp);
return len; return len;
} }
......
...@@ -33,27 +33,30 @@ void gfs2_assert_i(struct gfs2_sbd *sdp) ...@@ -33,27 +33,30 @@ void gfs2_assert_i(struct gfs2_sbd *sdp)
fs_emerg(sdp, "fatal assertion failed\n"); fs_emerg(sdp, "fatal assertion failed\n");
} }
int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...) void gfs2_lm(struct gfs2_sbd *sdp, const char *fmt, ...)
{ {
struct lm_lockstruct *ls = &sdp->sd_lockstruct;
const struct lm_lockops *lm = ls->ls_ops;
va_list args;
struct va_format vaf; struct va_format vaf;
va_list args;
if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW && if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW &&
test_and_set_bit(SDF_WITHDRAWN, &sdp->sd_flags)) test_bit(SDF_WITHDRAWN, &sdp->sd_flags))
return 0; return;
if (fmt) {
va_start(args, fmt); va_start(args, fmt);
vaf.fmt = fmt; vaf.fmt = fmt;
vaf.va = &args; vaf.va = &args;
fs_err(sdp, "%pV", &vaf); fs_err(sdp, "%pV", &vaf);
va_end(args); va_end(args);
} }
int gfs2_withdraw(struct gfs2_sbd *sdp)
{
struct lm_lockstruct *ls = &sdp->sd_lockstruct;
const struct lm_lockops *lm = ls->ls_ops;
if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW &&
test_and_set_bit(SDF_WITHDRAWN, &sdp->sd_flags))
return 0;
if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW) { if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW) {
fs_err(sdp, "about to withdraw this file system\n"); fs_err(sdp, "about to withdraw this file system\n");
...@@ -89,10 +92,12 @@ int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion, ...@@ -89,10 +92,12 @@ int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
const char *function, char *file, unsigned int line) const char *function, char *file, unsigned int line)
{ {
int me; int me;
me = gfs2_lm_withdraw(sdp,
gfs2_lm(sdp,
"fatal: assertion \"%s\" failed\n" "fatal: assertion \"%s\" failed\n"
" function = %s, file = %s, line = %u\n", " function = %s, file = %s, line = %u\n",
assertion, function, file, line); assertion, function, file, line);
me = gfs2_withdraw(sdp);
dump_stack(); dump_stack();
return (me) ? -1 : -2; return (me) ? -1 : -2;
} }
...@@ -140,11 +145,10 @@ int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion, ...@@ -140,11 +145,10 @@ int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide, const char *function, int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide, const char *function,
char *file, unsigned int line) char *file, unsigned int line)
{ {
int rv; gfs2_lm(sdp,
rv = gfs2_lm_withdraw(sdp,
"fatal: filesystem consistency error - function = %s, file = %s, line = %u\n", "fatal: filesystem consistency error - function = %s, file = %s, line = %u\n",
function, file, line); function, file, line);
return rv; return gfs2_withdraw(sdp);
} }
/** /**
...@@ -157,15 +161,15 @@ int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide, ...@@ -157,15 +161,15 @@ int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide,
const char *function, char *file, unsigned int line) const char *function, char *file, unsigned int line)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
int rv;
rv = gfs2_lm_withdraw(sdp, gfs2_lm(sdp,
"fatal: filesystem consistency error\n" "fatal: filesystem consistency error\n"
" inode = %llu %llu\n" " inode = %llu %llu\n"
" function = %s, file = %s, line = %u\n", " function = %s, file = %s, line = %u\n",
(unsigned long long)ip->i_no_formal_ino, (unsigned long long)ip->i_no_formal_ino,
(unsigned long long)ip->i_no_addr, (unsigned long long)ip->i_no_addr,
function, file, line); function, file, line);
return rv; return gfs2_withdraw(sdp);
} }
/** /**
...@@ -179,17 +183,16 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide, ...@@ -179,17 +183,16 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
{ {
struct gfs2_sbd *sdp = rgd->rd_sbd; struct gfs2_sbd *sdp = rgd->rd_sbd;
char fs_id_buf[sizeof(sdp->sd_fsname) + 7]; char fs_id_buf[sizeof(sdp->sd_fsname) + 7];
int rv;
sprintf(fs_id_buf, "fsid=%s: ", sdp->sd_fsname); sprintf(fs_id_buf, "fsid=%s: ", sdp->sd_fsname);
gfs2_rgrp_dump(NULL, rgd->rd_gl, fs_id_buf); gfs2_rgrp_dump(NULL, rgd->rd_gl, fs_id_buf);
rv = gfs2_lm_withdraw(sdp, gfs2_lm(sdp,
"fatal: filesystem consistency error\n" "fatal: filesystem consistency error\n"
" RG = %llu\n" " RG = %llu\n"
" function = %s, file = %s, line = %u\n", " function = %s, file = %s, line = %u\n",
(unsigned long long)rgd->rd_addr, (unsigned long long)rgd->rd_addr,
function, file, line); function, file, line);
return rv; return gfs2_withdraw(sdp);
} }
/** /**
...@@ -203,12 +206,14 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, ...@@ -203,12 +206,14 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
unsigned int line) unsigned int line)
{ {
int me; int me;
me = gfs2_lm_withdraw(sdp,
gfs2_lm(sdp,
"fatal: invalid metadata block\n" "fatal: invalid metadata block\n"
" bh = %llu (%s)\n" " bh = %llu (%s)\n"
" function = %s, file = %s, line = %u\n", " function = %s, file = %s, line = %u\n",
(unsigned long long)bh->b_blocknr, type, (unsigned long long)bh->b_blocknr, type,
function, file, line); function, file, line);
me = gfs2_withdraw(sdp);
return (me) ? -1 : -2; return (me) ? -1 : -2;
} }
...@@ -223,12 +228,14 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, ...@@ -223,12 +228,14 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
char *file, unsigned int line) char *file, unsigned int line)
{ {
int me; int me;
me = gfs2_lm_withdraw(sdp,
gfs2_lm(sdp,
"fatal: invalid metadata block\n" "fatal: invalid metadata block\n"
" bh = %llu (type: exp=%u, found=%u)\n" " bh = %llu (type: exp=%u, found=%u)\n"
" function = %s, file = %s, line = %u\n", " function = %s, file = %s, line = %u\n",
(unsigned long long)bh->b_blocknr, type, t, (unsigned long long)bh->b_blocknr, type, t,
function, file, line); function, file, line);
me = gfs2_withdraw(sdp);
return (me) ? -1 : -2; return (me) ? -1 : -2;
} }
...@@ -241,12 +248,11 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, ...@@ -241,12 +248,11 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file, int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function, char *file,
unsigned int line) unsigned int line)
{ {
int rv; gfs2_lm(sdp,
rv = gfs2_lm_withdraw(sdp,
"fatal: I/O error\n" "fatal: I/O error\n"
" function = %s, file = %s, line = %u\n", " function = %s, file = %s, line = %u\n",
function, file, line); function, file, line);
return rv; return gfs2_withdraw(sdp);
} }
/** /**
...@@ -266,6 +272,6 @@ void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh, ...@@ -266,6 +272,6 @@ void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
(unsigned long long)bh->b_blocknr, (unsigned long long)bh->b_blocknr,
function, file, line); function, file, line);
if (withdraw) if (withdraw)
gfs2_lm_withdraw(sdp, NULL); gfs2_withdraw(sdp);
} }
...@@ -177,6 +177,7 @@ static inline bool gfs2_withdrawn(struct gfs2_sbd *sdp) ...@@ -177,6 +177,7 @@ static inline bool gfs2_withdrawn(struct gfs2_sbd *sdp)
gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field) gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
__printf(2, 3) __printf(2, 3)
int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...); void gfs2_lm(struct gfs2_sbd *sdp, const char *fmt, ...);
int gfs2_withdraw(struct gfs2_sbd *sdp);
#endif /* __UTIL_DOT_H__ */ #endif /* __UTIL_DOT_H__ */
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