From: Mark Tinguely <tinguely@sgi.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 1/2] xfs: add CRC infrastructure
Date: Fri, 09 Nov 2012 16:09:30 -0600 [thread overview]
Message-ID: <509D7F1A.3090201@sgi.com> (raw)
In-Reply-To: <1352295452-4726-2-git-send-email-david@fromorbit.com>
On 11/07/12 07:37, Dave Chinner wrote:
> From: Christoph Hellwig<hch@lst.de>
>
> - add a mount feature bit for CRC enabled filesystems
> - add some helpers for generating and verifying the CRCs
> - add a copy_uuid helper
>
> The checksumming helpers are losely based on similar ones in sctp,
> all other bits come from Dave Chinner.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
> Signed-off-by: Dave Chinner<dchinner@redhat.com>
> ---
> +/*
> + * Calculate the intermediate checksum for a buffer that has the CRC field
> + * inside it. The offset of the 32bit crc fields is passed as the
> + * cksum_offset parameter.
> + */
> +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));
I know this came from sctp and I know I can't convince you to copy/null
the *cksum_offset to make one block for those with hardware crc32c devices.
Since the *cksum_offset value is never used in creating and verifying
the checksum, the 4 bytes of zeros does not add any new information,
why not just drop it from the cksum calculation?
> +
> + /* Calculate the rest of the CRC. */
> + return crc32c(crc,&buffer[cksum_offset + sizeof(__be32)],
> + length - (cksum_offset + sizeof(__be32)));
> +}
> +
> +/*
> + * Convert the intermediate checksum to the final ondisk format.
> + *
> + * Note that crc32c is already endianess agnostic, so no additional
> + * byte swap is needed.
> + */
> +static inline __be32
> +xfs_end_cksum(__uint32_t crc)
> +{
> + return (__force __be32)~crc;
> +}
> +
Wouldn't you have to cpu_to_le32() for big endian machines?
commit 9c5ff5f75d0d0a1c7928ecfae3f38418b51a88e3
Author: Vlad Yasevich <vladislav.yasevich@hp.com>
Date: Thu Jan 22 14:52:23 2009 -0800
sctp: Fix crc32c calculations on big-endian arhes.
crc32c algorithm provides a byteswaped result. On little-endian
arches, the result ends up in big-endian/network byte order.
On big-endinan arches, the result ends up in little-endian
order and needs to be byte swapped again. Thus calling cpu_to_le32
gives the right output.
Tested-by: Jukka Taimisto <jukka.taimisto@mail.suomi.net>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
index b799fb2..2fec3c3 100644
--- a/include/net/sctp/checksum.h
+++ b/include/net/sctp/checksum.h
@@ -79,5 +79,5 @@ static inline __be32 sctp_update_cksum(__u8 *buffer,
__u16 length, __be32 crc32)
static inline __be32 sctp_end_cksum(__be32 crc32)
{
- return ~crc32;
+ return (__force __be32)~cpu_to_le32((__force u32)crc32);
}
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-11-09 22:07 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
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 [this message]
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=509D7F1A.3090201@sgi.com \
--to=tinguely@sgi.com \
--cc=david@fromorbit.com \
--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