aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-06-22 14:16:24 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-06-22 14:16:24 -0400
commit11bd143fc8243cf48c934dc1c4479a5aacf58ce3 (patch)
tree51611e84a9d507d316cb5e4f124f488cd44a6c7f /fs/btrfs
parente011599b0f375683499bf1a9954703f4959a8d00 (diff)
Btrfs: Switch to libcrc32c to avoid problems with cryptomgr on highmem machines
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ctree.h4
-rw-r--r--fs/btrfs/disk-io.c30
-rw-r--r--fs/btrfs/file.c3
3 files changed, 8 insertions, 29 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1e83ad720b10..19a1d998fca7 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -286,10 +286,7 @@ struct btrfs_block_group_cache {
286 int cached; 286 int cached;
287}; 287};
288 288
289struct crypto_hash;
290
291struct btrfs_fs_info { 289struct btrfs_fs_info {
292 spinlock_t hash_lock;
293 struct btrfs_root *extent_root; 290 struct btrfs_root *extent_root;
294 struct btrfs_root *tree_root; 291 struct btrfs_root *tree_root;
295 struct radix_tree_root fs_roots_radix; 292 struct radix_tree_root fs_roots_radix;
@@ -314,7 +311,6 @@ struct btrfs_fs_info {
314 struct mutex fs_mutex; 311 struct mutex fs_mutex;
315 struct list_head trans_list; 312 struct list_head trans_list;
316 struct list_head dead_roots; 313 struct list_head dead_roots;
317 struct crypto_hash *hash_tfm;
318 struct delayed_work trans_work; 314 struct delayed_work trans_work;
319 int do_barriers; 315 int do_barriers;
320 int closing; 316 int closing;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 15cc9ec92308..3712e946f9c8 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -19,7 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/crypto.h> 22#include <linux/crc32c.h>
23#include <linux/scatterlist.h> 23#include <linux/scatterlist.h>
24#include <linux/swap.h> 24#include <linux/swap.h>
25#include <linux/radix-tree.h> 25#include <linux/radix-tree.h>
@@ -147,22 +147,12 @@ static int btree_get_block(struct inode *inode, sector_t iblock,
147int btrfs_csum_data(struct btrfs_root * root, char *data, size_t len, 147int btrfs_csum_data(struct btrfs_root * root, char *data, size_t len,
148 char *result) 148 char *result)
149{ 149{
150 struct scatterlist sg; 150 u32 crc;
151 struct crypto_hash *tfm = root->fs_info->hash_tfm; 151 crc = crc32c(0, data, len);
152 struct hash_desc desc; 152 memcpy(result, &crc, BTRFS_CRC32_SIZE);
153 int ret; 153 return 0;
154
155 desc.tfm = tfm;
156 desc.flags = 0;
157 sg_init_one(&sg, data, len);
158 spin_lock_irq(&root->fs_info->hash_lock);
159 ret = crypto_hash_digest(&desc, &sg, 1, result);
160 spin_unlock_irq(&root->fs_info->hash_lock);
161 if (ret) {
162 printk("digest failed\n");
163 }
164 return ret;
165} 154}
155
166static int csum_tree_block(struct btrfs_root *root, struct buffer_head *bh, 156static int csum_tree_block(struct btrfs_root *root, struct buffer_head *bh,
167 int verify) 157 int verify)
168{ 158{
@@ -454,14 +444,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
454 sizeof(struct btrfs_key)); 444 sizeof(struct btrfs_key));
455 insert_inode_hash(fs_info->btree_inode); 445 insert_inode_hash(fs_info->btree_inode);
456 mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS); 446 mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
457 fs_info->hash_tfm = crypto_alloc_hash("crc32c", 0, CRYPTO_ALG_ASYNC);
458 spin_lock_init(&fs_info->hash_lock);
459 447
460 if (!fs_info->hash_tfm || IS_ERR(fs_info->hash_tfm)) {
461 printk("btrfs: failed hash setup, modprobe cryptomgr?\n");
462 err = -ENOMEM;
463 goto fail_iput;
464 }
465 mutex_init(&fs_info->trans_mutex); 448 mutex_init(&fs_info->trans_mutex);
466 mutex_init(&fs_info->fs_mutex); 449 mutex_init(&fs_info->fs_mutex);
467 450
@@ -613,7 +596,6 @@ int close_ctree(struct btrfs_root *root)
613 btrfs_block_release(fs_info->tree_root, 596 btrfs_block_release(fs_info->tree_root,
614 fs_info->tree_root->node); 597 fs_info->tree_root->node);
615 btrfs_block_release(root, fs_info->sb_buffer); 598 btrfs_block_release(root, fs_info->sb_buffer);
616 crypto_free_hash(fs_info->hash_tfm);
617 truncate_inode_pages(fs_info->btree_inode->i_mapping, 0); 599 truncate_inode_pages(fs_info->btree_inode->i_mapping, 0);
618 iput(fs_info->btree_inode); 600 iput(fs_info->btree_inode);
619 601
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 6b455c2b3f03..23f029359688 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -607,7 +607,8 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
607 607
608 while(count > 0) { 608 while(count > 0) {
609 size_t offset = pos & (PAGE_CACHE_SIZE - 1); 609 size_t offset = pos & (PAGE_CACHE_SIZE - 1);
610 size_t write_bytes = min(count, nrptrs * PAGE_CACHE_SIZE - 610 size_t write_bytes = min(count, nrptrs *
611 (size_t)PAGE_CACHE_SIZE -
611 offset); 612 offset);
612 size_t num_pages = (write_bytes + PAGE_CACHE_SIZE - 1) >> 613 size_t num_pages = (write_bytes + PAGE_CACHE_SIZE - 1) >>
613 PAGE_CACHE_SHIFT; 614 PAGE_CACHE_SHIFT;