All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: linux-btrfs@vger.kernel.org
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Josef Bacik <josef@toxicpanda.com>,
	Naohiro Aota <Naohiro.Aota@wdc.com>
Subject: [PATCH v4 7/9] btrfs: zoned: allow zoned RAID
Date: Wed,  7 Dec 2022 06:22:16 -0800	[thread overview]
Message-ID: <54ae9043ea789786b636886aa29dee10f504514f.1670422590.git.johannes.thumshirn@wdc.com> (raw)
In-Reply-To: <cover.1670422590.git.johannes.thumshirn@wdc.com>

When we have a raid-stripe-tree, we can do RAID0/1/10 on zoned devices for
data block-groups. For meta-data block-groups, we don't actually need
anything special, as all meta-data I/O is protected by the
btrfs_zoned_meta_io_lock() already.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/raid-stripe-tree.h |  6 ++++++
 fs/btrfs/volumes.c          |  2 ++
 fs/btrfs/zoned.c            | 39 +++++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+)

diff --git a/fs/btrfs/raid-stripe-tree.h b/fs/btrfs/raid-stripe-tree.h
index d227299e8865..73167c775f66 100644
--- a/fs/btrfs/raid-stripe-tree.h
+++ b/fs/btrfs/raid-stripe-tree.h
@@ -52,6 +52,12 @@ static inline bool btrfs_need_stripe_tree_update(struct btrfs_fs_info *fs_info,
 	if (profile & BTRFS_BLOCK_GROUP_RAID1_MASK)
 		return true;
 
+	if (profile & BTRFS_BLOCK_GROUP_RAID0)
+		return true;
+
+	if (profile & BTRFS_BLOCK_GROUP_RAID10)
+		return true;
+
 	return false;
 }
 
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index be4f5075214c..385dcf8b2cc4 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6495,6 +6495,8 @@ int __btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
 	 * I/O context structure.
 	 */
 	if (smap && num_alloc_stripes == 1 &&
+	    !(btrfs_need_stripe_tree_update(fs_info, map->type) &&
+	      op != BTRFS_MAP_READ) &&
 	    !((map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) && mirror_num > 1) &&
 	    (!need_full_stripe(op) || !dev_replace_is_ongoing ||
 	     !dev_replace->tgtdev)) {
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index e5a083a9fd0f..d05b1180580d 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1510,8 +1510,47 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
 		cache->zone_capacity = min(caps[0], caps[1]);
 		break;
 	case BTRFS_BLOCK_GROUP_RAID1:
+	case BTRFS_BLOCK_GROUP_RAID1C3:
+	case BTRFS_BLOCK_GROUP_RAID1C4:
 	case BTRFS_BLOCK_GROUP_RAID0:
 	case BTRFS_BLOCK_GROUP_RAID10:
+		if (map->type & BTRFS_BLOCK_GROUP_DATA &&
+		    !btrfs_stripe_tree_root(fs_info)) {
+			btrfs_err(fs_info,
+				  "zoned: data RAID1 needs stripe_root");
+			ret = -EIO;
+			goto out;
+
+		}
+
+		for (i = 0; i < map->num_stripes; i++) {
+			if (alloc_offsets[i] == WP_MISSING_DEV ||
+			    alloc_offsets[i] == WP_CONVENTIONAL)
+				continue;
+
+			if (i == 0)
+				continue;
+
+			if (alloc_offsets[0] != alloc_offsets[i]) {
+				btrfs_err(fs_info,
+					  "zoned: write pointer offset mismatch of zones in RAID profile");
+				ret = -EIO;
+				goto out;
+			}
+			if (test_bit(0, active) != test_bit(i, active)) {
+				if (!btrfs_zone_activate(cache)) {
+					ret = -EIO;
+					goto out;
+				}
+			} else {
+				if (test_bit(0, active))
+					set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE,
+						&cache->runtime_flags);
+			}
+			cache->zone_capacity = min(caps[0], caps[i]);
+		}
+		cache->alloc_offset = alloc_offsets[0];
+		break;
 	case BTRFS_BLOCK_GROUP_RAID5:
 	case BTRFS_BLOCK_GROUP_RAID6:
 		/* non-single profiles are not supported yet */
-- 
2.38.1


  parent reply	other threads:[~2022-12-07 14:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 14:22 [PATCH v4 0/9] btrfs: introduce RAID stripe tree Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 1/9] btrfs: add raid stripe tree definitions Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 2/9] btrfs: read raid-stripe-tree from disk Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 3/9] btrfs: add support for inserting raid stripe extents Johannes Thumshirn
2022-12-12  7:22   ` Christoph Hellwig
2022-12-13  8:15     ` Johannes Thumshirn
2022-12-13  8:36       ` hch
2022-12-13  8:47         ` Johannes Thumshirn
2022-12-13  8:54           ` hch
2022-12-13  9:01             ` Johannes Thumshirn
2022-12-12 19:27   ` Josef Bacik
2022-12-13  8:17     ` Johannes Thumshirn
2022-12-13 16:14   ` Josef Bacik
2022-12-13 17:48     ` Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 4/9] btrfs: delete stripe extent on extent deletion Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 5/9] btrfs: lookup physical address from stripe extent Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 6/9] btrfs: add raid stripe tree pretty printer Johannes Thumshirn
2022-12-07 14:22 ` Johannes Thumshirn [this message]
2022-12-07 14:22 ` [PATCH v4 8/9] btrfs: check for leaks of ordered stripes on umount Johannes Thumshirn
2022-12-07 14:22 ` [PATCH v4 9/9] btrfs: add tracepoints for ordered stripes Johannes Thumshirn

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=54ae9043ea789786b636886aa29dee10f504514f.1670422590.git.johannes.thumshirn@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=Naohiro.Aota@wdc.com \
    --cc=josef@toxicpanda.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.