From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 1/3] btrfs: check rw_devices, not num_devices for restriping
Date: Fri, 17 Jan 2020 09:07:37 -0500 [thread overview]
Message-ID: <20200117140739.42560-2-josef@toxicpanda.com> (raw)
In-Reply-To: <20200117140739.42560-1-josef@toxicpanda.com>
While running xfstests with compression on I noticed I was panicing on
btrfs/154. I bisected this down to my inc_block_group_ro patches, which
was strange.
What was happening is with my patches we now use btrfs_can_overcommit()
to see if we can flip a block group read only. Before this would fail
because we weren't taking into account the usable un-allocated space for
allocating chunks. With my patches we were allowed to do the balance,
which is technically correct.
However this test is testing restriping with a degraded mount, something
that isn't working right because Anand's fix for the test was never
actually merged.
So now we're trying to allocate a chunk and cannot because we want to
allocate a RAID1 chunk, but there's only 1 device that's available for
usage. This results in an ENOSPC in one of the BUG_ON(ret) paths in
relocation (and a tricky path that is going to take many more patches to
fix.)
But we shouldn't even be making it this far, we don't have enough
devices to restripe. The problem is we're using btrfs_num_devices(),
which for some reason includes missing devices. That's not actually
what we want, we want the rw_devices.
Fix this by getting the rw_devices. With this patch we're no longer
panicing with my other patches applied, and we're in fact erroring out
at the correct spot instead of at inc_block_group_ro. The fact that
this was working before was just sheer dumb luck.
Fixes: e4d8ec0f65b9 ("Btrfs: implement online profile changing")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/volumes.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c72fd33a9ce1..035578e061fb 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3884,7 +3884,14 @@ int btrfs_balance(struct btrfs_fs_info *fs_info,
}
}
- num_devices = btrfs_num_devices(fs_info);
+ /*
+ * Balance is an exculsive operation, so no operation that's going to
+ * affect rw_devices can run concurrent with it, thus it is safe to
+ * simply grab the value. We want rw_devices because we do not want to
+ * allow restriping if we don't have enough devices we can actually
+ * allocate from.
+ */
+ num_devices = fs_info->fs_devices->rw_devices;
/*
* SINGLE profile on-disk has no profile bit, but in-memory we have a
--
2.24.1
next prev parent reply other threads:[~2020-01-17 14:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 14:07 [PATCH 0/3][v2] clean up how we mark block groups read only Josef Bacik
2020-01-17 14:07 ` Josef Bacik [this message]
2020-01-17 14:07 ` [PATCH 2/3] btrfs: fix force usage in inc_block_group_ro Josef Bacik
2020-01-17 14:07 ` [PATCH 3/3] btrfs: use btrfs_can_overcommit " Josef Bacik
2020-01-29 6:05 ` [PATCH 0/3][v2] clean up how we mark block groups read only Qu Wenruo
2020-01-29 13:45 ` 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=20200117140739.42560-2-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