aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-07-18 06:17:13 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:05 -0400
commit3edf7d33f4edb1e4a9bb0a4c0a84d95fb4d22a09 (patch)
tree8698a6dd1d0d038f1b56f79c92783518d36f2145 /fs/btrfs/ordered-data.c
parenteb84ae039e10f1f80443d846ba1350122bbdc753 (diff)
Btrfs: Handle data checksumming on bios that span multiple ordered extents
Data checksumming is done right before the bio is sent down the IO stack, which means a single bio might span more than one ordered extent. In this case, the checksumming data is split between two ordered extents. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r--fs/btrfs/ordered-data.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 230fd3ca6b2c..1ddb7bceea99 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -186,22 +186,17 @@ int btrfs_add_ordered_extent(struct inode *inode, u64 file_offset,
186 186
187/* 187/*
188 * Add a struct btrfs_ordered_sum into the list of checksums to be inserted 188 * Add a struct btrfs_ordered_sum into the list of checksums to be inserted
189 * when an ordered extent is finished. 189 * when an ordered extent is finished. If the list covers more than one
190 * ordered extent, it is split across multiples.
190 */ 191 */
191int btrfs_add_ordered_sum(struct inode *inode, struct btrfs_ordered_sum *sum) 192int btrfs_add_ordered_sum(struct inode *inode,
193 struct btrfs_ordered_extent *entry,
194 struct btrfs_ordered_sum *sum)
192{ 195{
193 struct btrfs_ordered_inode_tree *tree; 196 struct btrfs_ordered_inode_tree *tree;
194 struct rb_node *node;
195 struct btrfs_ordered_extent *entry;
196 197
197 tree = &BTRFS_I(inode)->ordered_tree; 198 tree = &BTRFS_I(inode)->ordered_tree;
198 mutex_lock(&tree->mutex); 199 mutex_lock(&tree->mutex);
199 node = tree_search(tree, sum->file_offset);
200 BUG_ON(!node);
201
202 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node);
203 BUG_ON(!offset_in_entry(entry, sum->file_offset));
204
205 list_add_tail(&sum->list, &entry->list); 200 list_add_tail(&sum->list, &entry->list);
206 mutex_unlock(&tree->mutex); 201 mutex_unlock(&tree->mutex);
207 return 0; 202 return 0;
@@ -524,8 +519,10 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u32 *sum)
524 struct btrfs_ordered_extent *ordered; 519 struct btrfs_ordered_extent *ordered;
525 struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree; 520 struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree;
526 struct list_head *cur; 521 struct list_head *cur;
522 unsigned long num_sectors;
523 unsigned long i;
524 u32 sectorsize = BTRFS_I(inode)->root->sectorsize;
527 int ret = 1; 525 int ret = 1;
528 int index;
529 526
530 ordered = btrfs_lookup_ordered_extent(inode, offset); 527 ordered = btrfs_lookup_ordered_extent(inode, offset);
531 if (!ordered) 528 if (!ordered)
@@ -534,14 +531,17 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u32 *sum)
534 mutex_lock(&tree->mutex); 531 mutex_lock(&tree->mutex);
535 list_for_each_prev(cur, &ordered->list) { 532 list_for_each_prev(cur, &ordered->list) {
536 ordered_sum = list_entry(cur, struct btrfs_ordered_sum, list); 533 ordered_sum = list_entry(cur, struct btrfs_ordered_sum, list);
537 if (offset >= ordered_sum->file_offset && 534 if (offset >= ordered_sum->file_offset) {
538 offset < ordered_sum->file_offset + ordered_sum->len) { 535 num_sectors = ordered_sum->len / sectorsize;
539 index = (offset - ordered_sum->file_offset) /
540 BTRFS_I(inode)->root->sectorsize;;
541 sector_sums = &ordered_sum->sums; 536 sector_sums = &ordered_sum->sums;
542 *sum = sector_sums[index].sum; 537 for (i = 0; i < num_sectors; i++) {
543 ret = 0; 538 if (sector_sums[i].offset == offset) {
544 goto out; 539printk("find ordered sum inode %lu offset %Lu\n", inode->i_ino, offset);
540 *sum = sector_sums[i].sum;
541 ret = 0;
542 goto out;
543 }
544 }
545 } 545 }
546 } 546 }
547out: 547out: