util-linux/include
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: move selinux_utils.c 2021-01-13 13:30:31 +01:00
all-io.h build-sys: fix sendfile use 2020-11-09 15:30:06 +01:00
bitops.h include/bitops: avoid fallbacks for more systems 2016-03-08 14:55:38 +01:00
blkdev.h libblkid: add magic and probing for zoned btrfs 2021-05-24 13:39:53 +02:00
buffer.h lib/buffer: add simple grow-able buffer 2020-09-29 12:06:11 +02:00
c.h text-utils: correctly detect ASan under clang 2021-02-01 11:59:47 +01:00
canonicalize.h lsblk: use prefix for DM name 2018-06-21 13:19:28 +02:00
caputils.h unshare: add --keep-caps option 2019-09-09 20:23:08 -07:00
carefulputc.h lib/jsonwrt: remove fputs_quoted_json_* functions from include/carefulputc.h 2021-05-06 16:05:56 +02:00
cctype.h lib: add parse-date.y 2017-03-04 10:49:41 -05:00
closestream.h text-utils: correctly detect ASan under clang 2021-02-01 11:59:47 +01:00
color-names.h misc: Fix various typos 2016-05-31 23:40:21 +02:00
colors.h lib/colors: force to "never" mode on non-terminal output 2019-02-04 14:14:37 +01:00
cpuset.h misc: Fix various typos 2016-05-31 23:40:21 +02:00
crc32.h lib/crc32: prefix public functions 2016-10-19 12:11:59 +02:00
crc32c.h lib: Add simple crc32c() function 2017-11-16 11:44:39 +01:00
debug.h include/debug: introduce __UL_INIT_DEBUG_FROM_STRING() 2018-01-17 13:58:29 +01:00
debugobj.h include/debug: don't print pointer address for SUID programs 2018-01-12 11:01:26 +01:00
encode.h libblkid: move UTF encoding function to lib/ 2020-02-25 12:00:27 +01:00
env.h lib/env: add function to save and restore unwanted variables 2020-08-25 10:43:07 +02:00
exec_shell.h lib/exec_shell: cleanup function attributes 2018-02-01 12:25:39 +01:00
exitcodes.h include/exitcodes: remove mount(8) exit codes 2017-04-27 14:26:45 +02:00
fileutils.h lib/fileutils: close fd if fdopen is failed 2021-05-06 12:20:14 +02:00
fuzz.h tests: integrate test_mount_fuzz into the testsuite 2020-08-06 12:33:11 +00:00
idcache.h namei: move icache to lib/ 2015-11-27 13:56:01 +01:00
ismounted.h lib: import whole ismounted.c code from e2fsprogs 2009-10-14 01:13:18 +02:00
iso9660.h isosize: move ISO size functions into a shared header 2019-12-16 14:29:24 +08:00
jsonwrt.h lib/jsonwrt: remove 'islast' from API 2021-05-06 15:58:02 +02:00
linux_version.h lib: add linux_version.{c,h} 2007-11-06 02:40:13 +01:00
list.h include/list: add list_entry_is_first() and list_count_entries() 2018-12-07 12:33:34 +01:00
loopdev.h lib/loopdev: cosmetic changes to LOOP_CONFIGURE 2020-10-05 14:52:20 +02:00
mangle.h lib/mangle: check for the NULL string argument 2020-03-20 16:28:49 -04:00
match.h lib,match: split match_fstype() from libmount 2011-11-15 15:17:19 +01:00
mbsalign.h lib/mbsalign: add function to calculate width 2020-04-22 12:22:29 +02:00
mbsedit.h lib/mbsedit: add simple buffer editor 2017-02-16 13:47:44 +01:00
md5.h [clang-tidy] fix mismatching declarations 2020-04-19 14:03:21 -07:00
meson.build meson: add second build system 2021-03-17 15:07:27 +01:00
minix.h libblkid: arch independent minix detection 2013-04-15 15:14:33 +02:00
monotonic.h dmesg: adjust timestamps according to suspended time 2020-06-04 10:57:36 +02:00
namespace.h unshare: support the time namespace 2020-03-08 19:02:00 +01:00
nls.h include/nls: remove unnecessary declaration 2020-04-22 10:27:12 +02:00
optutils.h optutils.h: don't print non-graph characters 2017-04-18 22:39:05 -04:00
pager.h lib/pager: cleanup and extend API 2016-08-26 12:07:25 +02:00
partx.h build-sys: fix non-blkid compilation 2017-09-19 13:48:52 +02:00
path.h lib/path: add ul_path_is_accessible() 2020-07-08 08:50:07 +02:00
pathnames.h include/pathnames: cleanup /proc/sys/kernel use 2021-02-02 16:54:12 +01:00
pidfd-utils.h include: cleanup pidfd inckudes 2020-03-10 12:32:36 +01:00
plymouth-ctrl.h cleanup: Remove some spurious spaces 2019-10-01 13:01:43 +02:00
procutils.h lib/procutils: add proc_is_procfs helper. 2020-11-18 14:30:50 -03:00
pt-bsd.h fdisk: (bsd) write/read PT code cleanup 2013-09-16 16:47:06 +02:00
pt-gpt-partnames.h libfdisk: add "Linux /usr" and "Linux /usr verity" GPT partition types 2020-09-21 18:26:53 +03:00
pt-mbr-partnames.h libfdisk: (MBR) use 0xEA partition type by BootLoaderSpecification 2020-01-02 15:16:54 +01:00
pt-mbr.h include/pt-mbr.h: fix integer overflow 2018-05-28 13:36:38 +02:00
pt-sgi.h build-sys: fix UTIL_LINUX_PT_SGI_H macro [lgtm scan] 2019-09-20 15:31:31 +02:00
pt-sun.h libblkid: const qualifier cleanup 2018-07-20 15:05:32 +02:00
pty-session.h su: (pty) change owner and mode for pty 2021-02-23 11:52:45 +01:00
pwdutils.h lib/pwdutils: add xgetgrnam 2020-04-15 22:50:59 +10:00
randutils.h libuuid: check quality of random bytes 2020-11-08 11:48:23 +00:00
rpmatch.h rpmatch: use symbolic value when evaluation return codes 2015-02-24 12:42:06 +01:00
selinux-utils.h mkswap: remove deprecated SELinux matchpathcon() 2021-01-13 14:58:43 +01:00
sha1.h lib/sha1: use ul_/UL_prefix for symbols 2017-12-12 11:29:02 +01:00
signames.h lib/signames: remove unused function 2017-11-28 14:39:17 +01:00
statfs_magic.h misc: Fix various typos 2016-05-31 23:40:21 +02:00
strutils.h lib/strutils: assume 64-bit time_t 2021-05-06 11:06:45 +02:00
strv.h lib/strv: add strv_extendv() 2015-10-01 14:43:05 +02:00
swapheader.h mkswap: remove unnecessary size check 2014-11-07 13:21:05 +01:00
swapprober.h swapon: split swapon-common.c 2014-09-22 13:16:25 +02:00
sysfs.h lsblk: Ignore hidden devices 2020-05-14 15:48:26 +02:00
timer.h lib/timer: add fallback if timer_create() not available 2018-12-03 11:23:33 +01:00
timeutils.h various: use threadsafe versions of time functions [lgtm scan] 2020-02-15 15:23:44 +00:00
ttyutils.h login: move generic setting to ttyutils.h 2021-02-23 11:46:10 +01:00
widechar.h include/widechar: add fallback for WEOF 2016-06-03 14:50:48 +02:00
xalloc.h include/xalloc: reindent function bodies to unify indentation 2019-08-21 15:00:16 +02:00