Message ID | 30ac9e674289d206ec9299228d38cd7d03cd16c4.1610693037.git.naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: zoned block device support | expand |
On 1/15/21 1:53 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. > > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Ok so in emulated mode we simply won't be able to test the SB logging stuff. I think this is an OK trade-off, Reviewed-by: Josef Bacik <josef@toxicpanda.com> Thanks, Josef
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 90b8d1d5369f..49148e7a44b4 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; }
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. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- fs/btrfs/zoned.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)