blob: 9b99886562d0b2c8ea9e883f3f2623b0ec6d8674 [file] [log] [blame]
Chris Mason6cbd5572007-06-12 09:07:21 -04001/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
17 */
18
Chris Mason065631f2008-02-20 12:07:25 -050019#include <linux/bio.h>
20#include <linux/pagemap.h>
21#include <linux/highmem.h>
Chris Mason1e1d2702007-03-15 19:03:33 -040022#include "ctree.h"
Chris Masondee26a92007-03-26 16:00:06 -040023#include "disk-io.h"
Chris Mason9f5fae22007-03-20 14:38:32 -040024#include "transaction.h"
Chris Mason1de037a2007-05-29 15:17:08 -040025#include "print-tree.h"
Chris Mason1e1d2702007-03-15 19:03:33 -040026
Chris Masond3977122009-01-05 21:25:51 -050027#define MAX_CSUM_ITEMS(r, size) ((((BTRFS_LEAF_DATA_SIZE(r) - \
Josef Bacik607d4322008-12-02 07:17:45 -050028 sizeof(struct btrfs_item) * 2) / \
29 size) - 1))
Yan Zheng07d400a2009-01-06 11:42:00 -050030
31#define MAX_ORDERED_SUM_BYTES(r) ((PAGE_SIZE - \
32 sizeof(struct btrfs_ordered_sum)) / \
33 sizeof(struct btrfs_sector_sum) * \
34 (r)->sectorsize - (r)->sectorsize)
35
Chris Masonb18c6682007-04-17 13:26:50 -040036int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
Sage Weilf2eb0a22008-05-02 14:43:14 -040037 struct btrfs_root *root,
38 u64 objectid, u64 pos,
39 u64 disk_offset, u64 disk_num_bytes,
Chris Masonc8b97812008-10-29 14:49:59 -040040 u64 num_bytes, u64 offset, u64 ram_bytes,
41 u8 compression, u8 encryption, u16 other_encoding)
Chris Mason9f5fae22007-03-20 14:38:32 -040042{
Chris Masondee26a92007-03-26 16:00:06 -040043 int ret = 0;
44 struct btrfs_file_extent_item *item;
45 struct btrfs_key file_key;
Chris Mason5caf2a02007-04-02 11:20:42 -040046 struct btrfs_path *path;
Chris Mason5f39d392007-10-15 16:14:19 -040047 struct extent_buffer *leaf;
Chris Masondee26a92007-03-26 16:00:06 -040048
Chris Mason5caf2a02007-04-02 11:20:42 -040049 path = btrfs_alloc_path();
50 BUG_ON(!path);
Chris Masondee26a92007-03-26 16:00:06 -040051 file_key.objectid = objectid;
Chris Masonb18c6682007-04-17 13:26:50 -040052 file_key.offset = pos;
Chris Masondee26a92007-03-26 16:00:06 -040053 btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
54
Chris Masonb9473432009-03-13 11:00:37 -040055 path->leave_spinning = 1;
Chris Mason5caf2a02007-04-02 11:20:42 -040056 ret = btrfs_insert_empty_item(trans, root, path, &file_key,
Chris Masondee26a92007-03-26 16:00:06 -040057 sizeof(*item));
Chris Mason54aa1f42007-06-22 14:16:25 -040058 if (ret < 0)
59 goto out;
Chris Mason9773a782007-03-27 11:26:26 -040060 BUG_ON(ret);
Chris Mason5f39d392007-10-15 16:14:19 -040061 leaf = path->nodes[0];
62 item = btrfs_item_ptr(leaf, path->slots[0],
Chris Masondee26a92007-03-26 16:00:06 -040063 struct btrfs_file_extent_item);
Sage Weilf2eb0a22008-05-02 14:43:14 -040064 btrfs_set_file_extent_disk_bytenr(leaf, item, disk_offset);
Chris Masondb945352007-10-15 16:15:53 -040065 btrfs_set_file_extent_disk_num_bytes(leaf, item, disk_num_bytes);
Sage Weilf2eb0a22008-05-02 14:43:14 -040066 btrfs_set_file_extent_offset(leaf, item, offset);
Chris Masondb945352007-10-15 16:15:53 -040067 btrfs_set_file_extent_num_bytes(leaf, item, num_bytes);
Chris Masonc8b97812008-10-29 14:49:59 -040068 btrfs_set_file_extent_ram_bytes(leaf, item, ram_bytes);
Chris Mason5f39d392007-10-15 16:14:19 -040069 btrfs_set_file_extent_generation(leaf, item, trans->transid);
70 btrfs_set_file_extent_type(leaf, item, BTRFS_FILE_EXTENT_REG);
Chris Masonc8b97812008-10-29 14:49:59 -040071 btrfs_set_file_extent_compression(leaf, item, compression);
72 btrfs_set_file_extent_encryption(leaf, item, encryption);
73 btrfs_set_file_extent_other_encoding(leaf, item, other_encoding);
74
Chris Mason5f39d392007-10-15 16:14:19 -040075 btrfs_mark_buffer_dirty(leaf);
Chris Mason54aa1f42007-06-22 14:16:25 -040076out:
Chris Mason5caf2a02007-04-02 11:20:42 -040077 btrfs_free_path(path);
Chris Mason54aa1f42007-06-22 14:16:25 -040078 return ret;
Chris Mason9f5fae22007-03-20 14:38:32 -040079}
Chris Masondee26a92007-03-26 16:00:06 -040080
Chris Masonb18c6682007-04-17 13:26:50 -040081struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
82 struct btrfs_root *root,
83 struct btrfs_path *path,
Chris Masond20f7042008-12-08 16:58:54 -050084 u64 bytenr, int cow)
Chris Mason6567e832007-04-16 09:22:45 -040085{
86 int ret;
87 struct btrfs_key file_key;
88 struct btrfs_key found_key;
89 struct btrfs_csum_item *item;
Chris Mason5f39d392007-10-15 16:14:19 -040090 struct extent_buffer *leaf;
Chris Mason6567e832007-04-16 09:22:45 -040091 u64 csum_offset = 0;
Josef Bacik607d4322008-12-02 07:17:45 -050092 u16 csum_size =
93 btrfs_super_csum_size(&root->fs_info->super_copy);
Chris Masona429e512007-04-18 16:15:28 -040094 int csums_in_item;
Chris Mason6567e832007-04-16 09:22:45 -040095
Chris Masond20f7042008-12-08 16:58:54 -050096 file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
97 file_key.offset = bytenr;
98 btrfs_set_key_type(&file_key, BTRFS_EXTENT_CSUM_KEY);
Chris Masonb18c6682007-04-17 13:26:50 -040099 ret = btrfs_search_slot(trans, root, &file_key, path, 0, cow);
Chris Mason6567e832007-04-16 09:22:45 -0400100 if (ret < 0)
101 goto fail;
Chris Mason5f39d392007-10-15 16:14:19 -0400102 leaf = path->nodes[0];
Chris Mason6567e832007-04-16 09:22:45 -0400103 if (ret > 0) {
104 ret = 1;
Chris Mason70b2bef2007-04-17 15:39:32 -0400105 if (path->slots[0] == 0)
Chris Mason6567e832007-04-16 09:22:45 -0400106 goto fail;
107 path->slots[0]--;
Chris Mason5f39d392007-10-15 16:14:19 -0400108 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
Chris Masond20f7042008-12-08 16:58:54 -0500109 if (btrfs_key_type(&found_key) != BTRFS_EXTENT_CSUM_KEY)
Chris Mason6567e832007-04-16 09:22:45 -0400110 goto fail;
Chris Masond20f7042008-12-08 16:58:54 -0500111
112 csum_offset = (bytenr - found_key.offset) >>
Chris Mason6567e832007-04-16 09:22:45 -0400113 root->fs_info->sb->s_blocksize_bits;
Chris Mason5f39d392007-10-15 16:14:19 -0400114 csums_in_item = btrfs_item_size_nr(leaf, path->slots[0]);
Josef Bacik607d4322008-12-02 07:17:45 -0500115 csums_in_item /= csum_size;
Chris Masona429e512007-04-18 16:15:28 -0400116
117 if (csum_offset >= csums_in_item) {
118 ret = -EFBIG;
Chris Mason6567e832007-04-16 09:22:45 -0400119 goto fail;
120 }
121 }
122 item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item);
Chris Mason509659c2007-05-10 12:36:17 -0400123 item = (struct btrfs_csum_item *)((unsigned char *)item +
Josef Bacik607d4322008-12-02 07:17:45 -0500124 csum_offset * csum_size);
Chris Mason6567e832007-04-16 09:22:45 -0400125 return item;
126fail:
127 if (ret > 0)
Chris Masonb18c6682007-04-17 13:26:50 -0400128 ret = -ENOENT;
Chris Mason6567e832007-04-16 09:22:45 -0400129 return ERR_PTR(ret);
130}
131
132
Chris Masondee26a92007-03-26 16:00:06 -0400133int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
134 struct btrfs_root *root,
135 struct btrfs_path *path, u64 objectid,
Chris Mason9773a782007-03-27 11:26:26 -0400136 u64 offset, int mod)
Chris Masondee26a92007-03-26 16:00:06 -0400137{
138 int ret;
139 struct btrfs_key file_key;
140 int ins_len = mod < 0 ? -1 : 0;
141 int cow = mod != 0;
142
143 file_key.objectid = objectid;
Chris Mason70b2bef2007-04-17 15:39:32 -0400144 file_key.offset = offset;
Chris Masondee26a92007-03-26 16:00:06 -0400145 btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
146 ret = btrfs_search_slot(trans, root, &file_key, path, ins_len, cow);
147 return ret;
148}
Chris Masonf254e522007-03-29 15:15:27 -0400149
Yan Zheng17d217f2008-12-12 10:03:38 -0500150
Chris Mason61b49442008-07-31 15:42:53 -0400151int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
Chris Masond20f7042008-12-08 16:58:54 -0500152 struct bio *bio, u32 *dst)
Chris Mason61b49442008-07-31 15:42:53 -0400153{
154 u32 sum;
155 struct bio_vec *bvec = bio->bi_io_vec;
156 int bio_index = 0;
157 u64 offset;
158 u64 item_start_offset = 0;
159 u64 item_last_offset = 0;
Chris Masond20f7042008-12-08 16:58:54 -0500160 u64 disk_bytenr;
Chris Mason61b49442008-07-31 15:42:53 -0400161 u32 diff;
Josef Bacik607d4322008-12-02 07:17:45 -0500162 u16 csum_size =
163 btrfs_super_csum_size(&root->fs_info->super_copy);
Chris Mason61b49442008-07-31 15:42:53 -0400164 int ret;
165 struct btrfs_path *path;
166 struct btrfs_csum_item *item = NULL;
167 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
168
169 path = btrfs_alloc_path();
Chris Mason4d1b5fb2008-08-20 09:44:52 -0400170 if (bio->bi_size > PAGE_CACHE_SIZE * 8)
171 path->reada = 2;
Chris Mason61b49442008-07-31 15:42:53 -0400172
173 WARN_ON(bio->bi_vcnt <= 0);
174
Chris Masond20f7042008-12-08 16:58:54 -0500175 disk_bytenr = (u64)bio->bi_sector << 9;
Chris Masond3977122009-01-05 21:25:51 -0500176 while (bio_index < bio->bi_vcnt) {
Chris Mason61b49442008-07-31 15:42:53 -0400177 offset = page_offset(bvec->bv_page) + bvec->bv_offset;
Chris Masond20f7042008-12-08 16:58:54 -0500178 ret = btrfs_find_ordered_sum(inode, offset, disk_bytenr, &sum);
Chris Mason61b49442008-07-31 15:42:53 -0400179 if (ret == 0)
180 goto found;
181
Chris Masond20f7042008-12-08 16:58:54 -0500182 if (!item || disk_bytenr < item_start_offset ||
183 disk_bytenr >= item_last_offset) {
Chris Mason61b49442008-07-31 15:42:53 -0400184 struct btrfs_key found_key;
185 u32 item_size;
186
187 if (item)
188 btrfs_release_path(root, path);
Chris Masond20f7042008-12-08 16:58:54 -0500189 item = btrfs_lookup_csum(NULL, root->fs_info->csum_root,
190 path, disk_bytenr, 0);
Chris Mason61b49442008-07-31 15:42:53 -0400191 if (IS_ERR(item)) {
192 ret = PTR_ERR(item);
193 if (ret == -ENOENT || ret == -EFBIG)
194 ret = 0;
195 sum = 0;
Yan Zheng17d217f2008-12-12 10:03:38 -0500196 if (BTRFS_I(inode)->root->root_key.objectid ==
197 BTRFS_DATA_RELOC_TREE_OBJECTID) {
198 set_extent_bits(io_tree, offset,
199 offset + bvec->bv_len - 1,
200 EXTENT_NODATASUM, GFP_NOFS);
201 } else {
Chris Masond3977122009-01-05 21:25:51 -0500202 printk(KERN_INFO "btrfs no csum found "
203 "for inode %lu start %llu\n",
204 inode->i_ino,
Yan Zheng17d217f2008-12-12 10:03:38 -0500205 (unsigned long long)offset);
206 }
Chris Mason6dab8152008-08-04 08:35:53 -0400207 item = NULL;
Chris Mason39be25c2008-11-10 11:50:50 -0500208 btrfs_release_path(root, path);
Chris Mason61b49442008-07-31 15:42:53 -0400209 goto found;
210 }
211 btrfs_item_key_to_cpu(path->nodes[0], &found_key,
212 path->slots[0]);
213
214 item_start_offset = found_key.offset;
215 item_size = btrfs_item_size_nr(path->nodes[0],
216 path->slots[0]);
217 item_last_offset = item_start_offset +
Josef Bacik607d4322008-12-02 07:17:45 -0500218 (item_size / csum_size) *
Chris Mason61b49442008-07-31 15:42:53 -0400219 root->sectorsize;
220 item = btrfs_item_ptr(path->nodes[0], path->slots[0],
221 struct btrfs_csum_item);
222 }
223 /*
224 * this byte range must be able to fit inside
225 * a single leaf so it will also fit inside a u32
226 */
Chris Masond20f7042008-12-08 16:58:54 -0500227 diff = disk_bytenr - item_start_offset;
Chris Mason61b49442008-07-31 15:42:53 -0400228 diff = diff / root->sectorsize;
Josef Bacik607d4322008-12-02 07:17:45 -0500229 diff = diff * csum_size;
Chris Mason61b49442008-07-31 15:42:53 -0400230
231 read_extent_buffer(path->nodes[0], &sum,
Chris Mason3de9d6b2008-08-04 23:17:27 -0400232 ((unsigned long)item) + diff,
Josef Bacik607d4322008-12-02 07:17:45 -0500233 csum_size);
Chris Mason61b49442008-07-31 15:42:53 -0400234found:
Chris Masond20f7042008-12-08 16:58:54 -0500235 if (dst)
236 *dst++ = sum;
237 else
238 set_state_private(io_tree, offset, sum);
239 disk_bytenr += bvec->bv_len;
Chris Mason61b49442008-07-31 15:42:53 -0400240 bio_index++;
241 bvec++;
242 }
243 btrfs_free_path(path);
244 return 0;
245}
246
Yan Zheng17d217f2008-12-12 10:03:38 -0500247int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
248 struct list_head *list)
249{
250 struct btrfs_key key;
251 struct btrfs_path *path;
252 struct extent_buffer *leaf;
253 struct btrfs_ordered_sum *sums;
254 struct btrfs_sector_sum *sector_sum;
255 struct btrfs_csum_item *item;
256 unsigned long offset;
257 int ret;
258 size_t size;
259 u64 csum_end;
260 u16 csum_size = btrfs_super_csum_size(&root->fs_info->super_copy);
261
262 path = btrfs_alloc_path();
263 BUG_ON(!path);
264
265 key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
266 key.offset = start;
267 key.type = BTRFS_EXTENT_CSUM_KEY;
268
Yan Zheng07d400a2009-01-06 11:42:00 -0500269 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
Yan Zheng17d217f2008-12-12 10:03:38 -0500270 if (ret < 0)
271 goto fail;
272 if (ret > 0 && path->slots[0] > 0) {
273 leaf = path->nodes[0];
274 btrfs_item_key_to_cpu(leaf, &key, path->slots[0] - 1);
275 if (key.objectid == BTRFS_EXTENT_CSUM_OBJECTID &&
276 key.type == BTRFS_EXTENT_CSUM_KEY) {
277 offset = (start - key.offset) >>
278 root->fs_info->sb->s_blocksize_bits;
279 if (offset * csum_size <
280 btrfs_item_size_nr(leaf, path->slots[0] - 1))
281 path->slots[0]--;
282 }
283 }
284
285 while (start <= end) {
286 leaf = path->nodes[0];
287 if (path->slots[0] >= btrfs_header_nritems(leaf)) {
Yan Zheng07d400a2009-01-06 11:42:00 -0500288 ret = btrfs_next_leaf(root, path);
Yan Zheng17d217f2008-12-12 10:03:38 -0500289 if (ret < 0)
290 goto fail;
291 if (ret > 0)
292 break;
293 leaf = path->nodes[0];
294 }
295
296 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
297 if (key.objectid != BTRFS_EXTENT_CSUM_OBJECTID ||
298 key.type != BTRFS_EXTENT_CSUM_KEY)
299 break;
300
301 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
302 if (key.offset > end)
303 break;
304
305 if (key.offset > start)
306 start = key.offset;
307
308 size = btrfs_item_size_nr(leaf, path->slots[0]);
309 csum_end = key.offset + (size / csum_size) * root->sectorsize;
Yan Zheng87b29b22008-12-17 10:21:48 -0500310 if (csum_end <= start) {
311 path->slots[0]++;
312 continue;
313 }
Yan Zheng17d217f2008-12-12 10:03:38 -0500314
Yan Zheng07d400a2009-01-06 11:42:00 -0500315 csum_end = min(csum_end, end + 1);
Yan Zheng17d217f2008-12-12 10:03:38 -0500316 item = btrfs_item_ptr(path->nodes[0], path->slots[0],
317 struct btrfs_csum_item);
Yan Zheng07d400a2009-01-06 11:42:00 -0500318 while (start < csum_end) {
319 size = min_t(size_t, csum_end - start,
320 MAX_ORDERED_SUM_BYTES(root));
321 sums = kzalloc(btrfs_ordered_sum_size(root, size),
322 GFP_NOFS);
323 BUG_ON(!sums);
Yan Zheng17d217f2008-12-12 10:03:38 -0500324
Yan Zheng07d400a2009-01-06 11:42:00 -0500325 sector_sum = sums->sums;
326 sums->bytenr = start;
327 sums->len = size;
328
329 offset = (start - key.offset) >>
330 root->fs_info->sb->s_blocksize_bits;
331 offset *= csum_size;
332
333 while (size > 0) {
334 read_extent_buffer(path->nodes[0],
335 &sector_sum->sum,
336 ((unsigned long)item) +
337 offset, csum_size);
338 sector_sum->bytenr = start;
339
340 size -= root->sectorsize;
341 start += root->sectorsize;
342 offset += csum_size;
343 sector_sum++;
344 }
345 list_add_tail(&sums->list, list);
Yan Zheng17d217f2008-12-12 10:03:38 -0500346 }
Yan Zheng17d217f2008-12-12 10:03:38 -0500347 path->slots[0]++;
348 }
349 ret = 0;
350fail:
351 btrfs_free_path(path);
352 return ret;
353}
354
Chris Mason3edf7d32008-07-18 06:17:13 -0400355int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode,
Chris Masond20f7042008-12-08 16:58:54 -0500356 struct bio *bio, u64 file_start, int contig)
Chris Masone0156402008-04-16 11:15:20 -0400357{
Chris Masone6dcd2d2008-07-17 12:53:50 -0400358 struct btrfs_ordered_sum *sums;
359 struct btrfs_sector_sum *sector_sum;
Chris Mason3edf7d32008-07-18 06:17:13 -0400360 struct btrfs_ordered_extent *ordered;
Chris Masone0156402008-04-16 11:15:20 -0400361 char *data;
362 struct bio_vec *bvec = bio->bi_io_vec;
363 int bio_index = 0;
Chris Mason3edf7d32008-07-18 06:17:13 -0400364 unsigned long total_bytes = 0;
365 unsigned long this_sum_bytes = 0;
366 u64 offset;
Chris Masond20f7042008-12-08 16:58:54 -0500367 u64 disk_bytenr;
Chris Masone0156402008-04-16 11:15:20 -0400368
Chris Masone6dcd2d2008-07-17 12:53:50 -0400369 WARN_ON(bio->bi_vcnt <= 0);
370 sums = kzalloc(btrfs_ordered_sum_size(root, bio->bi_size), GFP_NOFS);
Chris Masone0156402008-04-16 11:15:20 -0400371 if (!sums)
372 return -ENOMEM;
Chris Mason3edf7d32008-07-18 06:17:13 -0400373
Chris Masoned98b562008-07-22 23:06:42 -0400374 sector_sum = sums->sums;
Chris Masond20f7042008-12-08 16:58:54 -0500375 disk_bytenr = (u64)bio->bi_sector << 9;
Chris Masone6dcd2d2008-07-17 12:53:50 -0400376 sums->len = bio->bi_size;
377 INIT_LIST_HEAD(&sums->list);
Chris Masond20f7042008-12-08 16:58:54 -0500378
379 if (contig)
380 offset = file_start;
381 else
382 offset = page_offset(bvec->bv_page) + bvec->bv_offset;
383
384 ordered = btrfs_lookup_ordered_extent(inode, offset);
Chris Mason3edf7d32008-07-18 06:17:13 -0400385 BUG_ON(!ordered);
Chris Masond20f7042008-12-08 16:58:54 -0500386 sums->bytenr = ordered->start;
Chris Masone0156402008-04-16 11:15:20 -0400387
Chris Masond3977122009-01-05 21:25:51 -0500388 while (bio_index < bio->bi_vcnt) {
Chris Masond20f7042008-12-08 16:58:54 -0500389 if (!contig)
390 offset = page_offset(bvec->bv_page) + bvec->bv_offset;
391
392 if (!contig && (offset >= ordered->file_offset + ordered->len ||
393 offset < ordered->file_offset)) {
Chris Mason3edf7d32008-07-18 06:17:13 -0400394 unsigned long bytes_left;
395 sums->len = this_sum_bytes;
396 this_sum_bytes = 0;
397 btrfs_add_ordered_sum(inode, ordered, sums);
398 btrfs_put_ordered_extent(ordered);
399
400 bytes_left = bio->bi_size - total_bytes;
401
402 sums = kzalloc(btrfs_ordered_sum_size(root, bytes_left),
403 GFP_NOFS);
404 BUG_ON(!sums);
Chris Masoned98b562008-07-22 23:06:42 -0400405 sector_sum = sums->sums;
Chris Mason3edf7d32008-07-18 06:17:13 -0400406 sums->len = bytes_left;
Chris Masond20f7042008-12-08 16:58:54 -0500407 ordered = btrfs_lookup_ordered_extent(inode, offset);
Chris Mason3edf7d32008-07-18 06:17:13 -0400408 BUG_ON(!ordered);
Chris Masond20f7042008-12-08 16:58:54 -0500409 sums->bytenr = ordered->start;
Chris Mason3edf7d32008-07-18 06:17:13 -0400410 }
411
Chris Masone0156402008-04-16 11:15:20 -0400412 data = kmap_atomic(bvec->bv_page, KM_USER0);
Chris Masone6dcd2d2008-07-17 12:53:50 -0400413 sector_sum->sum = ~(u32)0;
414 sector_sum->sum = btrfs_csum_data(root,
415 data + bvec->bv_offset,
416 sector_sum->sum,
417 bvec->bv_len);
Chris Masone0156402008-04-16 11:15:20 -0400418 kunmap_atomic(data, KM_USER0);
Chris Masone6dcd2d2008-07-17 12:53:50 -0400419 btrfs_csum_final(sector_sum->sum,
420 (char *)&sector_sum->sum);
Chris Masond20f7042008-12-08 16:58:54 -0500421 sector_sum->bytenr = disk_bytenr;
Chris Masoned98b562008-07-22 23:06:42 -0400422
Chris Masone6dcd2d2008-07-17 12:53:50 -0400423 sector_sum++;
Chris Masone0156402008-04-16 11:15:20 -0400424 bio_index++;
Chris Mason3edf7d32008-07-18 06:17:13 -0400425 total_bytes += bvec->bv_len;
426 this_sum_bytes += bvec->bv_len;
Chris Masond20f7042008-12-08 16:58:54 -0500427 disk_bytenr += bvec->bv_len;
428 offset += bvec->bv_len;
Chris Masone0156402008-04-16 11:15:20 -0400429 bvec++;
430 }
Chris Masoned98b562008-07-22 23:06:42 -0400431 this_sum_bytes = 0;
Chris Mason3edf7d32008-07-18 06:17:13 -0400432 btrfs_add_ordered_sum(inode, ordered, sums);
433 btrfs_put_ordered_extent(ordered);
Chris Masone0156402008-04-16 11:15:20 -0400434 return 0;
435}
436
Chris Mason459931e2008-12-10 09:10:46 -0500437/*
438 * helper function for csum removal, this expects the
439 * key to describe the csum pointed to by the path, and it expects
440 * the csum to overlap the range [bytenr, len]
441 *
442 * The csum should not be entirely contained in the range and the
443 * range should not be entirely contained in the csum.
444 *
445 * This calls btrfs_truncate_item with the correct args based on the
446 * overlap, and fixes up the key as required.
447 */
448static noinline int truncate_one_csum(struct btrfs_trans_handle *trans,
449 struct btrfs_root *root,
450 struct btrfs_path *path,
451 struct btrfs_key *key,
452 u64 bytenr, u64 len)
453{
454 struct extent_buffer *leaf;
455 u16 csum_size =
456 btrfs_super_csum_size(&root->fs_info->super_copy);
457 u64 csum_end;
458 u64 end_byte = bytenr + len;
459 u32 blocksize_bits = root->fs_info->sb->s_blocksize_bits;
460 int ret;
461
462 leaf = path->nodes[0];
463 csum_end = btrfs_item_size_nr(leaf, path->slots[0]) / csum_size;
464 csum_end <<= root->fs_info->sb->s_blocksize_bits;
465 csum_end += key->offset;
466
467 if (key->offset < bytenr && csum_end <= end_byte) {
468 /*
469 * [ bytenr - len ]
470 * [ ]
471 * [csum ]
472 * A simple truncate off the end of the item
473 */
474 u32 new_size = (bytenr - key->offset) >> blocksize_bits;
475 new_size *= csum_size;
476 ret = btrfs_truncate_item(trans, root, path, new_size, 1);
477 BUG_ON(ret);
478 } else if (key->offset >= bytenr && csum_end > end_byte &&
479 end_byte > key->offset) {
480 /*
481 * [ bytenr - len ]
482 * [ ]
483 * [csum ]
484 * we need to truncate from the beginning of the csum
485 */
486 u32 new_size = (csum_end - end_byte) >> blocksize_bits;
487 new_size *= csum_size;
488
489 ret = btrfs_truncate_item(trans, root, path, new_size, 0);
490 BUG_ON(ret);
491
492 key->offset = end_byte;
493 ret = btrfs_set_item_key_safe(trans, root, path, key);
494 BUG_ON(ret);
495 } else {
496 BUG();
497 }
498 return 0;
499}
500
501/*
502 * deletes the csum items from the csum tree for a given
503 * range of bytes.
504 */
505int btrfs_del_csums(struct btrfs_trans_handle *trans,
506 struct btrfs_root *root, u64 bytenr, u64 len)
507{
508 struct btrfs_path *path;
509 struct btrfs_key key;
510 u64 end_byte = bytenr + len;
511 u64 csum_end;
512 struct extent_buffer *leaf;
513 int ret;
514 u16 csum_size =
515 btrfs_super_csum_size(&root->fs_info->super_copy);
516 int blocksize_bits = root->fs_info->sb->s_blocksize_bits;
517
518 root = root->fs_info->csum_root;
519
520 path = btrfs_alloc_path();
521
Chris Masond3977122009-01-05 21:25:51 -0500522 while (1) {
Chris Mason459931e2008-12-10 09:10:46 -0500523 key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
524 key.offset = end_byte - 1;
525 key.type = BTRFS_EXTENT_CSUM_KEY;
526
Chris Masonb9473432009-03-13 11:00:37 -0400527 path->leave_spinning = 1;
Chris Mason459931e2008-12-10 09:10:46 -0500528 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
529 if (ret > 0) {
530 if (path->slots[0] == 0)
531 goto out;
532 path->slots[0]--;
533 }
534 leaf = path->nodes[0];
535 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
536
537 if (key.objectid != BTRFS_EXTENT_CSUM_OBJECTID ||
538 key.type != BTRFS_EXTENT_CSUM_KEY) {
539 break;
540 }
541
542 if (key.offset >= end_byte)
543 break;
544
545 csum_end = btrfs_item_size_nr(leaf, path->slots[0]) / csum_size;
546 csum_end <<= blocksize_bits;
547 csum_end += key.offset;
548
549 /* this csum ends before we start, we're done */
550 if (csum_end <= bytenr)
551 break;
552
553 /* delete the entire item, it is inside our range */
554 if (key.offset >= bytenr && csum_end <= end_byte) {
555 ret = btrfs_del_item(trans, root, path);
556 BUG_ON(ret);
Chris Masondcbdd4d2008-12-16 13:51:01 -0500557 if (key.offset == bytenr)
558 break;
Chris Mason459931e2008-12-10 09:10:46 -0500559 } else if (key.offset < bytenr && csum_end > end_byte) {
560 unsigned long offset;
561 unsigned long shift_len;
562 unsigned long item_offset;
563 /*
564 * [ bytenr - len ]
565 * [csum ]
566 *
567 * Our bytes are in the middle of the csum,
568 * we need to split this item and insert a new one.
569 *
570 * But we can't drop the path because the
571 * csum could change, get removed, extended etc.
572 *
573 * The trick here is the max size of a csum item leaves
574 * enough room in the tree block for a single
575 * item header. So, we split the item in place,
576 * adding a new header pointing to the existing
577 * bytes. Then we loop around again and we have
578 * a nicely formed csum item that we can neatly
579 * truncate.
580 */
581 offset = (bytenr - key.offset) >> blocksize_bits;
582 offset *= csum_size;
583
584 shift_len = (len >> blocksize_bits) * csum_size;
585
586 item_offset = btrfs_item_ptr_offset(leaf,
587 path->slots[0]);
588
589 memset_extent_buffer(leaf, 0, item_offset + offset,
590 shift_len);
591 key.offset = bytenr;
592
593 /*
594 * btrfs_split_item returns -EAGAIN when the
595 * item changed size or key
596 */
597 ret = btrfs_split_item(trans, root, path, &key, offset);
598 BUG_ON(ret && ret != -EAGAIN);
599
600 key.offset = end_byte - 1;
601 } else {
602 ret = truncate_one_csum(trans, root, path,
603 &key, bytenr, len);
604 BUG_ON(ret);
Chris Masondcbdd4d2008-12-16 13:51:01 -0500605 if (key.offset < bytenr)
606 break;
Chris Mason459931e2008-12-10 09:10:46 -0500607 }
608 btrfs_release_path(root, path);
609 }
610out:
611 btrfs_free_path(path);
612 return 0;
613}
614
Chris Mason065631f2008-02-20 12:07:25 -0500615int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
Chris Masond20f7042008-12-08 16:58:54 -0500616 struct btrfs_root *root,
Chris Masone6dcd2d2008-07-17 12:53:50 -0400617 struct btrfs_ordered_sum *sums)
Chris Masonf254e522007-03-29 15:15:27 -0400618{
Chris Masond20f7042008-12-08 16:58:54 -0500619 u64 bytenr;
Chris Masonf254e522007-03-29 15:15:27 -0400620 int ret;
621 struct btrfs_key file_key;
Chris Mason6567e832007-04-16 09:22:45 -0400622 struct btrfs_key found_key;
Chris Mason065631f2008-02-20 12:07:25 -0500623 u64 next_offset;
Chris Masone6dcd2d2008-07-17 12:53:50 -0400624 u64 total_bytes = 0;
Chris Mason065631f2008-02-20 12:07:25 -0500625 int found_next;
Chris Mason5caf2a02007-04-02 11:20:42 -0400626 struct btrfs_path *path;
Chris Masonf254e522007-03-29 15:15:27 -0400627 struct btrfs_csum_item *item;
Chris Mason065631f2008-02-20 12:07:25 -0500628 struct btrfs_csum_item *item_end;
Chris Masonff79f812007-10-15 16:22:25 -0400629 struct extent_buffer *leaf = NULL;
Chris Mason6567e832007-04-16 09:22:45 -0400630 u64 csum_offset;
Chris Masone6dcd2d2008-07-17 12:53:50 -0400631 struct btrfs_sector_sum *sector_sum;
Chris Masonf578d4b2007-10-25 15:42:56 -0400632 u32 nritems;
633 u32 ins_size;
Chris Mason6e92f5e2008-02-20 12:07:25 -0500634 char *eb_map;
635 char *eb_token;
636 unsigned long map_len;
637 unsigned long map_start;
Josef Bacik607d4322008-12-02 07:17:45 -0500638 u16 csum_size =
639 btrfs_super_csum_size(&root->fs_info->super_copy);
Chris Mason6e92f5e2008-02-20 12:07:25 -0500640
Chris Mason5caf2a02007-04-02 11:20:42 -0400641 path = btrfs_alloc_path();
642 BUG_ON(!path);
Chris Masoned98b562008-07-22 23:06:42 -0400643 sector_sum = sums->sums;
Chris Mason065631f2008-02-20 12:07:25 -0500644again:
645 next_offset = (u64)-1;
646 found_next = 0;
Chris Masond20f7042008-12-08 16:58:54 -0500647 file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
648 file_key.offset = sector_sum->bytenr;
649 bytenr = sector_sum->bytenr;
650 btrfs_set_key_type(&file_key, BTRFS_EXTENT_CSUM_KEY);
Chris Masona429e512007-04-18 16:15:28 -0400651
Chris Masond20f7042008-12-08 16:58:54 -0500652 item = btrfs_lookup_csum(trans, root, path, sector_sum->bytenr, 1);
Chris Masonff79f812007-10-15 16:22:25 -0400653 if (!IS_ERR(item)) {
654 leaf = path->nodes[0];
Chris Mason639cb582008-08-28 06:15:25 -0400655 ret = 0;
Chris Masona429e512007-04-18 16:15:28 -0400656 goto found;
Chris Masonff79f812007-10-15 16:22:25 -0400657 }
Chris Masona429e512007-04-18 16:15:28 -0400658 ret = PTR_ERR(item);
659 if (ret == -EFBIG) {
660 u32 item_size;
661 /* we found one, but it isn't big enough yet */
Chris Mason5f39d392007-10-15 16:14:19 -0400662 leaf = path->nodes[0];
663 item_size = btrfs_item_size_nr(leaf, path->slots[0]);
Josef Bacik607d4322008-12-02 07:17:45 -0500664 if ((item_size / csum_size) >=
665 MAX_CSUM_ITEMS(root, csum_size)) {
Chris Masona429e512007-04-18 16:15:28 -0400666 /* already at max size, make a new one */
667 goto insert;
668 }
669 } else {
Chris Masonf578d4b2007-10-25 15:42:56 -0400670 int slot = path->slots[0] + 1;
Chris Masona429e512007-04-18 16:15:28 -0400671 /* we didn't find a csum item, insert one */
Chris Masonf578d4b2007-10-25 15:42:56 -0400672 nritems = btrfs_header_nritems(path->nodes[0]);
673 if (path->slots[0] >= nritems - 1) {
674 ret = btrfs_next_leaf(root, path);
Yanb56baf52007-10-29 12:01:05 -0400675 if (ret == 1)
Chris Masonf578d4b2007-10-25 15:42:56 -0400676 found_next = 1;
Yanb56baf52007-10-29 12:01:05 -0400677 if (ret != 0)
Chris Masonf578d4b2007-10-25 15:42:56 -0400678 goto insert;
Yanb56baf52007-10-29 12:01:05 -0400679 slot = 0;
Chris Masonf578d4b2007-10-25 15:42:56 -0400680 }
681 btrfs_item_key_to_cpu(path->nodes[0], &found_key, slot);
Chris Masond20f7042008-12-08 16:58:54 -0500682 if (found_key.objectid != BTRFS_EXTENT_CSUM_OBJECTID ||
683 found_key.type != BTRFS_EXTENT_CSUM_KEY) {
Chris Masonf578d4b2007-10-25 15:42:56 -0400684 found_next = 1;
685 goto insert;
686 }
687 next_offset = found_key.offset;
688 found_next = 1;
Chris Masona429e512007-04-18 16:15:28 -0400689 goto insert;
690 }
691
692 /*
693 * at this point, we know the tree has an item, but it isn't big
694 * enough yet to put our csum in. Grow it
695 */
696 btrfs_release_path(root, path);
Chris Mason6567e832007-04-16 09:22:45 -0400697 ret = btrfs_search_slot(trans, root, &file_key, path,
Josef Bacik607d4322008-12-02 07:17:45 -0500698 csum_size, 1);
Chris Mason6567e832007-04-16 09:22:45 -0400699 if (ret < 0)
Chris Mason53863232008-08-15 15:34:18 -0400700 goto fail_unlock;
Chris Mason459931e2008-12-10 09:10:46 -0500701
702 if (ret > 0) {
703 if (path->slots[0] == 0)
704 goto insert;
705 path->slots[0]--;
Chris Mason6567e832007-04-16 09:22:45 -0400706 }
Chris Mason459931e2008-12-10 09:10:46 -0500707
Chris Mason5f39d392007-10-15 16:14:19 -0400708 leaf = path->nodes[0];
709 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
Chris Masond20f7042008-12-08 16:58:54 -0500710 csum_offset = (bytenr - found_key.offset) >>
Chris Mason6567e832007-04-16 09:22:45 -0400711 root->fs_info->sb->s_blocksize_bits;
Chris Mason459931e2008-12-10 09:10:46 -0500712
Chris Masond20f7042008-12-08 16:58:54 -0500713 if (btrfs_key_type(&found_key) != BTRFS_EXTENT_CSUM_KEY ||
714 found_key.objectid != BTRFS_EXTENT_CSUM_OBJECTID ||
Josef Bacik607d4322008-12-02 07:17:45 -0500715 csum_offset >= MAX_CSUM_ITEMS(root, csum_size)) {
Chris Mason6567e832007-04-16 09:22:45 -0400716 goto insert;
717 }
Chris Mason459931e2008-12-10 09:10:46 -0500718
Chris Mason5f39d392007-10-15 16:14:19 -0400719 if (csum_offset >= btrfs_item_size_nr(leaf, path->slots[0]) /
Josef Bacik607d4322008-12-02 07:17:45 -0500720 csum_size) {
721 u32 diff = (csum_offset + 1) * csum_size;
Chris Mason459931e2008-12-10 09:10:46 -0500722
723 /*
724 * is the item big enough already? we dropped our lock
725 * before and need to recheck
726 */
727 if (diff < btrfs_item_size_nr(leaf, path->slots[0]))
728 goto csum;
729
Chris Mason5f39d392007-10-15 16:14:19 -0400730 diff = diff - btrfs_item_size_nr(leaf, path->slots[0]);
Chris Masond3977122009-01-05 21:25:51 -0500731 if (diff != csum_size)
Chris Mason3a686372007-05-24 13:35:57 -0400732 goto insert;
Chris Mason459931e2008-12-10 09:10:46 -0500733
Chris Masona429e512007-04-18 16:15:28 -0400734 ret = btrfs_extend_item(trans, root, path, diff);
Chris Mason6567e832007-04-16 09:22:45 -0400735 BUG_ON(ret);
736 goto csum;
737 }
738
739insert:
Chris Masona429e512007-04-18 16:15:28 -0400740 btrfs_release_path(root, path);
Chris Mason6567e832007-04-16 09:22:45 -0400741 csum_offset = 0;
Chris Masonf578d4b2007-10-25 15:42:56 -0400742 if (found_next) {
Chris Masond20f7042008-12-08 16:58:54 -0500743 u64 tmp = total_bytes + root->sectorsize;
744 u64 next_sector = sector_sum->bytenr;
745 struct btrfs_sector_sum *next = sector_sum + 1;
746
Chris Masond3977122009-01-05 21:25:51 -0500747 while (tmp < sums->len) {
Chris Masond20f7042008-12-08 16:58:54 -0500748 if (next_sector + root->sectorsize != next->bytenr)
749 break;
750 tmp += root->sectorsize;
751 next_sector = next->bytenr;
752 next++;
753 }
754 tmp = min(tmp, next_offset - file_key.offset);
Chris Masonf578d4b2007-10-25 15:42:56 -0400755 tmp >>= root->fs_info->sb->s_blocksize_bits;
756 tmp = max((u64)1, tmp);
Josef Bacik607d4322008-12-02 07:17:45 -0500757 tmp = min(tmp, (u64)MAX_CSUM_ITEMS(root, csum_size));
758 ins_size = csum_size * tmp;
Chris Masonf578d4b2007-10-25 15:42:56 -0400759 } else {
Josef Bacik607d4322008-12-02 07:17:45 -0500760 ins_size = csum_size;
Chris Masonf578d4b2007-10-25 15:42:56 -0400761 }
Chris Masonb9473432009-03-13 11:00:37 -0400762 path->leave_spinning = 1;
Chris Mason5caf2a02007-04-02 11:20:42 -0400763 ret = btrfs_insert_empty_item(trans, root, path, &file_key,
Chris Masonf578d4b2007-10-25 15:42:56 -0400764 ins_size);
Chris Masonb9473432009-03-13 11:00:37 -0400765 path->leave_spinning = 0;
Chris Mason54aa1f42007-06-22 14:16:25 -0400766 if (ret < 0)
Chris Mason53863232008-08-15 15:34:18 -0400767 goto fail_unlock;
Chris Masona429e512007-04-18 16:15:28 -0400768 if (ret != 0) {
Chris Masona429e512007-04-18 16:15:28 -0400769 WARN_ON(1);
Chris Mason53863232008-08-15 15:34:18 -0400770 goto fail_unlock;
Chris Masona429e512007-04-18 16:15:28 -0400771 }
Chris Mason6567e832007-04-16 09:22:45 -0400772csum:
Chris Mason5f39d392007-10-15 16:14:19 -0400773 leaf = path->nodes[0];
774 item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item);
Chris Masonf254e522007-03-29 15:15:27 -0400775 ret = 0;
Chris Mason509659c2007-05-10 12:36:17 -0400776 item = (struct btrfs_csum_item *)((unsigned char *)item +
Josef Bacik607d4322008-12-02 07:17:45 -0500777 csum_offset * csum_size);
Chris Masonb18c6682007-04-17 13:26:50 -0400778found:
Chris Mason065631f2008-02-20 12:07:25 -0500779 item_end = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item);
780 item_end = (struct btrfs_csum_item *)((unsigned char *)item_end +
781 btrfs_item_size_nr(leaf, path->slots[0]));
Chris Mason6e92f5e2008-02-20 12:07:25 -0500782 eb_token = NULL;
Chris Masone6dcd2d2008-07-17 12:53:50 -0400783next_sector:
Chris Masonaadfeb62008-01-29 09:10:27 -0500784
Chris Mason6e92f5e2008-02-20 12:07:25 -0500785 if (!eb_token ||
Josef Bacik607d4322008-12-02 07:17:45 -0500786 (unsigned long)item + csum_size >= map_start + map_len) {
Chris Mason6e92f5e2008-02-20 12:07:25 -0500787 int err;
788
789 if (eb_token)
Chris Masoneb209782008-02-21 09:30:08 -0500790 unmap_extent_buffer(leaf, eb_token, KM_USER1);
Chris Mason6e92f5e2008-02-20 12:07:25 -0500791 eb_token = NULL;
792 err = map_private_extent_buffer(leaf, (unsigned long)item,
Josef Bacik607d4322008-12-02 07:17:45 -0500793 csum_size,
Chris Mason6e92f5e2008-02-20 12:07:25 -0500794 &eb_token, &eb_map,
Chris Masoneb209782008-02-21 09:30:08 -0500795 &map_start, &map_len, KM_USER1);
Chris Mason6e92f5e2008-02-20 12:07:25 -0500796 if (err)
797 eb_token = NULL;
798 }
799 if (eb_token) {
800 memcpy(eb_token + ((unsigned long)item & (PAGE_CACHE_SIZE - 1)),
Josef Bacik607d4322008-12-02 07:17:45 -0500801 &sector_sum->sum, csum_size);
Chris Mason6e92f5e2008-02-20 12:07:25 -0500802 } else {
Chris Masone6dcd2d2008-07-17 12:53:50 -0400803 write_extent_buffer(leaf, &sector_sum->sum,
Josef Bacik607d4322008-12-02 07:17:45 -0500804 (unsigned long)item, csum_size);
Chris Mason6e92f5e2008-02-20 12:07:25 -0500805 }
Chris Mason7f3c74f2008-07-18 12:01:11 -0400806
Chris Masone6dcd2d2008-07-17 12:53:50 -0400807 total_bytes += root->sectorsize;
808 sector_sum++;
809 if (total_bytes < sums->len) {
Chris Mason6e92f5e2008-02-20 12:07:25 -0500810 item = (struct btrfs_csum_item *)((char *)item +
Josef Bacik607d4322008-12-02 07:17:45 -0500811 csum_size);
Chris Masond20f7042008-12-08 16:58:54 -0500812 if (item < item_end && bytenr + PAGE_CACHE_SIZE ==
813 sector_sum->bytenr) {
814 bytenr = sector_sum->bytenr;
Chris Masone6dcd2d2008-07-17 12:53:50 -0400815 goto next_sector;
Chris Mason2e1a9922008-02-20 15:44:32 -0500816 }
Chris Mason065631f2008-02-20 12:07:25 -0500817 }
Chris Mason6e92f5e2008-02-20 12:07:25 -0500818 if (eb_token) {
Chris Masoneb209782008-02-21 09:30:08 -0500819 unmap_extent_buffer(leaf, eb_token, KM_USER1);
Chris Mason6e92f5e2008-02-20 12:07:25 -0500820 eb_token = NULL;
821 }
Chris Mason5caf2a02007-04-02 11:20:42 -0400822 btrfs_mark_buffer_dirty(path->nodes[0]);
Chris Masone6dcd2d2008-07-17 12:53:50 -0400823 if (total_bytes < sums->len) {
Chris Mason065631f2008-02-20 12:07:25 -0500824 btrfs_release_path(root, path);
Chris Masonb9473432009-03-13 11:00:37 -0400825 cond_resched();
Chris Mason065631f2008-02-20 12:07:25 -0500826 goto again;
827 }
Chris Mason53863232008-08-15 15:34:18 -0400828out:
Chris Mason5caf2a02007-04-02 11:20:42 -0400829 btrfs_free_path(path);
Chris Masonf254e522007-03-29 15:15:27 -0400830 return ret;
Chris Mason53863232008-08-15 15:34:18 -0400831
832fail_unlock:
Chris Mason53863232008-08-15 15:34:18 -0400833 goto out;
Chris Masonf254e522007-03-29 15:15:27 -0400834}