util-linux/lib
Naohiro Aota 6be38dccae libblkid: add magic and probing for zoned btrfs
This commit adds zone-aware magics and probing functions for zoned btrfs.

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

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 starting
to write to the first zone again, it reset the first zone.

We can determine the position of the latest superblock by reading the 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 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 resets the first zone to write a new superblock. If btrfs
crashes 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 the temporary magic ("!BHRfS_M") in zone #0. Mkfs.btrfs
first writes the temporary superblock to the zone during the mkfs process.
It will survive there until the zones are filled up and reset. So, we also
need to detect this temporary magic.

Finally, this commit extends probe_btrfs() to load the latest superblock
determined by the write pointers.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
2021-05-24 13:39:53 +02:00
..
Makemodule.am build-sys: keep adoc files in dist_noinst_DATA 2021-05-05 13:35:30 +02:00
blkdev.c libblkid: add magic and probing for zoned btrfs 2021-05-24 13:39:53 +02:00
buffer.c lib: add missing headers to .c files 2020-10-06 15:03:45 +02:00
canonicalize.c lib/canonicalize: fix compiler warning [-Wsign-compare] 2019-06-10 11:00:38 +02:00
caputils.c lib/caputils: split to multiple functions, add test 2020-11-20 11:21:41 +01:00
color-names.c lib/color-names: add "white" between human-readable 2020-03-10 09:45:33 +01:00
colors.c misc: fix typos [codespell] 2019-09-12 19:41:46 +01:00
cpuset.c taskset: fix cpuset list parser 2019-03-20 13:12:25 +01:00
crc32.c lib/crc32: prefix public functions 2016-10-19 12:11:59 +02:00
crc32c.c lib: Add simple crc32c() function 2017-11-16 11:44:39 +01:00
encode.c [clang-tidy] do not use else after return 2020-04-20 13:20:59 -07:00
env.c misc: fix typos [codespell] 2020-11-04 11:42:25 +00:00
exec_shell.c cast NULL to char * when using execl 2020-10-29 19:49:07 +02:00
fileutils.c lib: use ul_prefix for close_all_fds() and mkdir_p() 2021-01-28 10:27:21 +01:00
idcache.c [clang-tidy] do not return in void functions 2020-04-19 14:03:21 -07:00
ismounted.c [clang-tidy] fix wrong *cmp usage 2020-04-20 13:21:00 -07:00
jsonwrt.c lib/jsonwrt: don't use ctype.h for ASCII chars 2021-05-06 16:35:50 +02:00
langinfo.c lib: add missing license headers 2019-11-08 10:40:42 +01:00
linux_version.c lib: add missing headers to .c files 2020-10-06 15:03:45 +02:00
loopdev.c lib/loopdev: fix is_loopdev() to be usable with partitions 2021-04-20 13:20:12 +02:00
mangle.c include: add some missing licence stuff to header files 2020-01-13 10:39:52 +01:00
match.c lib/match: make match_fstype() case insensitive 2017-08-31 14:15:23 +02:00
mbsalign.c lib/mbsalign: add function to calculate width 2020-04-22 12:22:29 +02:00
mbsedit.c lib/mbsedit: check wctomb() return code [coverity scan] 2017-10-11 14:40:37 +02:00
md5.c lib/md5: use ul_/UL_ prefix 2017-12-12 12:06:15 +01:00
meson.build meson: generate man pages from asciidoc 2021-04-06 15:32:46 +02:00
monotonic.c dmesg: adjust timestamps according to suspended time 2020-06-04 10:57:36 +02:00
pager.c lib/pager: fix improper use of negative value [coverity scan] 2020-10-16 11:30:08 +02:00
path.c lib/path: add ul_path_is_accessible() 2020-07-08 08:50:07 +02:00
plymouth-ctrl.c lib: style cosmetics plymouth-ctrl.c 2017-06-15 09:13:04 +02:00
procutils.c lib/procutils: improve proc_is_procfs(), add test 2020-11-20 10:40:31 +01:00
pty-session.c lib/pty-session: fix time_t=long assumptions 2021-05-06 10:22:07 +02:00
pwdutils.c lib: add missing headers to .c files 2020-10-06 15:03:45 +02:00
randutils.c libuuid: check quality of random bytes 2020-11-08 11:48:23 +00:00
selinux-utils.c lib/selinux-utils: tiny cleanup 2021-01-13 15:04:02 +01:00
sha1.c lib/sha1: use proper WORDS_BIGENDIAN macro 2018-01-02 11:08:03 +01:00
signames.c lib/signames: change license to public domain 2020-11-19 12:04:08 +01:00
strutils.c lib/strutils: assume 64-bit time_t 2021-05-06 11:06:45 +02:00
strv.c lib/strv: add strv_extendv() 2015-10-01 14:43:05 +02:00
swapprober.c lib: add missing headers to .c files 2020-10-06 15:03:45 +02:00
sysfs.c lib/sysfs: fix doble free [coverity scan] 2020-10-09 13:46:35 +02:00
terminal-colors.d.5.adoc build-sys: make man pages location independent 2021-03-31 11:50:47 +02:00
timer.c lib: add missing headers to .c files 2020-10-06 15:03:45 +02:00
timeutils.c Fixed wrongful time_t=long assumptions in hwclock.c and timeutils.c 2021-04-29 11:56:37 +00:00
ttyutils.c [clang-tidy] do not use else after return 2020-04-20 13:20:59 -07:00