Re: [PATCH v11 04/40] btrfs: change superblock location on conventional zone

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/21/20 10:48 PM, Naohiro Aota wrote:
We cannot use log-structured superblock writing in conventional zones since
there is no write pointer to determine the last written superblock
position. So, we write a superblock at a static location in a conventional
zone.

The written position is at the beginning of a zone, which is different from
an SB position of regular btrfs. This difference causes a "chicken-and-egg
problem" when supporting zoned emulation on a regular device. To know if
btrfs is (emulated) zoned btrfs, we need to load an SB and check the
feature flag. However, to load an SB, we need to know that it is zoned
btrfs to load it from a different position.

This patch moves the SB location on conventional zones so that the first SB
location will be the same as regular btrfs.

Signed-off-by: Naohiro Aota <naohiro.aota@xxxxxxx>
---
  fs/btrfs/zoned.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 90b8d1d5369f..e5619c8bcebb 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -465,7 +465,8 @@ static int sb_log_location(struct block_device *bdev, struct blk_zone *zones,
  	int ret;
if (zones[0].type == BLK_ZONE_TYPE_CONVENTIONAL) {
-		*bytenr_ret = zones[0].start << SECTOR_SHIFT;
+		*bytenr_ret = (zones[0].start << SECTOR_SHIFT) +
+			btrfs_sb_offset(0);
  		return 0;
  	}

I'm confused, we call btrfs_sb_log_location_bdev(), which does

        if (!bdev_is_zoned(bdev)) {
                *bytenr_ret = btrfs_sb_offset(mirror);
                return 0;
        }

so how does the emulation work, if we short circuit this if the block device isn't zoned? And then why does it matter where in the conventional zone that we put the super block? Can't we just emulate a conventional zone that starts at offset 0, and then the btrfs_sb_offset() will be the same as zones[0].start + btrfs_sb_offset(0)? Thanks,

Josef



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux