Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 346730
b: refs/heads/master
c: 0061280
h: refs/heads/master
v: v3
  • Loading branch information
Miao Xie authored and Chris Mason committed Dec 17, 2012
1 parent 70e8104 commit 94a19a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 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: 6347b3c433a4cff00eb2299c7f2c7d1d8b24c1fc
refs/heads/master: 0061280d2c7240805cfd7b1f493da967c97c2f34
16 changes: 9 additions & 7 deletions trunk/fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1859,9 +1859,9 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
struct btrfs_path *path;
struct btrfs_block_rsv *rsv;
struct btrfs_trans_handle *trans;
u64 mask = BTRFS_I(inode)->root->sectorsize - 1;
u64 lockstart = (offset + mask) & ~mask;
u64 lockend = ((offset + len) & ~mask) - 1;
u64 lockstart = round_up(offset, BTRFS_I(inode)->root->sectorsize);
u64 lockend = round_down(offset + len,
BTRFS_I(inode)->root->sectorsize) - 1;
u64 cur_offset = lockstart;
u64 min_size = btrfs_calc_trunc_metadata_size(root, 1);
u64 drop_end;
Expand Down Expand Up @@ -1896,10 +1896,12 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
}

/* zero the front end of the last page */
ret = btrfs_truncate_page(inode, offset + len, 0, 1);
if (ret) {
mutex_unlock(&inode->i_mutex);
return ret;
if (offset + len < round_up(inode->i_size, PAGE_CACHE_SIZE)) {
ret = btrfs_truncate_page(inode, offset + len, 0, 1);
if (ret) {
mutex_unlock(&inode->i_mutex);
return ret;
}
}

if (lockend < lockstart) {
Expand Down

0 comments on commit 94a19a2

Please sign in to comment.