[v6,21/28] btrfs: disallow mixed-bg in HMZONED mode
diff mbox series

Message ID 20191213040915.3502922-22-naohiro.aota@wdc.com
State New
Headers show
Series
  • btrfs: zoned block device support
Related show

Commit Message

Naohiro Aota Dec. 13, 2019, 4:09 a.m. UTC
Placing both data and metadata in a block group is impossible in HMZONED
mode. For data, we can allocate a space for it and write it immediately
after the allocation. For metadata, however, we cannot do so, because the
logical addresses are recorded in other metadata buffers to build up the
trees. As a result, a data buffer can be placed after a metadata buffer,
which is not written yet. Writing out the data buffer will break the
sequential write rule.

This commit check and disallow MIXED_BG with HMZONED mode.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/hmzoned.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Josef Bacik Dec. 17, 2019, 7:56 p.m. UTC | #1
On 12/12/19 11:09 PM, Naohiro Aota wrote:
> Placing both data and metadata in a block group is impossible in HMZONED
> mode. For data, we can allocate a space for it and write it immediately
> after the allocation. For metadata, however, we cannot do so, because the
> logical addresses are recorded in other metadata buffers to build up the
> trees. As a result, a data buffer can be placed after a metadata buffer,
> which is not written yet. Writing out the data buffer will break the
> sequential write rule.
> 
> This commit check and disallow MIXED_BG with HMZONED mode.
> 
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

I would prefer it if you did all of the weird disallows early on so it's clear 
as I go through that I don't have to think about certain cases.  I remembered 
from a previous look through that mixed_bg's were disallowed, but I had to go 
look for some other cases.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef
Naohiro Aota Dec. 18, 2019, 8:03 a.m. UTC | #2
On Tue, Dec 17, 2019 at 02:56:20PM -0500, Josef Bacik wrote:
>On 12/12/19 11:09 PM, Naohiro Aota wrote:
>>Placing both data and metadata in a block group is impossible in HMZONED
>>mode. For data, we can allocate a space for it and write it immediately
>>after the allocation. For metadata, however, we cannot do so, because the
>>logical addresses are recorded in other metadata buffers to build up the
>>trees. As a result, a data buffer can be placed after a metadata buffer,
>>which is not written yet. Writing out the data buffer will break the
>>sequential write rule.
>>
>>This commit check and disallow MIXED_BG with HMZONED mode.
>>
>>Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
>
>I would prefer it if you did all of the weird disallows early on so 
>it's clear as I go through that I don't have to think about certain 
>cases.  I remembered from a previous look through that mixed_bg's were 
>disallowed, but I had to go look for some other cases.
>
>Reviewed-by: Josef Bacik <josef@toxicpanda.com>
>
>Thanks,
>
>Josef

Sure, I will sort these patches after the other disallow patches.

Thanks,

Patch
diff mbox series

diff --git a/fs/btrfs/hmzoned.c b/fs/btrfs/hmzoned.c
index 1aa4c9d1032e..c779232bb003 100644
--- a/fs/btrfs/hmzoned.c
+++ b/fs/btrfs/hmzoned.c
@@ -306,6 +306,13 @@  int btrfs_check_hmzoned_mode(struct btrfs_fs_info *fs_info)
 		goto out;
 	}
 
+	if (btrfs_fs_incompat(fs_info, MIXED_GROUPS)) {
+		btrfs_err(fs_info,
+			  "HMZONED mode is not allowed for mixed block groups");
+		ret = -EINVAL;
+		goto out;
+	}
+
 	fs_info->zone_size = zone_size;
 
 	btrfs_info(fs_info, "HMZONED mode enabled, zone size %llu B",