aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-09-08 00:41:53 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-08 00:41:53 -0400
commiteb84d6b60491a3ca3d90d62ee5346b007770d40d (patch)
tree22aadf9ada15e1ae5ba4c400aafab6f2541996e6 /fs/btrfs/file.c
parent97a13e5289baa96eaddd06e61d277457d837af3a (diff)
parentd030671f3f261e528dc6e396a13f10859a74ae7c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d3afac292d67..36861b7a6757 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1840,7 +1840,15 @@ int btrfs_release_file(struct inode *inode, struct file *filp)
1840{ 1840{
1841 if (filp->private_data) 1841 if (filp->private_data)
1842 btrfs_ioctl_trans_end(filp); 1842 btrfs_ioctl_trans_end(filp);
1843 filemap_flush(inode->i_mapping); 1843 /*
1844 * ordered_data_close is set by settattr when we are about to truncate
1845 * a file from a non-zero size to a zero size. This tries to
1846 * flush down new bytes that may have been written if the
1847 * application were using truncate to replace a file in place.
1848 */
1849 if (test_and_clear_bit(BTRFS_INODE_ORDERED_DATA_CLOSE,
1850 &BTRFS_I(inode)->runtime_flags))
1851 filemap_flush(inode->i_mapping);
1844 return 0; 1852 return 0;
1845} 1853}
1846 1854
@@ -2088,10 +2096,9 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,
2088 goto out; 2096 goto out;
2089 } 2097 }
2090 2098
2091 if (hole_mergeable(inode, leaf, path->slots[0]+1, offset, end)) { 2099 if (hole_mergeable(inode, leaf, path->slots[0], offset, end)) {
2092 u64 num_bytes; 2100 u64 num_bytes;
2093 2101
2094 path->slots[0]++;
2095 key.offset = offset; 2102 key.offset = offset;
2096 btrfs_set_item_key_safe(root, path, &key); 2103 btrfs_set_item_key_safe(root, path, &key);
2097 fi = btrfs_item_ptr(leaf, path->slots[0], 2104 fi = btrfs_item_ptr(leaf, path->slots[0],
@@ -2216,7 +2223,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
2216 goto out_only_mutex; 2223 goto out_only_mutex;
2217 } 2224 }
2218 2225
2219 lockstart = round_up(offset , BTRFS_I(inode)->root->sectorsize); 2226 lockstart = round_up(offset, BTRFS_I(inode)->root->sectorsize);
2220 lockend = round_down(offset + len, 2227 lockend = round_down(offset + len,
2221 BTRFS_I(inode)->root->sectorsize) - 1; 2228 BTRFS_I(inode)->root->sectorsize) - 1;
2222 same_page = ((offset >> PAGE_CACHE_SHIFT) == 2229 same_page = ((offset >> PAGE_CACHE_SHIFT) ==
@@ -2277,7 +2284,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
2277 tail_start + tail_len, 0, 1); 2284 tail_start + tail_len, 0, 1);
2278 if (ret) 2285 if (ret)
2279 goto out_only_mutex; 2286 goto out_only_mutex;
2280 } 2287 }
2281 } 2288 }
2282 } 2289 }
2283 2290