diff mbox series

[v14,04/42] btrfs: use regular SB location on emulated zoned mode

Message ID e819daceaa2d00bc95df81a020432a746cf1c6e0.1611627788.git.naohiro.aota@wdc.com (mailing list archive)
State New
Headers show
Series btrfs: zoned block device support | expand

Commit Message

Naohiro Aota Jan. 26, 2021, 2:24 a.m. UTC
The zoned btrfs puts a superblock at the beginning of SB logging zones
if the zone is conventional. This difference causes a chicken-and-egg
problem for emulated zoned mode. Since the device is a regular
(non-zoned) device, we cannot know if the btrfs is regular or emulated
zoned while we read the superblock. But, to load proper superblock, we
need to see if it is emulated zoned or not.

We place the SBs at the same location as the regular btrfs on emulated
zoned mode to solve the problem. It is possible because it's ensured
that all the SB locations are at a conventional zone on emulated zoned
mode.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/zoned.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Anand Jain Jan. 30, 2021, 10:28 p.m. UTC | #1
On 1/26/2021 10:24 AM, Naohiro Aota wrote:
> The zoned btrfs puts a superblock at the beginning of SB logging zones
> if the zone is conventional. This difference causes a chicken-and-egg
> problem for emulated zoned mode. Since the device is a regular
> (non-zoned) device, we cannot know if the btrfs is regular or emulated
> zoned while we read the superblock. But, to load proper superblock, we
> need to see if it is emulated zoned or not.
> 
> We place the SBs at the same location as the regular btrfs on emulated
> zoned mode to solve the problem. It is possible because it's ensured
> that all the SB locations are at a conventional zone on emulated zoned
> mode.
> 
> Reviewed-by: Josef Bacik <josef@toxicpanda.com>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

  Makes sense to me.

  Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks.



> ---
>   fs/btrfs/zoned.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index bcabdb2c97f1..87172ce7173b 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -553,7 +553,13 @@ int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw,
>   	struct btrfs_zoned_device_info *zinfo = device->zone_info;
>   	u32 zone_num;
>   
> -	if (!zinfo) {
> +	/*
> +	 * With btrfs zoned mode on a non-zoned block device, use the same
> +	 * super block locations as regular btrfs. Doing so, the super
> +	 * block can always be retrieved and the zoned-mode of the volume
> +	 * detected from the super block information.
> +	 */
> +	if (!bdev_is_zoned(device->bdev)) {
>   		*bytenr_ret = btrfs_sb_offset(mirror);
>   		return 0;
>   	}
>
diff mbox series

Patch

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index bcabdb2c97f1..87172ce7173b 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -553,7 +553,13 @@  int btrfs_sb_log_location(struct btrfs_device *device, int mirror, int rw,
 	struct btrfs_zoned_device_info *zinfo = device->zone_info;
 	u32 zone_num;
 
-	if (!zinfo) {
+	/*
+	 * With btrfs zoned mode on a non-zoned block device, use the same
+	 * super block locations as regular btrfs. Doing so, the super
+	 * block can always be retrieved and the zoned-mode of the volume
+	 * detected from the super block information.
+	 */
+	if (!bdev_is_zoned(device->bdev)) {
 		*bytenr_ret = btrfs_sb_offset(mirror);
 		return 0;
 	}