Skip to content

Commit

Permalink
gfs2: improve debug information when lvb mismatches are found
Browse files Browse the repository at this point in the history
Before this patch, gfs2_rgrp_bh_get would check for lvb mismatches,
but it wouldn't tell you what was actually wrong. This patch adds
more information to help us debug it. It also makes rgrp consistency
checks dump any bad rgrps, and the rgrp dump code dump any lvbs
as well as the rgrp itself.

Signed-off-by: Bob Peterson <[email protected]>
Acked-by: Steven Whitehouse <[email protected]>
  • Loading branch information
AstralBob committed Aug 28, 2018
1 parent 050cdc6 commit 72244b6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
41 changes: 36 additions & 5 deletions fs/gfs2/rgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1103,12 +1103,35 @@ static int gfs2_rgrp_lvb_valid(struct gfs2_rgrpd *rgd)
{
struct gfs2_rgrp_lvb *rgl = rgd->rd_rgl;
struct gfs2_rgrp *str = (struct gfs2_rgrp *)rgd->rd_bits[0].bi_bh->b_data;
int valid = 1;

if (rgl->rl_flags != str->rg_flags || rgl->rl_free != str->rg_free ||
rgl->rl_dinodes != str->rg_dinodes ||
rgl->rl_igeneration != str->rg_igeneration)
return 0;
return 1;
if (rgl->rl_flags != str->rg_flags) {
printk(KERN_WARNING "GFS2: rgd: %llu lvb flag mismatch %u/%u",
(unsigned long long)rgd->rd_addr,
be32_to_cpu(rgl->rl_flags), be32_to_cpu(str->rg_flags));
valid = 0;
}
if (rgl->rl_free != str->rg_free) {
printk(KERN_WARNING "GFS2: rgd: %llu lvb free mismatch %u/%u",
(unsigned long long)rgd->rd_addr,
be32_to_cpu(rgl->rl_free), be32_to_cpu(str->rg_free));
valid = 0;
}
if (rgl->rl_dinodes != str->rg_dinodes) {
printk(KERN_WARNING "GFS2: rgd: %llu lvb dinode mismatch %u/%u",
(unsigned long long)rgd->rd_addr,
be32_to_cpu(rgl->rl_dinodes),
be32_to_cpu(str->rg_dinodes));
valid = 0;
}
if (rgl->rl_igeneration != str->rg_igeneration) {
printk(KERN_WARNING "GFS2: rgd: %llu lvb igen mismatch "
"%llu/%llu", (unsigned long long)rgd->rd_addr,
(unsigned long long)be64_to_cpu(rgl->rl_igeneration),
(unsigned long long)be64_to_cpu(str->rg_igeneration));
valid = 0;
}
return valid;
}

static u32 count_unlinked(struct gfs2_rgrpd *rgd)
Expand Down Expand Up @@ -2244,6 +2267,14 @@ void gfs2_rgrp_dump(struct seq_file *seq, const struct gfs2_glock *gl)
(unsigned long long)rgd->rd_addr, rgd->rd_flags,
rgd->rd_free, rgd->rd_free_clone, rgd->rd_dinodes,
rgd->rd_reserved, rgd->rd_extfail_pt);
if (rgd->rd_sbd->sd_args.ar_rgrplvb) {
struct gfs2_rgrp_lvb *rgl = rgd->rd_rgl;

gfs2_print_dbg(seq, " L: f:%02x b:%u i:%u\n",
be32_to_cpu(rgl->rl_flags),
be32_to_cpu(rgl->rl_free),
be32_to_cpu(rgl->rl_dinodes));
}
spin_lock(&rgd->rd_rsspin);
for (n = rb_first(&rgd->rd_rstree); n; n = rb_next(&trs->rs_node)) {
trs = rb_entry(n, struct gfs2_blkreserv, rs_node);
Expand Down
3 changes: 3 additions & 0 deletions fs/gfs2/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "gfs2.h"
#include "incore.h"
#include "glock.h"
#include "rgrp.h"
#include "util.h"

struct kmem_cache *gfs2_glock_cachep __read_mostly;
Expand Down Expand Up @@ -181,6 +182,8 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
{
struct gfs2_sbd *sdp = rgd->rd_sbd;
int rv;

gfs2_rgrp_dump(NULL, rgd->rd_gl);
rv = gfs2_lm_withdraw(sdp,
"fatal: filesystem consistency error\n"
" RG = %llu\n"
Expand Down

0 comments on commit 72244b6

Please sign in to comment.