linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 4/5] btrfs: refactor priority_reclaim_metadata_space
Date: Thu,  1 Aug 2019 18:19:36 -0400	[thread overview]
Message-ID: <20190801221937.22742-5-josef@toxicpanda.com> (raw)
In-Reply-To: <20190801221937.22742-1-josef@toxicpanda.com>

With the eviction flushing stuff we'll want to allow for different
states, but still work basically the same way that
priority_reclaim_metadata_space works currently.  Refactor this to take
the flushing states and size as an argument so we can use the same logic
for limit flushing and eviction flushing.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/space-info.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 71749b355136..03556e411b11 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -868,9 +868,12 @@ static const enum btrfs_flush_state priority_flush_states[] = {
 	ALLOC_CHUNK,
 };
 
-static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
-					    struct btrfs_space_info *space_info,
-					    struct reserve_ticket *ticket)
+static void
+priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
+				struct btrfs_space_info *space_info,
+				struct reserve_ticket *ticket,
+				const enum btrfs_flush_state *states,
+				int states_nr)
 {
 	u64 to_reclaim;
 	int flush_state;
@@ -887,7 +890,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
 	flush_state = 0;
 	do {
 		flush_space(fs_info, space_info, to_reclaim,
-			    priority_flush_states[flush_state]);
+			    states[flush_state]);
 		flush_state++;
 		spin_lock(&space_info->lock);
 		if (ticket->bytes == 0) {
@@ -895,7 +898,7 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info,
 			return;
 		}
 		spin_unlock(&space_info->lock);
-	} while (flush_state < ARRAY_SIZE(priority_flush_states));
+	} while (flush_state < states_nr);
 }
 
 static void wait_reserve_ticket(struct btrfs_fs_info *fs_info,
@@ -944,7 +947,9 @@ static int handle_reserve_ticket(struct btrfs_fs_info *fs_info,
 	if (flush == BTRFS_RESERVE_FLUSH_ALL)
 		wait_reserve_ticket(fs_info, space_info, ticket);
 	else
-		priority_reclaim_metadata_space(fs_info, space_info, ticket);
+		priority_reclaim_metadata_space(fs_info, space_info, ticket,
+						priority_flush_states,
+						ARRAY_SIZE(priority_flush_states));
 
 	spin_lock(&space_info->lock);
 	ret = ticket->error;
-- 
2.21.0


  parent reply	other threads:[~2019-08-01 22:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 22:19 [PATCH 0/5] Rework eviction space flushing Josef Bacik
2019-08-01 22:19 ` [PATCH 1/5] btrfs: add a flush step for delayed iputs Josef Bacik
2019-08-01 22:19 ` [PATCH 2/5] btrfs: unify error handling for ticket flushing Josef Bacik
2019-08-01 22:19 ` [PATCH 3/5] btrfs: factor out the ticket flush handling Josef Bacik
2019-08-01 22:19 ` Josef Bacik [this message]
2019-08-19 16:22   ` [PATCH 4/5] btrfs: refactor priority_reclaim_metadata_space David Sterba
2019-08-01 22:19 ` [PATCH 5/5] btrfs: introduce an evict flushing state Josef Bacik
2019-08-05 17:50 ` [PATCH 0/5] Rework eviction space flushing David Sterba
2019-08-19 16:20 ` David Sterba

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=20190801221937.22742-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).