public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 1/2] xfs: add CRC infrastructure
Date: Thu, 8 Nov 2012 07:31:05 +1100	[thread overview]
Message-ID: <20121107203105.GE6434@dastard> (raw)
In-Reply-To: <m2ehk5qt88.fsf@firstfloor.org>

On Wed, Nov 07, 2012 at 08:21:27AM -0800, Andi Kleen wrote:
> Dave Chinner <david@fromorbit.com> writes:
> > + */
> > +static inline __uint32_t
> > +xfs_start_cksum(char *buffer, size_t length, unsigned long cksum_offset)
> > +{
> > +	__uint32_t zero = 0;
> > +	__uint32_t crc;
> > +
> > +	/* Calculate CRC up to the checksum. */
> > +	crc = crc32c(XFS_CRC_SEED, buffer, cksum_offset);
> > +
> > +	/* Skip checksum field */
> > +	crc = crc32c(crc, &zero, sizeof(__u32));
> > +
> > +	/* Calculate the rest of the CRC. */
> > +	return crc32c(crc, &buffer[cksum_offset + sizeof(__be32)],
> > +		      length - (cksum_offset + sizeof(__be32)));
> 
> Don't you need to remap a zero result to some other value, otherwise a
> real zero checksum will never be checked?

Why would that be necessary? We never include the checksum field in
the calculation when setting it or verifiying it, and the
verification uses exactly the same method as the original
calculation to check the CRC, so it doesn't matter if the CRC value
is zero or not - if it matches (zero or otherwise), the validation
passes....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2012-11-07 20:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07 13:37 [PATCH 0/2] xfs: CRCs for log buffers Dave Chinner
2012-11-07 13:37 ` [PATCH 1/2] xfs: add CRC infrastructure Dave Chinner
2012-11-07 16:21   ` Andi Kleen
2012-11-07 20:31     ` Dave Chinner [this message]
2012-11-07 21:39       ` Andi Kleen
2012-11-07 22:28         ` Dave Chinner
2012-11-08 14:42   ` Mark Tinguely
2012-11-08 21:22     ` Dave Chinner
2012-11-09 22:09   ` Mark Tinguely
2012-11-11  1:26     ` Dave Chinner
2012-11-11 19:54       ` Mark Tinguely
2012-11-11 22:51         ` Dave Chinner
2012-11-07 13:37 ` [PATCH 2/2] xfs: add CRC checks to the log Dave Chinner
2012-11-11 19:57   ` Mark Tinguely
2012-11-08  0:21 ` [PATCH 0/2] xfs: CRCs for log buffers Dave Chinner
2012-11-09  0:05 ` Ben Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121107203105.GE6434@dastard \
    --to=david@fromorbit.com \
    --cc=andi@firstfloor.org \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox