Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 346731
b: refs/heads/master
c: 7426cc0
h: refs/heads/master
i:
  346729: 70e8104
  346727: 65caced
v: v3
  • Loading branch information
Miao Xie authored and Chris Mason committed Dec 17, 2012
1 parent 94a19a2 commit a557920
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 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: 0061280d2c7240805cfd7b1f493da967c97c2f34
refs/heads/master: 7426cc04d407621773af3a0403e57642e40c36bf
22 changes: 12 additions & 10 deletions trunk/fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1873,26 +1873,28 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
btrfs_wait_ordered_range(inode, offset, len);

mutex_lock(&inode->i_mutex);
if (offset >= inode->i_size) {
mutex_unlock(&inode->i_mutex);
return 0;
}

/*
* We needn't truncate any page which is beyond the end of the file
* because we are sure there is no data there.
*/
/*
* Only do this if we are in the same page and we aren't doing the
* entire page.
*/
if (same_page && len < PAGE_CACHE_SIZE) {
ret = btrfs_truncate_page(inode, offset, len, 0);
if (offset < round_up(inode->i_size, PAGE_CACHE_SIZE))
ret = btrfs_truncate_page(inode, offset, len, 0);
mutex_unlock(&inode->i_mutex);
return ret;
}

/* zero back part of the first page */
ret = btrfs_truncate_page(inode, offset, 0, 0);
if (ret) {
mutex_unlock(&inode->i_mutex);
return ret;
if (offset < round_up(inode->i_size, PAGE_CACHE_SIZE)) {
ret = btrfs_truncate_page(inode, offset, 0, 0);
if (ret) {
mutex_unlock(&inode->i_mutex);
return ret;
}
}

/* zero the front end of the last page */
Expand Down

0 comments on commit a557920

Please sign in to comment.