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 18/22] btrfs: add ALLOC_CHUNK_FORCE to the flushing code
Date: Thu, 19 Jul 2018 10:50:02 -0400	[thread overview]
Message-ID: <20180719145006.17532-18-josef@toxicpanda.com> (raw)
In-Reply-To: <20180719145006.17532-1-josef@toxicpanda.com>

With my change to no longer take into account the global reserve for
metadata allocation chunks we have this side-effect for mixed block
group fs'es where we are no longer allocating enough chunks for the
data/metadata requirements.  To deal with this add a ALLOC_CHUNK_FORCE
step to the flushing state machine.  This will only get used if we've
already made a full loop through the flushing machinery and tried
committing the transaction.  If we have then we can try and force a
chunk allocation since we likely need it to make progress.  This
resolves the issues I was seeing with the mixed bg tests in xfstests
with my previous patch.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/ctree.h             | 3 ++-
 fs/btrfs/extent-tree.c       | 7 ++++++-
 include/trace/events/btrfs.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b33f851fb97d..95f841d8b27c 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2756,7 +2756,8 @@ enum btrfs_flush_state {
 	FLUSH_DELALLOC		=	5,
 	FLUSH_DELALLOC_WAIT	=	6,
 	ALLOC_CHUNK		=	7,
-	COMMIT_TRANS		=	8,
+	ALLOC_CHUNK_FORCE	=	8,
+	COMMIT_TRANS		=	9,
 };
 
 int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 66b28b29839b..626fb6a92dda 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5004,6 +5004,7 @@ static void flush_space(struct btrfs_fs_info *fs_info,
 		btrfs_end_transaction(trans);
 		break;
 	case ALLOC_CHUNK:
+	case ALLOC_CHUNK_FORCE:
 		trans = btrfs_join_transaction(root);
 		if (IS_ERR(trans)) {
 			ret = PTR_ERR(trans);
@@ -5011,7 +5012,9 @@ static void flush_space(struct btrfs_fs_info *fs_info,
 		}
 		ret = do_chunk_alloc(trans, fs_info,
 				     btrfs_metadata_alloc_profile(fs_info),
-				     CHUNK_ALLOC_NO_FORCE);
+				     (state == ALLOC_CHUNK) ?
+				     CHUNK_ALLOC_NO_FORCE :
+				     CHUNK_ALLOC_FORCE);
 		btrfs_end_transaction(trans);
 		if (ret > 0 || ret == -ENOSPC)
 			ret = 0;
@@ -5164,6 +5167,8 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work)
 			}
 		}
 		spin_unlock(&space_info->lock);
+		if (flush_state == ALLOC_CHUNK_FORCE && !commit_cycles)
+			flush_state++;
 	} while (flush_state <= COMMIT_TRANS);
 }
 
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index c0c536d8848a..de38e849f963 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -1052,6 +1052,7 @@ TRACE_EVENT(btrfs_trigger_flush,
 		{ FLUSH_DELAYED_REFS_NR,	"FLUSH_DELAYED_REFS_NR"},	\
 		{ FLUSH_DELAYED_REFS,		"FLUSH_ELAYED_REFS"},		\
 		{ ALLOC_CHUNK,			"ALLOC_CHUNK"},			\
+		{ ALLOC_CHUNK_FORCE,		"ALLOC_CHUNK_FORCE"},		\
 		{ COMMIT_TRANS,			"COMMIT_TRANS"})
 
 TRACE_EVENT(btrfs_flush_space,
-- 
2.14.3


  parent reply	other threads:[~2018-07-19 15:34 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 14:49 [PATCH 01/22] btrfs: add btrfs_delete_ref_head helper Josef Bacik
2018-07-19 14:49 ` [PATCH 02/22] btrfs: add cleanup_ref_head_accounting helper Josef Bacik
2018-07-19 14:49 ` [PATCH 03/22] btrfs: use cleanup_extent_op in check_ref_cleanup Josef Bacik
2018-07-19 14:49 ` [PATCH 04/22] btrfs: only track ref_heads in delayed_ref_updates Josef Bacik
2018-07-21  8:49   ` Nikolay Borisov
2018-07-19 14:49 ` [PATCH 05/22] btrfs: introduce delayed_refs_rsv Josef Bacik
2018-07-19 14:49 ` [PATCH 06/22] btrfs: check if free bgs for commit Josef Bacik
2018-07-19 14:49 ` [PATCH 07/22] btrfs: don't leak ret from do_chunk_alloc Josef Bacik
2018-07-19 15:43   ` Nikolay Borisov
2018-07-24 11:24     ` David Sterba
2018-07-19 14:49 ` [PATCH 08/22] btrfs: dump block_rsv whe dumping space info Josef Bacik
2018-07-19 15:39   ` Nikolay Borisov
2018-07-20 11:59   ` David Sterba
2018-07-19 14:49 ` [PATCH 09/22] btrfs: release metadata before running delayed refs Josef Bacik
2018-07-19 14:49 ` [PATCH 10/22] btrfs: alloc space cache inode with GFP_NOFS Josef Bacik
2018-07-19 15:35   ` Nikolay Borisov
2018-07-19 15:44     ` David Sterba
2018-07-19 15:56       ` Josef Bacik
2018-07-19 15:55     ` Josef Bacik
2018-07-19 14:49 ` [PATCH 11/22] btrfs: fix truncate throttling Josef Bacik
2018-07-19 14:49 ` [PATCH 12/22] btrfs: don't use global rsv for chunk allocation Josef Bacik
2018-07-19 14:49 ` [PATCH 13/22] btrfs: reset max_extent_size properly Josef Bacik
2018-07-19 14:49 ` [PATCH 14/22] btrfs: don't enospc all tickets on flush failure Josef Bacik
2018-07-19 14:49 ` [PATCH 15/22] btrfs: run delayed iputs before committing Josef Bacik
2018-08-21 13:51   ` David Sterba
2018-07-19 14:50 ` [PATCH 16/22] btrfs: loop in inode_rsv_refill Josef Bacik
2018-07-19 14:50 ` [PATCH 17/22] btrfs: don't take the dio_sem in the fsync path Josef Bacik
2018-07-19 15:12   ` Filipe Manana
2018-07-19 15:21   ` Filipe Manana
2018-07-19 15:54     ` Josef Bacik
2018-07-19 15:57       ` Filipe Manana
2018-07-19 14:50 ` Josef Bacik [this message]
2018-07-19 14:50 ` [PATCH 19/22] btrfs: set max_extent_size properly Josef Bacik
2018-07-19 14:50 ` [PATCH 20/22] btrfs: don't use ctl->free_space for max_extent_size Josef Bacik
2018-07-19 14:50 ` [PATCH 21/22] btrfs: reset max_extent_size on clear in a bitmap Josef Bacik
2018-07-19 14:50 ` [PATCH 22/22] btrfs: only run delayed refs if we're committing Josef Bacik
2018-07-20  7:37   ` Nikolay Borisov
2018-07-19 16:08 ` [PATCH 01/22] btrfs: add btrfs_delete_ref_head helper David Sterba
2018-07-19 16:12   ` Josef Bacik
2018-07-19 16:36     ` David Sterba
2018-07-20 13:11 ` Nikolay Borisov
2018-07-20 14:18   ` Josef Bacik
2018-07-20 14:48 ` David Sterba
2018-07-20 16:04 ` 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=20180719145006.17532-18-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.