All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH v2 03/11] btrfs: introduce a FORCE_COMMIT_TRANS flush operation
Date: Thu,  8 Oct 2020 16:48:47 -0400	[thread overview]
Message-ID: <a5a4a2dd1dbb4686175e796c9a20f9ad9cc59222.1602189832.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1602189832.git.josef@toxicpanda.com>

Sole-y for preemptive flushing, we want to be able to force the
transaction commit without any of the ambiguity of
may_commit_transaction().  This is because may_commit_transaction()
checks tickets and such, and in preemptive flushing we already know
it'll be helpful, so use this to keep the code nice and clean and
straightforward.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/ctree.h             | 1 +
 fs/btrfs/space-info.c        | 8 ++++++++
 include/trace/events/btrfs.h | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index e817b3b3483d..84c5db91dc44 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2654,6 +2654,7 @@ enum btrfs_flush_state {
 	ALLOC_CHUNK_FORCE	=	8,
 	RUN_DELAYED_IPUTS	=	9,
 	COMMIT_TRANS		=	10,
+	FORCE_COMMIT_TRANS	=	11,
 };
 
 int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 96d40f8df246..a215470c1887 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -737,6 +737,14 @@ static void flush_space(struct btrfs_fs_info *fs_info,
 	case COMMIT_TRANS:
 		ret = may_commit_transaction(fs_info, space_info);
 		break;
+	case FORCE_COMMIT_TRANS:
+		trans = btrfs_join_transaction(root);
+		if (IS_ERR(trans)) {
+			ret = PTR_ERR(trans);
+			break;
+		}
+		ret = btrfs_commit_transaction(trans);
+		break;
 	default:
 		ret = -ENOSPC;
 		break;
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index eb348656839f..0a3d35d952c4 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -99,7 +99,8 @@ struct btrfs_space_info;
 	EM( ALLOC_CHUNK,		"ALLOC_CHUNK")			\
 	EM( ALLOC_CHUNK_FORCE,		"ALLOC_CHUNK_FORCE")		\
 	EM( RUN_DELAYED_IPUTS,		"RUN_DELAYED_IPUTS")		\
-	EMe(COMMIT_TRANS,		"COMMIT_TRANS")
+	EM(COMMIT_TRANS,		"COMMIT_TRANS")			\
+	EMe(FORCE_COMMIT_TRANS,		"FORCE_COMMIT_TRANS")
 
 /*
  * First define the enums in the above macros to be exported to userspace via
-- 
2.26.2


  parent reply	other threads:[~2020-10-08 20:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08 20:48 [PATCH v2 00/11] Improve preemptive ENOSPC flushing Josef Bacik
2020-10-08 20:48 ` [PATCH v2 01/11] btrfs: add a trace point for reserve tickets Josef Bacik
2020-10-09  7:20   ` Nikolay Borisov
2020-10-08 20:48 ` [PATCH v2 02/11] btrfs: track ordered bytes instead of just dio ordered bytes Josef Bacik
2020-10-09  7:25   ` Nikolay Borisov
2020-10-08 20:48 ` Josef Bacik [this message]
2020-10-08 20:48 ` [PATCH v2 04/11] btrfs: improve preemptive background space flushing Josef Bacik
2020-10-08 20:48 ` [PATCH v2 05/11] btrfs: rename need_do_async_reclaim Josef Bacik
2020-10-08 20:48 ` [PATCH v2 06/11] btrfs: check reclaim_size in need_preemptive_reclaim Josef Bacik
2020-10-08 20:48 ` [PATCH v2 07/11] btrfs: rework btrfs_calc_reclaim_metadata_size Josef Bacik
2020-10-09  9:53   ` Nikolay Borisov
2020-10-08 20:48 ` [PATCH v2 08/11] btrfs: simplify the logic in need_preemptive_flushing Josef Bacik
2020-10-08 20:48 ` [PATCH v2 09/11] btrfs: implement space clamping for preemptive flushing Josef Bacik
2020-10-09 12:22   ` Nikolay Borisov
2020-10-08 20:48 ` [PATCH v2 10/11] btrfs: adjust the flush trace point to include the source Josef Bacik
2020-10-08 20:48 ` [PATCH v2 11/11] btrfs: add a trace class for dumping the current ENOSPC state Josef Bacik
2020-10-09  9:50   ` Nikolay Borisov
2020-10-09 10:39 ` [PATCH v2 00/11] Improve preemptive ENOSPC flushing Nikolay Borisov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5a4a2dd1dbb4686175e796c9a20f9ad9cc59222.1602189832.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.