]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
geom_part: extend kern.geom.part.check_integrity to work on GPT
authoreugen <eugen@FreeBSD.org>
Tue, 8 Sep 2020 22:23:53 +0000 (22:23 +0000)
committereugen <eugen@FreeBSD.org>
Tue, 8 Sep 2020 22:23:53 +0000 (22:23 +0000)
commitad24dd082a6997b9e8ce9a2d254fa3e9081176a4
treedca14ccff780f56ab3500616849c2a35472c0e35
parent700e53f09f6c352accd9dafd2a23548a6fdf3615
geom_part: extend kern.geom.part.check_integrity to work on GPT

There are multiple USB/SATA bridges on the market that unconditionally
cut some LBAs off connected media. This could be a problem
for pre-partitioned drives so GEOM complains and does not create
devices in /dev for slices/partitions preventing access to existing data.

We have kern.geom.part.check_integrity that allows us to correct
partitioning if changed from default 1 to 0 but it works for MBR only.
If backup copy of GPT is unavailable due to decreases number of LBAs,
kernel still does not give access to partitions and prints to dmesg:

GEOM: md0: corrupt or invalid GPT detected.
GEOM: md0: GPT rejected -- may not be recoverable.

This change makes it work for GPT too, so it created partitions in /dev
and prints to dmesg this instead:

GEOM: md0: the secondary GPT table is corrupt or invalid.
GEOM: md0: using the primary only -- recovery suggested.

Then "gpart recover" re-created backup copy of GPT
and allows further manipulations with partitions.

This change is no-op for default configuration having
kern.geom.part.check_integrity=1

Reported by: Alex Korchmar
MFC after: 3 days.
sys/geom/part/g_part.c
sys/geom/part/g_part_gpt.c