Commit 2a2c9824 authored by Steven Whitehouse's avatar Steven Whitehouse

[GFS2] Fix crc32 calculation in recovery.c

Commit "[GFS2] split and annotate gfs2_log_head" resulted in an incorrect
checksum calculation for log headers. This patch corrects the
problem without resorting to copying the whole log header as
the previous code used to.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent 55167622
...@@ -136,6 +136,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, ...@@ -136,6 +136,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
{ {
struct buffer_head *bh; struct buffer_head *bh;
struct gfs2_log_header_host lh; struct gfs2_log_header_host lh;
static const u32 nothing = 0;
u32 hash; u32 hash;
int error; int error;
...@@ -143,11 +144,11 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, ...@@ -143,11 +144,11 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
if (error) if (error)
return error; return error;
memcpy(&lh, bh->b_data, sizeof(struct gfs2_log_header)); /* XXX */ hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) -
lh.lh_hash = 0; sizeof(u32));
hash = gfs2_disk_hash((char *)&lh, sizeof(struct gfs2_log_header)); hash = crc32_le(hash, (unsigned char const *)&nothing, sizeof(nothing));
hash ^= (u32)~0;
gfs2_log_header_in(&lh, bh->b_data); gfs2_log_header_in(&lh, bh->b_data);
brelse(bh); brelse(bh);
if (lh.lh_header.mh_magic != GFS2_MAGIC || if (lh.lh_header.mh_magic != GFS2_MAGIC ||
......
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