Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #543: Fix BTRFS mounting issue. #545

Merged
merged 1 commit into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions deb/openmediavault/debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ openmediavault (5.2.1-1) unstable; urgency=low

* Issue #542: Add OMV_WATCHDOG_CONF_WATCHDOG_TIMEOUT to customize
the watchdog timeout.
* Issue #543: Fix BTRFS mounting issue.

-- Volker Theile <volker.theile@openmediavault.org> Sun, 22 Dec 2019 22:18:16 +0100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,36 @@ class Btrfs extends BackendAbstract {
* See parent class definition.
*/
public function enumerateByBlkid(array $enums) {
// Sort filesystems by device names.
array_sort_key($enums, "devicefile");
// Filter filesystems with duplicate UUID, e.g. when they are
// used in a RAID. Because of the previous sorting always the
// lower device is used.
// The following example of a RAID1 will return /dev/sdk.
// /dev/sdk: LABEL="TestFS" UUID="b7adba40-b980-4067-b33c-dd5c8ee17044" UUID_SUB="7b19094b-e7df-4a3e-a3db-57e2d4c548b3" TYPE="btrfs"
// /dev/sdl: LABEL="TestFS" UUID="b7adba40-b980-4067-b33c-dd5c8ee17044" UUID_SUB="ba1e2b16-5022-4cbd-ad35-6d609e9560e9" TYPE="btrfs"
return array_unique_key($enums, "uuid");
$result = [];
// !!! Attention !!!
// We need to keep the following in mind when processing BTRFS
// filesystems:
// * BTRFS will report multiple devices for a RAID.
// * BTRFS seems to randomly use a device file for the canonical
// path from a device of the RAID.
//
// # blkid
// /dev/sdb: LABEL="openmediavaultData" UUID="9b84cea2-3c7b-4f88-b346-f3bc1ee7c804" UUID_SUB="c86b22dd-c08d-47c5-93f3-90bd445931bb" TYPE="btrfs"
// /dev/sda: LABEL="openmediavaultData" UUID="9b84cea2-3c7b-4f88-b346-f3bc1ee7c804" UUID_SUB="04c92e67-4e6e-4cfc-bb71-18f9a109aa35" TYPE="btrfs"
// /dev/sdc: LABEL="openmediavaultData" UUID="9b84cea2-3c7b-4f88-b346-f3bc1ee7c804" UUID_SUB="9756742b-1552-46ce-9631-8e9376e1a918" TYPE="btrfs"
//
// # ls -alh /dev/disk/by-label/openmediavaultData
// lrwxrwxrwx 1 root root 9 Dec 24 14:05 /dev/disk/by-label/openmediavaultData -> ../../sdc
//
// Because of that we need to find out the correct device file
// and return ONLY that device.
// To achieve this, we first filter for unique UUIDs and use
// the /dev/disk/by-uuid/<UUID> device file to get the
// canonical one. After that simply get the array element
// related to that device file.
$uniqueEnums = array_unique_key($enums, "uuid");
foreach ($uniqueEnums as $uniqueEnumk => $uniqueEnumv) {
$canonicalDeviceFile = realpath(sprintf("/dev/disk/by-uuid/%s",
$uniqueEnumv['uuid']));
$result[] = array_filter_ex($enums, "devicefile",
$canonicalDeviceFile)[0];
}
return $result;
}

/**
Expand Down