xfs: fix sparse reported log CRC endian issue
authorDave Chinner <dchinner@redhat.com>
Wed, 28 Nov 2012 02:01:03 +0000 (13:01 +1100)
committerBen Myers <bpm@sgi.com>
Mon, 3 Dec 2012 18:10:59 +0000 (12:10 -0600)
Not a bug as such, just warning noise from the xlog_cksum()
returning a __be32 type when it should be returning a __le32 type.

On Wed, Nov 28, 2012 at 08:30:59AM -0500, Christoph Hellwig wrote:
> But why are we storing the crc field little endian while all other on
> disk formats are big endian? (And yes I realize it might as well have
> been me who did that back in the idea, but I still have no idea why)

Because the CRC always returns the calcuation LE format, even on BE
systems. So rather than always having to byte swap it everywhere and
have all the force casts and anootations for sparse, it seems simpler to
just make it a __le32 everywhere....

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_log.c
fs/xfs/xfs_log_priv.h
fs/xfs/xfs_log_recover.c

index c49e2c12dba4ec55600cc2f36a175526ae3aa503..46bd9d52ab518a57f4ef697d45b310060f0f6d10 100644 (file)
@@ -1538,7 +1538,7 @@ xlog_pack_data(
  * This is a little more complicated than it should be because the various
  * headers and the actual data are non-contiguous.
  */
  * This is a little more complicated than it should be because the various
  * headers and the actual data are non-contiguous.
  */
-__be32
+__le32
 xlog_cksum(
        struct xlog             *log,
        struct xlog_rec_header  *rhead,
 xlog_cksum(
        struct xlog             *log,
        struct xlog_rec_header  *rhead,
index dc3498bf17c2b0cca9978d5b5ec802cfaabef657..16d8d12ea3b472cbf57d714f2952f4782e4c8a41 100644 (file)
@@ -555,7 +555,7 @@ extern int
 xlog_recover_finish(
        struct xlog             *log);
 
 xlog_recover_finish(
        struct xlog             *log);
 
-extern __be32   xlog_cksum(struct xlog *log, struct xlog_rec_header *rhead,
+extern __le32   xlog_cksum(struct xlog *log, struct xlog_rec_header *rhead,
                            char *dp, int size);
 
 extern kmem_zone_t *xfs_log_ticket_zone;
                            char *dp, int size);
 
 extern kmem_zone_t *xfs_log_ticket_zone;
index 9c3651c9e75b46f0dcfcdefeadf7c13723eaca24..96fcbb85ff835d0223e292125f501482626bc60c 100644 (file)
@@ -3233,15 +3233,15 @@ xlog_unpack_data_crc(
        xfs_caddr_t             dp,
        struct xlog             *log)
 {
        xfs_caddr_t             dp,
        struct xlog             *log)
 {
-       __be32                  crc;
+       __le32                  crc;
 
        crc = xlog_cksum(log, rhead, dp, be32_to_cpu(rhead->h_len));
        if (crc != rhead->h_crc) {
                if (rhead->h_crc || xfs_sb_version_hascrc(&log->l_mp->m_sb)) {
                        xfs_alert(log->l_mp,
                "log record CRC mismatch: found 0x%x, expected 0x%x.\n",
 
        crc = xlog_cksum(log, rhead, dp, be32_to_cpu(rhead->h_len));
        if (crc != rhead->h_crc) {
                if (rhead->h_crc || xfs_sb_version_hascrc(&log->l_mp->m_sb)) {
                        xfs_alert(log->l_mp,
                "log record CRC mismatch: found 0x%x, expected 0x%x.\n",
-                                       be32_to_cpu(rhead->h_crc),
-                                       be32_to_cpu(crc));
+                                       le32_to_cpu(rhead->h_crc),
+                                       le32_to_cpu(crc));
                        xfs_hex_dump(dp, 32);
                }
 
                        xfs_hex_dump(dp, 32);
                }