Merge branch 'for-4.10/block' of git://git.kernel.dk/linux-block
[linux-2.6-block.git] / fs / btrfs / inode.c
index c8eb82a416b334ecb4ea30128bf6799570397d41..a4c879671b9db1d880eddc853520a77780e3f87a 100644 (file)
@@ -4605,8 +4605,8 @@ delete:
                        BUG_ON(ret);
                        if (btrfs_should_throttle_delayed_refs(trans, root))
                                btrfs_async_run_delayed_refs(root,
-                                                            trans->transid,
-                                       trans->delayed_ref_updates * 2, 0);
+                                       trans->delayed_ref_updates * 2,
+                                       trans->transid, 0);
                        if (be_nice) {
                                if (truncate_space_check(trans, root,
                                                         extent_num_bytes)) {
@@ -8928,9 +8928,14 @@ again:
         *    So even we call qgroup_free_data(), it won't decrease reserved
         *    space.
         * 2) Not written to disk
-        *    This means the reserved space should be freed here.
+        *    This means the reserved space should be freed here. However,
+        *    if a truncate invalidates the page (by clearing PageDirty)
+        *    and the page is accounted for while allocating extent
+        *    in btrfs_check_data_free_space() we let delayed_ref to
+        *    free the entire extent.
         */
-       btrfs_qgroup_free_data(inode, page_start, PAGE_SIZE);
+       if (PageDirty(page))
+               btrfs_qgroup_free_data(inode, page_start, PAGE_SIZE);
        if (!inode_evicting) {
                clear_extent_bit(tree, page_start, page_end,
                                 EXTENT_LOCKED | EXTENT_DIRTY |