Page MenuHomeFreeBSD

zfsd(8): Close a race condition when onlining a disk paritition
ClosedPublic

Authored by asomers on Aug 7 2017, 11:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 1 2024, 11:57 PM
Unknown Object (File)
Jan 2 2024, 8:21 PM
Unknown Object (File)
Dec 20 2023, 3:37 AM
Unknown Object (File)
Dec 11 2023, 11:41 PM
Unknown Object (File)
Nov 21 2023, 1:12 AM
Unknown Object (File)
Oct 15 2023, 1:21 AM
Unknown Object (File)
Oct 4 2023, 4:00 PM
Unknown Object (File)
Sep 17 2023, 5:41 AM
Subscribers

Details

Summary

zfsd(8): Close a race condition when onlining a disk paritition

When inserting a partitioned disk, devfs and geom will announce the whole
disk before they announce the partition. If the partition containing ZFS
extends to one of the disk's extents, then zfsd will see a ZFS label on the
whole disk and attempt to online it. ZFS is smart enough to activate the
partition instead of the whole disk, but only if GEOM has already created
the partition's provider.

cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
Add a zpool_read_all_labels method. It's similar to
zpool_read_label, but it will return the number of labels found.

cddl/usr.sbin/zfsd/zfsd_event.cc
When processing a DevFS CREATE event, only online a VDEV if we can
read all four ZFS labels.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

You haven't included zpool_read_all_labels method into the patch.

I don't have objections other then ones I sounded when you implemented alike functionality in kernel.

Whoops! Here's zpool_read_all_labels

In D11920#247428, @mav wrote:

I don't have objections other then ones I sounded when you implemented alike functionality in kernel.

Presumably you mean D10365. I agree that this seems like a hackish way to verify that we're reading the correct partition. But the label doesn't include the size of the device, so I don't see what other option there is. Adding mediasize to the label would be a change to the ZFS on-disk format, albeit a backwards-compatible one.

This revision was automatically updated to reflect the committed changes.