aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/recovery.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-10-31 14:44:50 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-11-30 10:33:17 -0500
commit2a2c98247b822db8df037a56c27201f9d716ac66 (patch)
treecadb8e1f27da7f931a6fec84abd4200719331692 /fs/gfs2/recovery.c
parent551676226163379c217e8ec54bd287eab9b8521e (diff)
[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: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/recovery.c')
-rw-r--r--fs/gfs2/recovery.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 447816241626..4acf238e1db6 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -136,6 +136,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
136{ 136{
137 struct buffer_head *bh; 137 struct buffer_head *bh;
138 struct gfs2_log_header_host lh; 138 struct gfs2_log_header_host lh;
139static const u32 nothing = 0;
139 u32 hash; 140 u32 hash;
140 int error; 141 int error;
141 142
@@ -143,11 +144,11 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
143 if (error) 144 if (error)
144 return error; 145 return error;
145 146
146 memcpy(&lh, bh->b_data, sizeof(struct gfs2_log_header)); /* XXX */ 147 hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) -
147 lh.lh_hash = 0; 148 sizeof(u32));
148 hash = gfs2_disk_hash((char *)&lh, sizeof(struct gfs2_log_header)); 149 hash = crc32_le(hash, (unsigned char const *)&nothing, sizeof(nothing));
150 hash ^= (u32)~0;
149 gfs2_log_header_in(&lh, bh->b_data); 151 gfs2_log_header_in(&lh, bh->b_data);
150
151 brelse(bh); 152 brelse(bh);
152 153
153 if (lh.lh_header.mh_magic != GFS2_MAGIC || 154 if (lh.lh_header.mh_magic != GFS2_MAGIC ||