From 143e0828c8818df2c137ada5acdacedf2a14fff0 Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Fri, 4 Feb 2022 02:14:42 +0000 Subject: [PATCH] osd: re-enable raw mode on disk We can re-enable raw mode OSD on disk if Ceph version is at least v16.2.6. https://github.com/ceph/ceph/pull/42469 Closes: https://github.com/rook/rook/issues/9659 Signed-off-by: Satoru Takeuchi --- pkg/daemon/ceph/osd/volume.go | 22 ++++++++++++++++++---- pkg/daemon/ceph/osd/volume_test.go | 6 ++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pkg/daemon/ceph/osd/volume.go b/pkg/daemon/ceph/osd/volume.go index 7bfac6494..35ca28b22 100644 --- a/pkg/daemon/ceph/osd/volume.go +++ b/pkg/daemon/ceph/osd/volume.go @@ -56,8 +56,12 @@ var ( // The Ceph Octopus to include a retry to acquire device lock cephFlockFixOctopusMinCephVersion = cephver.CephVersion{Major: 15, Minor: 2, Extra: 9} - isEncrypted = os.Getenv(oposd.EncryptedDeviceEnvVarName) == "true" - isOnPVC = os.Getenv(oposd.PVCBackedOSDVarName) == "true" + + // The mitigation of phantom ATARI partition problem is fixed in Ceph v16.2.6. Quincy doesn't have this problem from the beginning + // See https://github.com/ceph/ceph/pull/42469 + cephIgnorePhantomAtariPartitionCephVersion = cephver.CephVersion{Major: 16, Minor: 2, Extra: 6} + isEncrypted = os.Getenv(oposd.EncryptedDeviceEnvVarName) == "true" + isOnPVC = os.Getenv(oposd.PVCBackedOSDVarName) == "true" ) type osdInfoBlock struct { @@ -468,6 +472,16 @@ func (a *OsdAgent) allowRawMode(context *clusterd.Context) (bool, error) { return allowRawMode, nil } +func isSafeToUseRawMode(deviceType string, cephVersion cephver.CephVersion) bool { + if deviceType != sys.DiskType { + return true + } + if cephVersion.IsAtLeast(cephIgnorePhantomAtariPartitionCephVersion) { + return true + } + return false +} + func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceOsdMapping) error { // Should we allow ceph-volume raw mode? allowRawMode, err := a.allowRawMode(context) @@ -493,7 +507,7 @@ func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceO } for name, device := range devices.Entries { - // Even if we can use raw mode, do NOT use raw mode on disks. Ceph bluestore disks can + // Even if we can use raw mode, do NOT use raw mode on disks in Ceph < 16.2.6. Ceph bluestore disks can // sometimes appear as though they have "phantom" Atari (AHDI) partitions created on them // when they don't in reality. This is due to a series of bugs in the Linux kernel when it // is built with Atari support enabled. This behavior does not appear for raw mode OSDs on @@ -502,7 +516,7 @@ func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceO // which reports only the phantom partitions (and malformed OSD info) when they exist and // ignores the original (correct) OSDs created on the raw disk. // See: https://github.com/rook/rook/issues/7940 - if device.DeviceInfo.Type != sys.DiskType && allowRawMode { + if allowRawMode && isSafeToUseRawMode(device.DeviceInfo.Type, a.clusterInfo.CephVersion) { rawDevices.Entries[name] = device continue } diff --git a/pkg/daemon/ceph/osd/volume_test.go b/pkg/daemon/ceph/osd/volume_test.go index d787337e1..8163be067 100644 --- a/pkg/daemon/ceph/osd/volume_test.go +++ b/pkg/daemon/ceph/osd/volume_test.go @@ -1378,3 +1378,9 @@ func TestAppendOSDInfo(t *testing.T) { assert.Equal(t, 3, len(trimmedOSDs)) } } + +func TestIsSafeToUseRawMode(t *testing.T) { + assert.Equal(t, true, isSafeToUseRawMode(sys.PartType, cephver.CephVersion{Major: 16, Minor: 2, Extra: 5})) + assert.Equal(t, false, isSafeToUseRawMode(sys.DiskType, cephver.CephVersion{Major: 16, Minor: 2, Extra: 5})) + assert.Equal(t, true, isSafeToUseRawMode(sys.DiskType, cephver.CephVersion{Major: 16, Minor: 2, Extra: 6})) +}