89 lines
3.9 KiB
Diff
89 lines
3.9 KiB
Diff
From d181edb85b8892f9c4a9c1f201565cee8a38a5e0 Mon Sep 17 00:00:00 2001
|
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
|
Date: Tue, 16 Dec 2025 14:16:10 +0100
|
|
Subject: [PATCH] udiskslinuxmdraid: Fix getting bitmap location on latest
|
|
kernels
|
|
|
|
bd_md_get_bitmap_location reads the value from sysfs (so this
|
|
doesn't introduce any new mdadm calls) but also correctly handles
|
|
the missing md/bitmap/location file with arrays without bitmap.
|
|
|
|
See also https://github.com/storaged-project/libblockdev/pull/1143
|
|
---
|
|
src/tests/dbus-tests/test_mdraid.py | 14 +++++++++++---
|
|
src/udiskslinuxmdraid.c | 5 ++++-
|
|
2 files changed, 15 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/tests/dbus-tests/test_mdraid.py b/src/tests/dbus-tests/test_mdraid.py
|
|
index 479710c4..f6c9b8f1 100644
|
|
--- a/src/tests/dbus-tests/test_mdraid.py
|
|
+++ b/src/tests/dbus-tests/test_mdraid.py
|
|
@@ -113,6 +113,14 @@ class RAIDLevel(udiskstestcase.UdisksTestCase):
|
|
|
|
return data
|
|
|
|
+ def _get_bitmap_location(self, md_name):
|
|
+ try:
|
|
+ bitmap = self.read_file('/sys/block/%s/md/bitmap/location' % md_name)
|
|
+ except FileNotFoundError:
|
|
+ # since kernel 6.18 the md/bitmap/location file doesn't exist when bitmap is not set
|
|
+ bitmap = "none"
|
|
+ return bitmap.strip()
|
|
+
|
|
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSTABLE)
|
|
def test_create(self):
|
|
if self.level is None:
|
|
@@ -160,7 +168,7 @@ class RAIDLevel(udiskstestcase.UdisksTestCase):
|
|
|
|
# check bitmap location
|
|
dbus_bitmap = self.get_property(array, '.MDRaid', 'BitmapLocation')
|
|
- sys_bitmap = self.read_file('/sys/block/%s/md/bitmap/location' % md_name)
|
|
+ sys_bitmap = self._get_bitmap_location(md_name)
|
|
|
|
# raid0 does not support write-intent bitmaps -> BitmapLocation is set to an empty string
|
|
if self.level == 'raid0':
|
|
@@ -366,7 +374,7 @@ class RAID1TestCase(RAIDLevel):
|
|
array.SetBitmapLocation(loc, self.no_options, dbus_interface=self.iface_prefix + '.MDRaid')
|
|
|
|
dbus_bitmap = self.get_property(array, '.MDRaid', 'BitmapLocation')
|
|
- sys_bitmap = self.read_file('/sys/block/%s/md/bitmap/location' % md_name).strip()
|
|
+ sys_bitmap = self._get_bitmap_location(md_name)
|
|
dbus_bitmap.assertEqual(self.str_to_ay(sys_bitmap))
|
|
|
|
# change bitmap location back to 'none'
|
|
@@ -375,7 +383,7 @@ class RAID1TestCase(RAIDLevel):
|
|
array.SetBitmapLocation(loc, self.no_options, dbus_interface=self.iface_prefix + '.MDRaid')
|
|
|
|
dbus_bitmap = self.get_property(array, '.MDRaid', 'BitmapLocation')
|
|
- sys_bitmap = self.read_file('/sys/block/%s/md/bitmap/location' % md_name).strip()
|
|
+ sys_bitmap = self._get_bitmap_location(md_name)
|
|
dbus_bitmap.assertEqual(self.str_to_ay(sys_bitmap))
|
|
|
|
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSTABLE)
|
|
diff --git a/src/udiskslinuxmdraid.c b/src/udiskslinuxmdraid.c
|
|
index 7eca9764..74ab9030 100644
|
|
--- a/src/udiskslinuxmdraid.c
|
|
+++ b/src/udiskslinuxmdraid.c
|
|
@@ -235,6 +235,7 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid,
|
|
const gchar *level = NULL;
|
|
const gchar *uuid = NULL;
|
|
const gchar *name = NULL;
|
|
+ const gchar *devfile = NULL;
|
|
gchar *sync_action = NULL;
|
|
gchar *sync_completed = NULL;
|
|
gchar *bitmap_location = NULL;
|
|
@@ -316,7 +317,9 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid,
|
|
degraded = read_sysfs_attr_as_int (raid_device->udev_device, "md/degraded");
|
|
sync_action = read_sysfs_attr (raid_device->udev_device, "md/sync_action");
|
|
sync_completed = read_sysfs_attr (raid_device->udev_device, "md/sync_completed");
|
|
- bitmap_location = read_sysfs_attr (raid_device->udev_device, "md/bitmap/location");
|
|
+ devfile = g_udev_device_get_device_file (raid_device->udev_device);
|
|
+ if (devfile)
|
|
+ bitmap_location = bd_md_get_bitmap_location (devfile, NULL);
|
|
}
|
|
|
|
if (mdraid_has_stripes (level))
|
|
--
|
|
2.55.0
|
|
|