Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 339441
b: refs/heads/master
c: bc02e86
h: refs/heads/master
i:
  339439: cac0505
v: v3
  • Loading branch information
Christoph Hellwig authored and Ben Myers committed Nov 20, 2012
1 parent f20a6a0 commit f39cd3e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1813dd64057490e7a0678a885c4fe6d02f78bdc1
refs/heads/master: bc02e8693d875c2a9b0037cfd37fe0b726d26403
1 change: 1 addition & 0 deletions trunk/fs/xfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ config XFS_FS
tristate "XFS filesystem support"
depends on BLOCK
select EXPORTFS
select LIBCRC32C
help
XFS is a high performance journaling filesystem which originated
on the SGI IRIX platform. It is completely multi-threaded, can
Expand Down
6 changes: 6 additions & 0 deletions trunk/fs/xfs/uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ extern int uuid_is_nil(uuid_t *uuid);
extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]);

static inline void
uuid_copy(uuid_t *dst, uuid_t *src)
{
memcpy(dst, src, sizeof(uuid_t));
}

#endif /* __XFS_SUPPORT_UUID_H__ */
63 changes: 63 additions & 0 deletions trunk/fs/xfs/xfs_cksum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef _XFS_CKSUM_H
#define _XFS_CKSUM_H 1

#define XFS_CRC_SEED (~(__uint32_t)0)

/*
* 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));

/* 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.
*
* The CRC32c calculation uses LE format even on BE machines, but returns the
* result in host endian format. Hence we need to byte swap it back to LE format
* so that it is consistent on disk.
*/
static inline __le32
xfs_end_cksum(__uint32_t crc)
{
return ~cpu_to_le32(crc);
}

/*
* Helper to generate the checksum for a buffer.
*/
static inline void
xfs_update_cksum(char *buffer, size_t length, unsigned long cksum_offset)
{
__uint32_t crc = xfs_start_cksum(buffer, length, cksum_offset);

*(__le32 *)(buffer + cksum_offset) = xfs_end_cksum(crc);
}

/*
* Helper to verify the checksum for a buffer.
*/
static inline int
xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset)
{
__uint32_t crc = xfs_start_cksum(buffer, length, cksum_offset);

return *(__le32 *)(buffer + cksum_offset) == xfs_end_cksum(crc);
}

#endif /* _XFS_CKSUM_H */
1 change: 1 addition & 0 deletions trunk/fs/xfs/xfs_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/slab.h>
#include <linux/crc32c.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/file.h>
Expand Down
7 changes: 7 additions & 0 deletions trunk/fs/xfs/xfs_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct xfs_mount;
#define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
#define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */
#define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32 bit project id */
#define XFS_SB_VERSION2_CRCBIT 0x00000100 /* metadata CRCs */

#define XFS_SB_VERSION2_OKREALFBITS \
(XFS_SB_VERSION2_LAZYSBCOUNTBIT | \
Expand Down Expand Up @@ -503,6 +504,12 @@ static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp)
(sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT);
}

static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp)
{
return (xfs_sb_version_hasmorebits(sbp) &&
(sbp->sb_features2 & XFS_SB_VERSION2_CRCBIT));
}

/*
* end of superblock version macros
*/
Expand Down

0 comments on commit f39cd3e

Please sign in to comment.