diff mbox series

[03/13] btrfs: make btrfs_should_throttle_delayed_refs only check run time

Message ID 20200313212330.149024-4-josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Throttle delayed refs based on time | expand

Commit Message

Josef Bacik March 13, 2020, 9:23 p.m. UTC
btrfs_should_throttle_delayed_refs checks run time of the delayed refs
and if there's enough space.  However we want to use these two checks
independently in the future, so make btrfs_should_throttle_delayed_refs
only check the runtime.  Then fix the only caller of
btrfs_should_throttle_delayed_refs to check the space as well, because
we want to throttle truncates on either space or time.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/delayed-ref.c | 3 +--
 fs/btrfs/inode.c       | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index acad9978b927..e28565dc4288 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -64,8 +64,7 @@  bool btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans)
 		return true;
 	if (val >= NSEC_PER_SEC / 2)
 		return true;
-
-	return btrfs_check_space_for_delayed_refs(trans->fs_info);
+	return false;
 }
 
 /**
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b8dabffac767..d3e75e04a0a0 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4349,7 +4349,8 @@  int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 				break;
 			}
 			if (be_nice) {
-				if (btrfs_should_throttle_delayed_refs(trans))
+				if (btrfs_should_throttle_delayed_refs(trans) ||
+				    btrfs_check_space_for_delayed_refs(fs_info))
 					should_throttle = true;
 			}
 		}