[PATCH 11/13] btrfs: check delayed refs while relocating

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Relocation can generate a serious amount of delayed refs, so we need to
throttle the relocation sometimes in order to keep up with the async
flusher.  We already have a mechanism to start over because of ENOSPC,
simply add delayed ref counts to the check as well.

Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
 fs/btrfs/relocation.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 45268e50cb17..e3d6ba27663e 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2797,6 +2797,16 @@ static int reserve_metadata_space(struct btrfs_trans_handle *trans,
 	int ret;
 	u64 tmp;
 
+	/*
+	 * If we're generating too many delayed refs we should bail and allow
+	 * the delayed ref throttling stuff to catch up.
+	 */
+	if (btrfs_check_space_for_delayed_refs(fs_info) ||
+	    btrfs_should_throttle_delayed_refs(fs_info,
+					       &trans->transaction->delayed_refs,
+					       true))
+		return -EAGAIN;
+
 	num_bytes = calcu_metadata_size(rc, node, 1) * 2;
 
 	trans->block_rsv = rc->block_rsv;
-- 
2.24.1




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux