From: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 20/20] Btrfs: don't waste metadata block groups for clustered allocation
Date: Fri, 25 Nov 2011 21:47:13 -0200 [thread overview]
Message-ID: <3e32802d2e55b6f58e1cc0b7b3f9867b2edf30f6.1322507825.git.oliva@lsd.ic.unicamp.br> (raw)
In-Reply-To: <cover.1322507825.git.oliva@lsd.ic.unicamp.br>
We try to maintain about 1% of the filesystem space in free space in
data block groups, but we need not do that for metadata, since we only
allocate one block at a time.
This patch also moves the adjustment of flags to account for mixed
data/metadata block groups into the block protected by spin lock, and
before the point in which we now look at flags to decide whether or
not we should keep the free space buffer.
Signed-off-by: Alexandre Oliva <oliva@lsd.ic.unicamp.br>
---
fs/btrfs/extent-tree.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3c649fe..cce452d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3228,7 +3228,7 @@ static void force_metadata_allocation(struct btrfs_fs_info *info)
static int should_alloc_chunk(struct btrfs_root *root,
struct btrfs_space_info *sinfo, u64 alloc_bytes,
- int force)
+ u64 flags, int force)
{
struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv;
u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly;
@@ -3246,10 +3246,10 @@ static int should_alloc_chunk(struct btrfs_root *root,
num_allocated += global_rsv->size;
/*
- * in limited mode, we want to have some free space up to
+ * in limited mode, we want to have some free data space up to
* about 1% of the FS size.
*/
- if (force == CHUNK_ALLOC_LIMITED) {
+ if (force == CHUNK_ALLOC_LIMITED && (flags & BTRFS_BLOCK_GROUP_DATA)) {
thresh = btrfs_super_total_bytes(root->fs_info->super_copy);
thresh = max_t(u64, 64 * 1024 * 1024,
div_factor_fine(thresh, 1));
@@ -3310,7 +3310,16 @@ again:
return 0;
}
- if (!should_alloc_chunk(extent_root, space_info, alloc_bytes, force)) {
+ /*
+ * If we have mixed data/metadata chunks we want to make sure we keep
+ * allocating mixed chunks instead of individual chunks.
+ */
+ if (btrfs_mixed_space_info(space_info))
+ flags |= (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA);
+
+ if (!should_alloc_chunk(extent_root, space_info, alloc_bytes,
+ flags, force)) {
+ space_info->force_alloc = CHUNK_ALLOC_NO_FORCE;
spin_unlock(&space_info->lock);
return 0;
} else if (space_info->chunk_alloc) {
@@ -3336,13 +3345,6 @@ again:
}
/*
- * If we have mixed data/metadata chunks we want to make sure we keep
- * allocating mixed chunks instead of individual chunks.
- */
- if (btrfs_mixed_space_info(space_info))
- flags |= (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA);
-
- /*
* if we're doing a data chunk, go ahead and make sure that
* we keep a reasonable number of metadata chunks allocated in the
* FS as well.
--
1.7.4.4
next prev parent reply other threads:[~2011-11-28 19:33 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-28 19:17 [PATCH 00/20] Here's my current btrfs patchset Alexandre Oliva
2011-10-14 15:10 ` [PATCH 13/20] Btrfs: revamp clustered allocation logic Alexandre Oliva
2011-10-29 4:20 ` [PATCH 17/20] Btrfs: introduce -o cluster and -o nocluster Alexandre Oliva
2011-11-08 14:25 ` [PATCH 14/20] Btrfs: introduce option to rebalance only metadata Alexandre Oliva
2011-11-08 14:33 ` [PATCH 01/20] Btrfs: enable removal of second disk with raid1 metadata Alexandre Oliva
2011-11-10 22:55 ` [PATCH 18/20] Btrfs: add -o mincluster option Alexandre Oliva
2011-11-16 3:25 ` [PATCH 10/20] Btrfs: report reason for failed relocation Alexandre Oliva
2011-11-25 23:47 ` Alexandre Oliva [this message]
2011-11-26 21:19 ` [PATCH 12/20] Btrfs: introduce verbose debug mode for patched clustered allocation recovery Alexandre Oliva
2011-11-26 23:53 ` [PATCH 05/20] Btrfs: start search for new cluster at the beginning of the block group Alexandre Oliva
2011-11-27 2:05 ` [PATCH 09/20] Btrfs: skip allocation attempt from empty cluster Alexandre Oliva
2011-11-27 22:49 ` [PATCH 16/20] Btrfs: try cluster but don't advance in search list Alexandre Oliva
2011-11-28 0:07 ` [PATCH 08/20] Btrfs: try to allocate from cluster even at LOOP_NO_EMPTY_SIZE Alexandre Oliva
2011-11-28 2:04 ` [PATCH 15/20] Btrfs: activate allocation debugging Alexandre Oliva
2011-11-28 13:52 ` [PATCH 02/20] Btrfs: initialize new bitmaps' list Alexandre Oliva
2011-11-29 21:00 ` Christian Brunner
2011-11-30 23:28 ` Alexandre Oliva
2011-12-01 14:50 ` Christian Brunner
2011-12-07 20:50 ` Christian Brunner
2011-12-09 15:17 ` Christian Brunner
2011-12-12 7:47 ` Alexandre Oliva
2011-12-12 8:05 ` Christian Brunner
2011-11-28 14:07 ` [PATCH 04/20] Btrfs: reset cluster's max_size when creating bitmap cluster Alexandre Oliva
2011-11-28 14:22 ` [PATCH 11/20] Btrfs: note when a bitmap is skipped because its list is in use Alexandre Oliva
2011-11-28 14:23 ` [PATCH 19/20] Btrfs: log when a bitmap is rejected for a cluster Alexandre Oliva
2011-11-28 14:30 ` [PATCH 06/20] Btrfs: skip block groups without enough space " Alexandre Oliva
2011-11-28 14:36 ` [PATCH 07/20] Btrfs: don't set up allocation result twice Alexandre Oliva
2011-11-28 15:41 ` [PATCH 03/20] Btrfs: fix comment typo Alexandre Oliva
2011-11-29 2:25 ` [PATCH 00/20] Here's my current btrfs patchset Li Zefan
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=3e32802d2e55b6f58e1cc0b7b3f9867b2edf30f6.1322507825.git.oliva@lsd.ic.unicamp.br \
--to=oliva@lsd.ic.unicamp.br \
--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).