btrfs: Adjust commit-transaction condition to avoid NO_SPACE more
authorZhao Lei <zhaolei@cn.fujitsu.com>
Tue, 17 Feb 2015 09:25:51 +0000 (17:25 +0800)
committerChris Mason <clm@fb.com>
Mon, 13 Apr 2015 14:27:24 +0000 (07:27 -0700)
If we have any chance to make a successful write, we should not give up.

This patch adjust commit-transaction condition from:
  pinned >= wanted
to
  left + pinned >= wanted

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/extent-tree.c

index 7b227a65078cb93f1bfa79c45ab312bf726c7fb4..01f4db6554a12696010c1d8dbe6e6e4863546712 100644 (file)
@@ -3931,7 +3931,8 @@ alloc:
                 * don't bother committing the transaction.
                 */
                if (percpu_counter_compare(&data_sinfo->total_bytes_pinned,
-                                          bytes) < 0)
+                                          used + bytes -
+                                          data_sinfo->total_bytes) < 0)
                        have_pinned_space = 0;
                spin_unlock(&data_sinfo->lock);