btrfs-progs/mkfs
Li Zhang bb2eed3aa5 btrfs-progs: mkfs: run device preparation in parallel
When devices are formatted as btrfs, btrfs_prepare_device is called
sequentially for each device, which takes too much time.

Put each btrfs_prepare_device into a thread, wait for the first thread
to complete to mkfs.btrfs, and wait for other threads to complete before
adding other devices to the file system.

During the preparation it's either trim/discard or zone reset.

This was tested with TCMU emulation with two zoned devices.  Each device
is 2000G (about 19.53 TiB), the region size is 4MB, Use the following
parameters for targetcli:

  create name=zbc0 size=20000G cfgstring=model-HM/zsize-4/conv-100@~/zbc0.raw

Call difftime to calculate the running time of the function
btrfs_prepare_device.  Calculate the time from thread creation to
completion of all threads after patching:

  $ lsscsi -p
  [10:0:1:0]   (0x14)  LIO-ORG  TCMU ZBC device  0002  /dev/sdb   -          none
  [11:0:1:0]   (0x14)  LIO-ORG  TCMU ZBC device  0002  /dev/sdc   -          none

  $ sudo mkfs.btrfs -d single -m single -O zoned /dev/sdc /dev/sdb -f
  ....
  time for prepare devices:4.000000.
  ....

  $ sudo mkfs.btrfs -d single -m single -O zoned /dev/sdc /dev/sdb -f
  ...
  time for prepare devices:2.000000.
  ...

Issue: #496
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Li Zhang <zhanglikernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:08 +02:00
..
common.c btrfs-progs: mkfs: use message helpers for error messages 2022-10-11 09:08:07 +02:00
common.h btrfs-progs: mkfs: update include lists 2022-10-11 09:06:12 +02:00
main.c btrfs-progs: mkfs: run device preparation in parallel 2022-10-11 09:08:08 +02:00
Makefile btrfs-progs: build: add stub makefile to image and mkfs 2019-07-04 15:36:01 +02:00
rootdir.c btrfs-progs: mkfs: update include lists 2022-10-11 09:06:12 +02:00
rootdir.h btrfs-progs: mkfs: update include lists 2022-10-11 09:06:12 +02:00