]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
gfs2: Split gfs2_lm_withdraw into two functions
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 23 Jan 2020 17:41:00 +0000 (18:41 +0100)
committerBob Peterson <rpeterso@redhat.com>
Mon, 10 Feb 2020 13:39:44 +0000 (07:39 -0600)
Split gfs2_lm_withdraw into a function that prints an error message and a
function that withdraws the filesystem.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/glops.c
fs/gfs2/log.c
fs/gfs2/sys.c
fs/gfs2/util.c
fs/gfs2/util.h

index 061d22e1ceb6e72018d0dcb54274a9a5886d9d49..58431f67665eaaf093f3b96cfc95fe495bbf01bb 100644 (file)
@@ -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",
               gl->gl_name.ln_type, gl->gl_name.ln_number,
               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);
 }
 
 /**
index 00a2e721a374fb467ccb1d2826cf9a4431599e23..c4c7c013f7a73680942a7a224878aa5aab5e45d1 100644 (file)
@@ -165,7 +165,7 @@ restart:
        spin_unlock(&sdp->sd_ail_lock);
        blk_finish_plug(&plug);
        if (withdraw)
-               gfs2_lm_withdraw(sdp, NULL);
+               gfs2_withdraw(sdp);
        trace_gfs2_ail_flush(sdp, wbc, 0);
 }
 
@@ -239,8 +239,10 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp)
        ret = list_empty(&sdp->sd_ail1_list);
        spin_unlock(&sdp->sd_ail_lock);
 
-       if (withdraw)
-               gfs2_lm_withdraw(sdp, "fatal: I/O error(s)\n");
+       if (withdraw) {
+               gfs2_lm(sdp, "fatal: I/O error(s)\n");
+               gfs2_withdraw(sdp);
+       }
 
        return ret;
 }
@@ -1016,11 +1018,12 @@ int gfs2_logd(void *data)
 
                /* Check for errors writing to the journal */
                if (sdp->sd_log_error) {
-                       gfs2_lm_withdraw(sdp,
-                                        "GFS2: fsid=%s: error %d: "
-                                        "withdrawing the file system to "
-                                        "prevent further damage.\n",
-                                        sdp->sd_fsname, sdp->sd_log_error);
+                       gfs2_lm(sdp,
+                               "GFS2: fsid=%s: error %d: "
+                               "withdrawing the file system to "
+                               "prevent further damage.\n",
+                               sdp->sd_fsname, sdp->sd_log_error);
+                       gfs2_withdraw(sdp);
                }
 
                did_flush = false;
index 8ccb68f4ed1671e878de66af511a1f7e7e2a3930..a2eae5c578d6775e21f526968975d4783a82bcd5 100644 (file)
@@ -136,7 +136,8 @@ static ssize_t withdraw_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
        if (val != 1)
                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;
 }
index ec600b4874981240290b985a4148ce2cabc14659..322012e2064e218cb00adf147f7afae9e8a9aba3 100644 (file)
@@ -33,28 +33,31 @@ void gfs2_assert_i(struct gfs2_sbd *sdp)
        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 va_format vaf;
+       va_list args;
+
+       if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW &&
+           test_bit(SDF_WITHDRAWN, &sdp->sd_flags))
+               return;
+
+       va_start(args, fmt);
+       vaf.fmt = fmt;
+       vaf.va = &args;
+       fs_err(sdp, "%pV", &vaf);
+       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;
-       va_list args;
-       struct va_format vaf;
 
        if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW &&
            test_and_set_bit(SDF_WITHDRAWN, &sdp->sd_flags))
                return 0;
 
-       if (fmt) {
-               va_start(args, fmt);
-
-               vaf.fmt = fmt;
-               vaf.va = &args;
-
-               fs_err(sdp, "%pV", &vaf);
-
-               va_end(args);
-       }
-
        if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW) {
                fs_err(sdp, "about to withdraw this file system\n");
                BUG_ON(sdp->sd_args.ar_debug);
@@ -89,10 +92,12 @@ int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
                           const char *function, char *file, unsigned int line)
 {
        int me;
-       me = gfs2_lm_withdraw(sdp,
-                             "fatal: assertion \"%s\" failed\n"
-                             "   function = %s, file = %s, line = %u\n",
-                             assertion, function, file, line);
+
+       gfs2_lm(sdp,
+               "fatal: assertion \"%s\" failed\n"
+               "   function = %s, file = %s, line = %u\n",
+               assertion, function, file, line);
+       me = gfs2_withdraw(sdp);
        dump_stack();
        return (me) ? -1 : -2;
 }
@@ -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,
                   char *file, unsigned int line)
 {
-       int rv;
-       rv = gfs2_lm_withdraw(sdp,
-                             "fatal: filesystem consistency error - function = %s, file = %s, line = %u\n",
-                             function, file, line);
-       return rv;
+       gfs2_lm(sdp,
+               "fatal: filesystem consistency error - function = %s, file = %s, line = %u\n",
+               function, file, line);
+       return gfs2_withdraw(sdp);
 }
 
 /**
@@ -157,15 +161,15 @@ int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide,
                         const char *function, char *file, unsigned int line)
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
-       int rv;
-       rv = gfs2_lm_withdraw(sdp,
-                             "fatal: filesystem consistency error\n"
-                             "  inode = %llu %llu\n"
-                             "  function = %s, file = %s, line = %u\n",
-                             (unsigned long long)ip->i_no_formal_ino,
-                             (unsigned long long)ip->i_no_addr,
-                             function, file, line);
-       return rv;
+
+       gfs2_lm(sdp,
+               "fatal: filesystem consistency error\n"
+               "  inode = %llu %llu\n"
+               "  function = %s, file = %s, line = %u\n",
+               (unsigned long long)ip->i_no_formal_ino,
+               (unsigned long long)ip->i_no_addr,
+               function, file, line);
+       return gfs2_withdraw(sdp);
 }
 
 /**
@@ -179,17 +183,16 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
 {
        struct gfs2_sbd *sdp = rgd->rd_sbd;
        char fs_id_buf[sizeof(sdp->sd_fsname) + 7];
-       int rv;
 
        sprintf(fs_id_buf, "fsid=%s: ", sdp->sd_fsname);
        gfs2_rgrp_dump(NULL, rgd->rd_gl, fs_id_buf);
-       rv = gfs2_lm_withdraw(sdp,
-                             "fatal: filesystem consistency error\n"
-                             "  RG = %llu\n"
-                             "  function = %s, file = %s, line = %u\n",
-                             (unsigned long long)rgd->rd_addr,
-                             function, file, line);
-       return rv;
+       gfs2_lm(sdp,
+               "fatal: filesystem consistency error\n"
+               "  RG = %llu\n"
+               "  function = %s, file = %s, line = %u\n",
+               (unsigned long long)rgd->rd_addr,
+               function, file, line);
+       return gfs2_withdraw(sdp);
 }
 
 /**
@@ -203,12 +206,14 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
                       unsigned int line)
 {
        int me;
-       me = gfs2_lm_withdraw(sdp,
-                             "fatal: invalid metadata block\n"
-                             "  bh = %llu (%s)\n"
-                             "  function = %s, file = %s, line = %u\n",
-                             (unsigned long long)bh->b_blocknr, type,
-                             function, file, line);
+
+       gfs2_lm(sdp,
+               "fatal: invalid metadata block\n"
+               "  bh = %llu (%s)\n"
+               "  function = %s, file = %s, line = %u\n",
+               (unsigned long long)bh->b_blocknr, type,
+               function, file, line);
+       me = gfs2_withdraw(sdp);
        return (me) ? -1 : -2;
 }
 
@@ -223,12 +228,14 @@ int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
                           char *file, unsigned int line)
 {
        int me;
-       me = gfs2_lm_withdraw(sdp,
-                             "fatal: invalid metadata block\n"
-                             "  bh = %llu (type: exp=%u, found=%u)\n"
-                             "  function = %s, file = %s, line = %u\n",
-                             (unsigned long long)bh->b_blocknr, type, t,
-                             function, file, line);
+
+       gfs2_lm(sdp,
+               "fatal: invalid metadata block\n"
+               "  bh = %llu (type: exp=%u, found=%u)\n"
+               "  function = %s, file = %s, line = %u\n",
+               (unsigned long long)bh->b_blocknr, type, t,
+               function, file, line);
+       me = gfs2_withdraw(sdp);
        return (me) ? -1 : -2;
 }
 
@@ -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,
                    unsigned int line)
 {
-       int rv;
-       rv = gfs2_lm_withdraw(sdp,
-                             "fatal: I/O error\n"
-                             "  function = %s, file = %s, line = %u\n",
-                             function, file, line);
-       return rv;
+       gfs2_lm(sdp,
+               "fatal: I/O error\n"
+               "  function = %s, file = %s, line = %u\n",
+               function, file, line);
+       return gfs2_withdraw(sdp);
 }
 
 /**
@@ -266,6 +272,6 @@ void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
                       (unsigned long long)bh->b_blocknr,
                       function, file, line);
        if (withdraw)
-               gfs2_lm_withdraw(sdp, NULL);
+               gfs2_withdraw(sdp);
 }
 
index f2702bc9837c010de86739163557701f72c4aa4c..fdc218a28609076e0a8ad8091a9ea252bc7b31c7 100644 (file)
@@ -177,6 +177,7 @@ static inline bool gfs2_withdrawn(struct gfs2_sbd *sdp)
 gfs2_tune_get_i(&(sdp)->sd_tune, &(sdp)->sd_tune.field)
 
 __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__ */