@@ -4386,6 +4386,21 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
* let the normal reservation dance happen higher up.
*/
if (should_throttle) {
+ struct btrfs_transaction *cur_trans =
+ trans->transaction;
+
+ /*
+ * If we're over time, or we're flushing, go
+ * ahead and break out so that we can let
+ * everybody catch up.
+ */
+ if (btrfs_should_throttle_delayed_refs(fs_info,
+ &cur_trans->delayed_refs, true) ||
+ cur_trans->delayed_refs.flushing) {
+ ret = -EAGAIN;
+ break;
+ }
+
ret = btrfs_delayed_refs_rsv_refill(fs_info,
BTRFS_RESERVE_NO_FLUSH);
if (ret) {
Truncates can generate a lot of delayed refs, and if we're over our time limit or we're already flushing we should just bail so the appropriate action can be taken. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/inode.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)