Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128712
b: refs/heads/master
c: a5eb62e
h: refs/heads/master
v: v3
  • Loading branch information
Miguel authored and Chris Mason committed Sep 25, 2008
1 parent d7ece4d commit 933d7b5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 587f77043a1c86e2a7900ff2ce86bef3c1f4e075
refs/heads/master: a5eb62e345fc1818d0d8b6181463200a9e8dfe39
17 changes: 17 additions & 0 deletions trunk/fs/btrfs/crc32c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <asm/byteorder.h>
#include <linux/crc32c.h>
#include <linux/version.h>

/**
* implementation of crc32c_le() changed in linux-2.6.23,
* has of v0.13 btrfs-progs is using the latest version.
* We must workaround older implementations of crc32c_le()
* found on older kernel versions.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
#define btrfs_crc32c(seed, data, length) \
__cpu_to_le32( crc32c( __le32_to_cpu(seed), data, length) )
#else
#define btrfs_crc32c(seed, data, length) \
crc32c(seed, data, length)
#endif
4 changes: 2 additions & 2 deletions trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

#include <linux/fs.h>
#include <linux/blkdev.h>
#include <linux/crc32c.h>
#include <linux/scatterlist.h>
#include <linux/swap.h>
#include <linux/radix-tree.h>
#include <linux/writeback.h>
#include <linux/buffer_head.h> // for block_sync_page
#include <linux/workqueue.h>
#include "crc32c.h"
#include "ctree.h"
#include "disk-io.h"
#include "transaction.h"
Expand Down Expand Up @@ -100,7 +100,7 @@ struct extent_map *btree_get_extent(struct inode *inode, struct page *page,

u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len)
{
return crc32c(seed, data, len);
return btrfs_crc32c(seed, data, len);
}

void btrfs_csum_final(u32 crc, char *result)
Expand Down
12 changes: 5 additions & 7 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*/

#include <linux/sched.h>
#include <linux/crc32c.h>
#include <linux/pagemap.h>
#include "hash.h"
#include "crc32c.h"
#include "ctree.h"
#include "disk-io.h"
#include "print-tree.h"
Expand Down Expand Up @@ -398,16 +397,15 @@ static u64 hash_extent_ref(u64 root_objectid, u64 ref_generation,
u32 high_crc = ~(u32)0;
u32 low_crc = ~(u32)0;
__le64 lenum;

lenum = cpu_to_le64(root_objectid);
high_crc = crc32c(high_crc, &lenum, sizeof(lenum));
high_crc = btrfs_crc32c(high_crc, &lenum, sizeof(lenum));
lenum = cpu_to_le64(ref_generation);
low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
if (owner >= BTRFS_FIRST_FREE_OBJECTID) {
lenum = cpu_to_le64(owner);
low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
lenum = cpu_to_le64(owner_offset);
low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
}
return ((u64)high_crc << 32) | (u64)low_crc;
}
Expand Down

0 comments on commit 933d7b5

Please sign in to comment.