Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 167588
b: refs/heads/master
c: 5d5e103
h: refs/heads/master
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Oct 14, 2009
1 parent c7cd307 commit 440bb65
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 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: 0eda294dfc980c1cbe4f8a0564bf543f86a01ddb
refs/heads/master: 5d5e103a70f74ae98e3965a4add1ab951d0651d1
27 changes: 24 additions & 3 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3032,12 +3032,22 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from)

if ((offset & (blocksize - 1)) == 0)
goto out;
ret = btrfs_check_data_free_space(root, inode, PAGE_CACHE_SIZE);
if (ret)
goto out;

ret = btrfs_reserve_metadata_for_delalloc(root, inode, 1);
if (ret)
goto out;

ret = -ENOMEM;
again:
page = grab_cache_page(mapping, index);
if (!page)
if (!page) {
btrfs_free_reserved_data_space(root, inode, PAGE_CACHE_SIZE);
btrfs_unreserve_metadata_for_delalloc(root, inode, 1);
goto out;
}

page_start = page_offset(page);
page_end = page_start + PAGE_CACHE_SIZE - 1;
Expand Down Expand Up @@ -3070,6 +3080,10 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from)
goto again;
}

clear_extent_bits(&BTRFS_I(inode)->io_tree, page_start, page_end,
EXTENT_DIRTY | EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING,
GFP_NOFS);

ret = btrfs_set_extent_delalloc(inode, page_start, page_end);
if (ret) {
unlock_extent(io_tree, page_start, page_end, GFP_NOFS);
Expand All @@ -3088,6 +3102,9 @@ static int btrfs_truncate_page(struct address_space *mapping, loff_t from)
unlock_extent(io_tree, page_start, page_end, GFP_NOFS);

out_unlock:
if (ret)
btrfs_free_reserved_data_space(root, inode, PAGE_CACHE_SIZE);
btrfs_unreserve_metadata_for_delalloc(root, inode, 1);
unlock_page(page);
page_cache_release(page);
out:
Expand All @@ -3111,7 +3128,9 @@ int btrfs_cont_expand(struct inode *inode, loff_t size)
if (size <= hole_start)
return 0;

btrfs_truncate_page(inode->i_mapping, inode->i_size);
err = btrfs_truncate_page(inode->i_mapping, inode->i_size);
if (err)
return err;

while (1) {
struct btrfs_ordered_extent *ordered;
Expand Down Expand Up @@ -5008,7 +5027,9 @@ static void btrfs_truncate(struct inode *inode)
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return;

btrfs_truncate_page(inode->i_mapping, inode->i_size);
ret = btrfs_truncate_page(inode->i_mapping, inode->i_size);
if (ret)
return;
btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1);

trans = btrfs_start_transaction(root, 1);
Expand Down

0 comments on commit 440bb65

Please sign in to comment.