* [GFS2] Fix crc32 calculation in recovery.c [8/70]
@ 2006-11-30 12:13 Steven Whitehouse
2006-12-02 8:40 ` Jan Engelhardt
0 siblings, 1 reply; 4+ messages in thread
From: Steven Whitehouse @ 2006-11-30 12:13 UTC (permalink / raw)
To: cluster-devel, linux-kernel
>From 2a2c98247b822db8df037a56c27201f9d716ac66 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho@redhat.com>
Date: Tue, 31 Oct 2006 14:44:50 -0500
Subject: [PATCH] [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>
---
fs/gfs2/recovery.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 4478162..4acf238 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -136,6 +136,7 @@ static int get_log_header(struct gfs2_jd
{
struct buffer_head *bh;
struct gfs2_log_header_host lh;
+static const u32 nothing = 0;
u32 hash;
int error;
@@ -143,11 +144,11 @@ static int get_log_header(struct gfs2_jd
if (error)
return error;
- memcpy(&lh, bh->b_data, sizeof(struct gfs2_log_header)); /* XXX */
- lh.lh_hash = 0;
- hash = gfs2_disk_hash((char *)&lh, sizeof(struct gfs2_log_header));
+ hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) -
+ sizeof(u32));
+ hash = crc32_le(hash, (unsigned char const *)¬hing, sizeof(nothing));
+ hash ^= (u32)~0;
gfs2_log_header_in(&lh, bh->b_data);
-
brelse(bh);
if (lh.lh_header.mh_magic != GFS2_MAGIC ||
--
1.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [GFS2] Fix crc32 calculation in recovery.c [8/70]
2006-11-30 12:13 [GFS2] Fix crc32 calculation in recovery.c [8/70] Steven Whitehouse
@ 2006-12-02 8:40 ` Jan Engelhardt
2006-12-04 10:13 ` Steven Whitehouse
2006-12-07 9:14 ` Steven Whitehouse
0 siblings, 2 replies; 4+ messages in thread
From: Jan Engelhardt @ 2006-12-02 8:40 UTC (permalink / raw)
To: Steven Whitehouse; +Cc: cluster-devel, linux-kernel
>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>
>---
> fs/gfs2/recovery.c | 9 +++++----
> 1 files changed, 5 insertions(+), 4 deletions(-)
>
>diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
>index 4478162..4acf238 100644
>--- a/fs/gfs2/recovery.c
>+++ b/fs/gfs2/recovery.c
>@@ -136,6 +136,7 @@ static int get_log_header(struct gfs2_jd
> {
> struct buffer_head *bh;
> struct gfs2_log_header_host lh;
>+static const u32 nothing = 0;
> u32 hash;
> int error;
>
At least indent it.
>@@ -143,11 +144,11 @@ static int get_log_header(struct gfs2_jd
> if (error)
> return error;
>
>- memcpy(&lh, bh->b_data, sizeof(struct gfs2_log_header)); /* XXX */
>- lh.lh_hash = 0;
>- hash = gfs2_disk_hash((char *)&lh, sizeof(struct gfs2_log_header));
>+ hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) -
>+ sizeof(u32));
>+ hash = crc32_le(hash, (unsigned char const *)¬hing, sizeof(nothing));
>+ hash ^= (u32)~0;
> gfs2_log_header_in(&lh, bh->b_data);
>-
> brelse(bh);
>
> if (lh.lh_header.mh_magic != GFS2_MAGIC ||
>--
>1.4.1
-`J'
--
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [GFS2] Fix crc32 calculation in recovery.c [8/70]
2006-12-02 8:40 ` Jan Engelhardt
@ 2006-12-04 10:13 ` Steven Whitehouse
2006-12-07 9:14 ` Steven Whitehouse
1 sibling, 0 replies; 4+ messages in thread
From: Steven Whitehouse @ 2006-12-04 10:13 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: cluster-devel, linux-kernel
Hi,
On Sat, 2006-12-02 at 09:40 +0100, Jan Engelhardt wrote:
> >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>
> >---
> > fs/gfs2/recovery.c | 9 +++++----
> > 1 files changed, 5 insertions(+), 4 deletions(-)
> >
> >diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
> >index 4478162..4acf238 100644
> >--- a/fs/gfs2/recovery.c
> >+++ b/fs/gfs2/recovery.c
> >@@ -136,6 +136,7 @@ static int get_log_header(struct gfs2_jd
> > {
> > struct buffer_head *bh;
> > struct gfs2_log_header_host lh;
> >+static const u32 nothing = 0;
> > u32 hash;
> > int error;
> >
>
> At least indent it.
>
I've had a private email from someone pointing out the same thing. It
was not intended to emphasise the fact that it is static, I'm not sure
if thats the "right thing" or not, but either way, it doesn't actually
need to be static, so that I've agreed that I'll remove the static and
just leave it as const and fix the indenting at the same time,
Steve.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [GFS2] Fix crc32 calculation in recovery.c [8/70]
2006-12-02 8:40 ` Jan Engelhardt
2006-12-04 10:13 ` Steven Whitehouse
@ 2006-12-07 9:14 ` Steven Whitehouse
1 sibling, 0 replies; 4+ messages in thread
From: Steven Whitehouse @ 2006-12-07 9:14 UTC (permalink / raw)
To: Andrew Morton, Jan Engelhardt; +Cc: cluster-devel, linux-kernel
Hi,
On Sat, 2006-12-02 at 09:40 +0100, Jan Engelhardt wrote:
> >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>
> >---
> > fs/gfs2/recovery.c | 9 +++++----
> > 1 files changed, 5 insertions(+), 4 deletions(-)
> >
> >diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
> >index 4478162..4acf238 100644
> >--- a/fs/gfs2/recovery.c
> >+++ b/fs/gfs2/recovery.c
> >@@ -136,6 +136,7 @@ static int get_log_header(struct gfs2_jd
> > {
> > struct buffer_head *bh;
> > struct gfs2_log_header_host lh;
> >+static const u32 nothing = 0;
> > u32 hash;
> > int error;
> >
>
> At least indent it.
>
As per your comment and also Andrew Morton's similar remark, here is the
patch I'm just about to add to the tree,
Steve.
---------------------------------------------------------------------------------------
>From 887bc5d00c02b32763845247024e8db5243ef857 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho@redhat.com>
Date: Tue, 5 Dec 2006 13:34:17 -0500
Subject: [PATCH] [GFS2] Fix indent in recovery.c
As per comments from Andrew Morton and Jan Engelhardt, this fixes the
indent and removes the "static" from a variable declaration since its
not needed in this case (now allocated on the stack of the function
in question).
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: Andrew Morton <akpm@osdl.org>
---
fs/gfs2/recovery.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 4acf238..d0c806b 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -136,7 +136,7 @@ static int get_log_header(struct gfs2_jd
{
struct buffer_head *bh;
struct gfs2_log_header_host lh;
-static const u32 nothing = 0;
+ const u32 nothing = 0;
u32 hash;
int error;
--
1.4.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-12-07 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-30 12:13 [GFS2] Fix crc32 calculation in recovery.c [8/70] Steven Whitehouse
2006-12-02 8:40 ` Jan Engelhardt
2006-12-04 10:13 ` Steven Whitehouse
2006-12-07 9:14 ` Steven Whitehouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox