Skip to content

Commit 1b8ba31

Browse files
StevenWhitehouseswhiteho
authored andcommitted
GFS2: Fix error handling when reading an invalid block from the journal
When we read an invalid block from the journal, we should not call withdraw, but simply print a message and return an error. It is up to the caller to then handle that error. In the case of mount that means a failed mount, rather than a withdraw (requiring a reboot). In the case of recovering another nodes journal then we return an error via the uevent. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 23d0bb8 commit 1b8ba31

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

‎fs/gfs2/lops.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,14 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
401401
goto out;
402402
set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
403403
set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
404-
gfs2_meta_check(sdp, bd->bd_bh);
405-
gfs2_pin(sdp, bd->bd_bh);
406404
mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
405+
if (unlikely(mh->mh_magic != cpu_to_be32(GFS2_MAGIC))) {
406+
printk(KERN_ERR
407+
"Attempting to add uninitialised block to journal (inplace block=%lld)\n",
408+
(unsigned long long)bd->bd_bh->b_blocknr);
409+
BUG();
410+
}
411+
gfs2_pin(sdp, bd->bd_bh);
407412
mh->__pad0 = cpu_to_be64(0);
408413
mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
409414
sdp->sd_log_num_buf++;

‎fs/gfs2/util.h‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,19 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
7979
const char *type, const char *function,
8080
char *file, unsigned int line);
8181

82-
static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp,
83-
struct buffer_head *bh,
84-
const char *function,
85-
char *file, unsigned int line)
82+
static inline int gfs2_meta_check(struct gfs2_sbd *sdp,
83+
struct buffer_head *bh)
8684
{
8785
struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
8886
u32 magic = be32_to_cpu(mh->mh_magic);
89-
if (unlikely(magic != GFS2_MAGIC))
90-
return gfs2_meta_check_ii(sdp, bh, "magic number", function,
91-
file, line);
87+
if (unlikely(magic != GFS2_MAGIC)) {
88+
printk(KERN_ERR "GFS2: Magic number missing at %llu\n",
89+
(unsigned long long)bh->b_blocknr);
90+
return -EIO;
91+
}
9292
return 0;
9393
}
9494

95-
#define gfs2_meta_check(sdp, bh) \
96-
gfs2_meta_check_i((sdp), (bh), __func__, __FILE__, __LINE__)
97-
98-
9995
int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
10096
u16 type, u16 t,
10197
const char *function,

0 commit comments

Comments
 (0)