btrfs-progs/cmds
Naohiro Aota 8ef9313cf2 btrfs-progs: zoned: implement log-structured superblock
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, 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.

- primary superblock: offset   0B (and the following zone)
- first copy:         offset 512G (and the following zone)
- Second copy:        offset   4T (4096G, and the following zone)

If these reserved zones are conventional, superblock is written fixed at
the start of the zone without logging.

Currently, superblock reading/writing is done by pread/pwrite. This
commit replace the call sites with sbread/sbwrite to wrap the functions.
For zoned btrfs, btrfs_sb_io which is called from sbread/sbwrite
reverses the IO position back to a mirror number, maps the mirror number
into the superblock logging position, and do the IO.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-06 16:41:45 +02:00
..
balance.c btrfs-progs: balance: fix raid56 warning for other profiles 2021-03-23 17:04:22 +01:00
commands.h btrfs-progs: help: define helper for command with flags 2019-07-03 20:49:04 +02:00
device.c btrfs-progs: build: fix linking with static libmount 2021-01-25 23:31:56 +01:00
filesystem-du.c btrfs-progs: fix short/long unit size options 2020-12-16 17:08:52 +01:00
filesystem-usage.c btrfs-progs: a bunch of typo fixes 2021-01-13 22:33:10 +01:00
filesystem-usage.h btrfs-progs: move all cmds-fi*.c to cmds/ 2019-07-03 20:49:03 +02:00
filesystem.c btrfs-progs: fi resize: fix false 0.00B size output 2021-05-06 16:41:44 +02:00
inspect-dump-super.c btrfs-progs: zoned: implement log-structured superblock 2021-05-06 16:41:45 +02:00
inspect-dump-tree.c btrfs-progs: factor open_ctree parameters to a structure 2021-03-24 22:20:19 +01:00
inspect-tree-stats.c btrfs-progs: move volumes.c to kernel-shared/ 2020-08-31 17:01:06 +02:00
inspect.c btrfs-progs: inspect: use find_mount_fsroot in logical-resolve 2021-01-18 17:49:22 +01:00
property.c btrfs-progs: move ctree.c to kernel-shared/ 2020-08-31 17:01:05 +02:00
qgroup.c btrfs-progs: build: fix linking with static libmount 2021-01-25 23:31:56 +01:00
quota.c btrfs-progs: move ctree.c to kernel-shared/ 2020-08-31 17:01:05 +02:00
receive-dump.c btrfs-progs: move send-utils.c to common/ 2020-08-31 17:01:04 +02:00
receive-dump.h btrfs-progs: move send-dump.c to cmds/receive-dump.c 2020-08-31 17:01:04 +02:00
receive.c btrfs-progs: receive: remove workaround for setting capabilities 2021-02-19 15:18:39 +01:00
replace.c btrfs-progs: fix return code for failed replace start 2021-02-19 19:58:01 +01:00
rescue-chunk-recover.c btrfs-progs: provide fs_info from btrfs_device 2021-05-06 16:41:45 +02:00
rescue-super-recover.c btrfs-progs: move volumes.c to kernel-shared/ 2020-08-31 17:01:06 +02:00
rescue.c btrfs-progs: factor open_ctree parameters to a structure 2021-03-24 22:20:19 +01:00
rescue.h btrfs-progs: super-recover: add global verbose option 2020-06-12 19:31:37 +02:00
restore.c btrfs-progs: factor open_ctree parameters to a structure 2021-03-24 22:20:19 +01:00
scrub.c btrfs-progs: fix short/long unit size options 2020-12-16 17:08:52 +01:00
send.c btrfs-progs: send: fix crash on unknown option 2021-01-13 22:33:09 +01:00
subvolume.c btrfs-progs: subvol set-default: change id to 5 if specified as 0 2021-01-18 17:49:23 +01:00