btrfs-progs: zoned: wipe temporary superblocks in superblock log zone
mkfs.btrfs uses a temporary superblock during the initialization process. The temporary superblock uses BTRFS_MAGIC_TEMPORARY as its magic which is different from a regular superblock. As a result, libblkid, which only supports the usual magic, cannot recognize the volume as btrfs. So, let's wipe the temporary magic before writing out the usual superblock. Technically, we can add the temporary magic to the libblkid's table. But, it will result in recognizing a half-baked filesystem as btrfs, which is not ideal. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
9d42778b48
commit
8c2dfa6387
|
@ -1953,6 +1953,12 @@ int close_ctree_fs_info(struct btrfs_fs_info *fs_info)
|
|||
}
|
||||
|
||||
if (fs_info->finalize_on_close) {
|
||||
ret = btrfs_wipe_temporary_sb(fs_info->fs_devices);
|
||||
if (ret) {
|
||||
error("zoned: failed to wipe temporary super blocks: %m");
|
||||
goto skip_commit;
|
||||
}
|
||||
|
||||
btrfs_set_super_magic(fs_info->super_copy, BTRFS_MAGIC);
|
||||
root->fs_info->finalize_on_close = 0;
|
||||
ret = write_all_supers(fs_info);
|
||||
|
|
|
@ -968,6 +968,26 @@ int btrfs_reset_chunk_zones(struct btrfs_fs_info *fs_info, u64 devid,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int btrfs_wipe_temporary_sb(struct btrfs_fs_devices *fs_devices)
|
||||
{
|
||||
struct list_head *head = &fs_devices->devices;
|
||||
struct btrfs_device *dev;
|
||||
int ret = 0;
|
||||
|
||||
list_for_each_entry(dev, head, dev_list) {
|
||||
struct btrfs_zoned_device_info *zinfo = dev->zone_info;
|
||||
|
||||
if (!zinfo)
|
||||
continue;
|
||||
|
||||
ret = btrfs_reset_dev_zone(dev->fd, &zinfo->zones[0]);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info)
|
||||
|
|
|
@ -95,9 +95,9 @@ bool btrfs_redirty_extent_buffer_for_zoned(struct btrfs_fs_info *fs_info,
|
|||
int btrfs_reset_chunk_zones(struct btrfs_fs_info *fs_info, u64 devid,
|
||||
u64 offset, u64 length);
|
||||
int btrfs_reset_all_zones(int fd, struct btrfs_zoned_device_info *zinfo);
|
||||
|
||||
int zero_zone_blocks(int fd, struct btrfs_zoned_device_info *zinfo, off_t start,
|
||||
size_t len);
|
||||
int btrfs_wipe_temporary_sb(struct btrfs_fs_devices *fs_devices);
|
||||
|
||||
#else
|
||||
|
||||
|
@ -160,6 +160,11 @@ static inline int zero_zone_blocks(int fd,
|
|||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int btrfs_wipe_temporary_sb(struct btrfs_fs_devices *fs_devices)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* BTRFS_ZONED */
|
||||
|
||||
static inline bool btrfs_dev_is_sequential(struct btrfs_device *device, u64 pos)
|
||||
|
|
Loading…
Reference in New Issue