On 14/04/2021 03:33, Naohiro Aota wrote:
> This commit adds zone-aware magics and probing functions for zoned btrfs.
> Superblock (and its copies) is the only data structure in btrfs with a

The superblock?

> fixed location on a device. Since we cannot overwrite in a sequential write

cannot do overwrites

> required zone, we cannot place superblock in the zone.

the superblock

> Thus, zoned btrfs use superblock log writing to update superblock on

Thus, zoned btrfs uses superblock log writing to update superblocks on

> sequential write required zones. It uses two zones as a circular buffer to
> write updated superblocks. Once the first zone is filled up, start writing
> into the second buffer. When both zones are filled up and before start

starting to write

> writing to the first zone again, it reset the first zone.
> We can determine the position of the latest superblock by reading write

reading the write pointer

> pointer information from a device. One corner case is when both zones are
> full. For this situation, we read out the last superblock of each zone and
> compare them to determine which zone is older.
> The magics can detect a superblock magic ("_BHRfs_M") at the beginning of
> zone #0 or zone #1 to see if it is zoned btrfs. When both zones are filled
> up, zoned btrfs reset the first zone to write a new superblock. If btrfs


> crash at the moment, we do not see a superblock at zone #0. Thus, we need


> to check not only zone #0 but also zone #1.
> It also supports temporary magic ("!BHRfS_M") in zone #0. The mkfs.btrfs

the temporary magic [...]. Mkfs.btrfs


> +      * Log position:
> +      *   *: Special case, no superblock is written
> +      *   0: Use write pointer of zones[0]
> +      *   1: Use write pointer of zones[1]
> +      *   C: Compare super blcoks from zones[0] and zones[1], use the latest
                        blocks ~^


> +     rep_size = sizeof(struct blk_zone_report) + sizeof(struct blk_zone) * 2;
> +     rep = malloc(rep_size);
> +     if (!rep)
> +             return -errno;
> +
> +     memset(rep, 0, rep_size);

I think Damien already pointed this out, but that's a good opportunity for 

Reviewed-by: Johannes Thumshirn <johannes.thumsh...@wdc.com>
Tested-by: Johannes Thumshirn <johannes.thumsh...@wdc.com>

Reply via email to