• Naohiro Aota's avatar
    btrfs: implement log-structured superblock for ZONED mode · 12659251
    Naohiro Aota authored
    Superblock (and its copies) is the only data structure in btrfs which
    has a fixed location on a device. Since we cannot overwrite in a
    sequential write required zone, we cannot place superblock in the zone.
    One easy solution is limiting superblock and copies to be placed only in
    conventional zones.  However, this method has two downsides: one is
    reduced number of superblock copies. The location of the second copy of
    superblock is 256GB, which is in a sequential write required zone on
    typical devices in the market today.  So, the number of superblock and
    copies is limited to be two.  Second downside is that we cannot support
    devices which have no conventional zones at all.
    
    To solve these two problems, we employ superblock log writing. It uses
    two adjacent zones as a circular buffer to write updated superblocks.
    Once the first zone is filled up, start writing into the second one.
    Then, when both zones are filled up and before starting to write to the
    first zone again, it reset the first zone.
    
    We can determine the position of the latest superblock by reading write
    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 following zones are reserved as the circular buffer on ZONED btrfs.
    
    - The primary superblock: zones 0 and 1
    - The first copy: zones 16 and 17
    - The second copy: zones 1024 or zone at 256GB which is minimum, and
      next to it
    
    If these reserved zones are conventional, superblock is written fixed at
    the start of the zone without logging.
    Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    12659251
block-group.c 96.2 KB