Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128843
b: refs/heads/master
c: 8964222
h: refs/heads/master
i:
  128841: ee79ad6
  128839: b2034a6
v: v3
  • Loading branch information
Chris Mason committed Sep 25, 2008
1 parent 6de971c commit 991c9ad
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 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: 9ba4611a3a7902c6bad70c5c205de5161fcfc17b
refs/heads/master: 89642229a582a5c2b6d2ed8ec16986387d9a9047
9 changes: 8 additions & 1 deletion trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,16 @@ void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
spin_lock(&em_tree->lock);
em = lookup_extent_mapping(em_tree, offset, PAGE_CACHE_SIZE);
spin_unlock(&em_tree->lock);
if (!em)
if (!em) {
__unplug_io_fn(bdi, page);
return;
}

if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
free_extent_map(em);
__unplug_io_fn(bdi, page);
return;
}
offset = offset - em->start;
btrfs_unplug_page(&BTRFS_I(inode)->root->fs_info->mapping_tree,
em->block_start + offset, page);
Expand Down
8 changes: 4 additions & 4 deletions trunk/fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1949,18 +1949,18 @@ printk("2bad mapping end %Lu cur %Lu\n", end, cur);
cur + iosize - 1);
}
if (!ret) {
unsigned long nr = (last_byte >> PAGE_CACHE_SHIFT) + 1;
nr -= page->index;
unsigned long pnr = (last_byte >> PAGE_CACHE_SHIFT) + 1;
pnr -= page->index;
ret = submit_extent_page(READ, tree, page,
sector, iosize, page_offset,
bdev, bio, nr,
bdev, bio, pnr,
end_bio_extent_readpage, mirror_num);
nr++;
}
if (ret)
SetPageError(page);
cur = cur + iosize;
page_offset += iosize;
nr++;
}
if (!nr) {
if (!PageError(page))
Expand Down
33 changes: 18 additions & 15 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,22 +611,25 @@ int btrfs_readpage_io_hook(struct page *page, u64 start, u64 end)
btrfs_test_flag(inode, NODATASUM))
return 0;

/*
* It is possible there is an ordered extent that has
* not yet finished for this range in the file. If so,
* that extent will have a csum cached, and it will insert
* the sum after all the blocks in the extent are fully
* on disk. So, look for an ordered extent and use the
* sum if found. We have to do this before looking in the
* btree because csum items are pre-inserted based on
* the file size. btrfs_lookup_csum might find an item
* that still hasn't been fully filled.
*/
ret = btrfs_find_ordered_sum(inode, start, &csum);
if (ret == 0)
goto found;

ret = 0;
path = btrfs_alloc_path();
mutex_lock(&BTRFS_I(inode)->csum_mutex);
item = btrfs_lookup_csum(NULL, root, path, inode->i_ino, start, 0);
if (IS_ERR(item)) {
/*
* It is possible there is an ordered extent that has
* not yet finished for this range in the file. If so,
* that extent will have a csum cached, and it will insert
* the sum after all the blocks in the extent are fully
* on disk. So, look for an ordered extent and use the
* sum if found.
*/
ret = btrfs_find_ordered_sum(inode, start, &csum);
if (ret == 0)
goto found;

ret = PTR_ERR(item);
/* a csum that isn't present is a preallocated region. */
if (ret == -ENOENT || ret == -EFBIG)
Expand All @@ -641,7 +644,6 @@ int btrfs_readpage_io_hook(struct page *page, u64 start, u64 end)
found:
set_state_private(io_tree, start, csum);
out:
mutex_unlock(&BTRFS_I(inode)->csum_mutex);
if (path)
btrfs_free_path(path);
return ret;
Expand Down Expand Up @@ -1375,7 +1377,7 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from)
}
if (!PageUptodate(page)) {
ret = -EIO;
goto out;
goto out_unlock;
}
}
wait_on_page_writeback(page);
Expand Down Expand Up @@ -1406,6 +1408,7 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from)
set_page_dirty(page);
unlock_extent(io_tree, page_start, page_end, GFP_NOFS);

out_unlock:
unlock_page(page);
page_cache_release(page);
out:
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/btrfs/ordered-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u32 *sum)
}
out:
mutex_unlock(&tree->mutex);
btrfs_put_ordered_extent(ordered);
return ret;
}

Expand Down

0 comments on commit 991c9ad

Please sign in to comment.