mbox series

[v2,0/3] implement zone-aware probing/wiping for zoned btrfs

Message ID 20210414013339.2936229-1-naohiro.aota@wdc.com (mailing list archive)
Headers show
Series implement zone-aware probing/wiping for zoned btrfs | expand

Message

Naohiro Aota April 14, 2021, 1:33 a.m. UTC
This series implements probing and wiping of the superblock of zoned btrfs.

Changes:
  - v2:
     - Fix zone alignment calculation
     - Fix the build without HAVE_LINUX_BLKZONED_H

Zoned btrfs is merged with this series:
https://lore.kernel.org/linux-btrfs/20210222160049.GR1993@twin.jikos.cz/T/

And, superblock locations are finalized with this patch:
https://lore.kernel.org/linux-btrfs/BL0PR04MB651442E6ACBF48342BD00FEBE7719@BL0PR04MB6514.namprd04.prod.outlook.com/T/

A zoned block device consists of a number of zones. Zones are either
conventional and accepting random writes or sequential and requiring that
writes be issued in LBA order from each zone write pointer position.

Superblock (and its copies) is the only data structure in btrfs with a
fixed location on a device. Since we cannot overwrite in a sequential write
required zone, we cannot place superblock in the zone.

Thus, zoned btrfs use superblock log writing to update superblock 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
writing to the first zone again, it reset the first zone.

This series first implements zone based detection of the magic location.
Then, it adds magics for zoned btrfs and implements a probing function to
detect the latest superblock. Finally, this series also implements
zone-aware wiping by zone resetting.

Naohiro Aota (3):
  blkid: implement zone-aware probing
  blkid: add magic and probing for zoned btrfs
  blkid: support zone reset for wipefs

 configure.ac                     |   1 +
 libblkid/src/blkidP.h            |   5 +
 libblkid/src/probe.c             | 108 ++++++++++++++++--
 libblkid/src/superblocks/btrfs.c | 185 ++++++++++++++++++++++++++++++-
 4 files changed, 290 insertions(+), 9 deletions(-)

Comments

Karel Zak April 14, 2021, 2:09 p.m. UTC | #1
On Wed, Apr 14, 2021 at 10:33:36AM +0900, Naohiro Aota wrote:
> This series implements probing and wiping of the superblock of zoned btrfs.

I have no disk with zones support, but it seems scsi_debug supports
it. Do you have any step by step example how to test with btrfs? If
yes, I will add a test to our test suite.

  Karel
Damien Le Moal April 14, 2021, 10:04 p.m. UTC | #2
On 2021/04/14 23:11, Karel Zak wrote:
> On Wed, Apr 14, 2021 at 10:33:36AM +0900, Naohiro Aota wrote:
>> This series implements probing and wiping of the superblock of zoned btrfs.
> 
> I have no disk with zones support, but it seems scsi_debug supports
> it. Do you have any step by step example how to test with btrfs? If
> yes, I will add a test to our test suite.

Yes, scsi_debug does support emulating a ZBC disk. You can setup a disk like this:

modprobe scsi_debug \
	max_luns=1 \
	sector_size=4096 \
	zbc=host-managed \
	dev_size_mb=2048 \
	zone_size_mb=64 \
	zone_nr_conv=0

This will create a 2GB capacity disk with 64 MB zones.
Another solution, may be simpler, is to use null_blk. I am attaching a script
that I use to create zoned null block devices.

# nullblk-create.sh --help
Usage: nullblk-create.sh [options]
Options:
    -h | --help      : Display this help message and exit
    -v               : Be verbose (display final config)
    -cap <size (GB)> : set device capacity (default: 8)
                       For zoned devices, capacity is determined
                       with zone size and total number of zones
    -bs <size (B)>   : set sector size (default: 512)
    -m               : enable memory backing (default: false)
    -z               : create a zoned device (default: false)
    -qm <mode>       : set queue mode (default: 2)
                       0=bio, 1=rq, 2=multiqueue
    -sq <num>        : set number of submission queues
                       (default: nproc)
    -qd <depth>      : set queue depth (default: 64)
    -im <mode>       : set IRQ mode (default: 0)
                       0=none, 1=softirq, 2=timer
    -c <nsecs>       : set completion time for timer completion
                       (default: 10000 ns)
Options for zoned devices:
    -zs <size (MB)>  : set zone size (default: 8 MB)
    -zc <size (MB)>  : set zone capacity (default: zone size)
    -znc <num>       : set number of conv zones (default: 0)
    -zns <num>       : set number of swr zones (default: 8)
    -zr              : add a smaller runt swr zone (default: none)
    -zmo <num>       : set max open zones (default: no limit)
    -zma <num>       : set max active zones (default: no limit)

Something like this:

# nullblk-create.sh -m -cap 2 -z -zs 64 -znc 0
Created /dev/nullb0

Will also create a 2GB capacity disk with memory backing and 64 MB zones.

For the correct setup of the drive to test btrfs, I will let Naohiro and
Johannes comment.