Blob Blame History Raw
From: Josef Bacik <josef@toxicpanda.com>
Date: Thu, 1 Aug 2019 18:19:33 -0400
Subject: btrfs: add a flush step for delayed iputs
Git-commit: 844245b4548499efad26e33e408a459b1fe3a346
Patch-mainline: v5.4-rc1
References: bsc#1165949

Delayed iputs could very well free up enough space without needing to
commit the transaction, so make this step it's own step.  This will
allow us to skip the step for evictions in a later patch.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Acked-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/ctree.h             |    3 ++-
 fs/btrfs/space-info.c        |    5 +++--
 include/trace/events/btrfs.h |    1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2549,7 +2549,8 @@ enum btrfs_flush_state {
 	FLUSH_DELALLOC_WAIT	=	6,
 	ALLOC_CHUNK		=	7,
 	ALLOC_CHUNK_FORCE	=	8,
-	COMMIT_TRANS		=	9,
+	RUN_DELAYED_IPUTS	=	9,
+	COMMIT_TRANS		=	10,
 };
 
 void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -677,7 +677,7 @@ static int flush_space(struct btrfs_fs_i
 		if (ret > 0 || ret == -ENOSPC)
 			ret = 0;
 		break;
-	case COMMIT_TRANS:
+	case RUN_DELAYED_IPUTS:
 		/*
 		 * If we have pending delayed iputs then we could free up a
 		 * bunch of pinned space, so make sure we run the iputs before
@@ -685,7 +685,8 @@ static int flush_space(struct btrfs_fs_i
 		 */
 		btrfs_run_delayed_iputs(fs_info);
 		btrfs_wait_on_delayed_iputs(fs_info);
-
+		break;
+	case COMMIT_TRANS:
 		ret = may_commit_transaction(fs_info, space_info);
 		break;
 	default:
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -1013,6 +1013,7 @@ TRACE_EVENT(btrfs_trigger_flush,
 		{ FLUSH_DELAYED_REFS,		"FLUSH_ELAYED_REFS"},		\
 		{ ALLOC_CHUNK,			"ALLOC_CHUNK"},			\
 		{ ALLOC_CHUNK_FORCE,		"ALLOC_CHUNK_FORCE"},		\
+		{ RUN_DELAYED_IPUTS,		"RUN_DELAYED_IPUTS"},		\
 		{ COMMIT_TRANS,			"COMMIT_TRANS"})
 
 TRACE_EVENT(btrfs_flush_space,