Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/tests/dbus-tests/test_mdraid.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def _md_data(self, array_name):

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:
Expand Down Expand Up @@ -167,7 +175,7 @@ def test_create(self):

# 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':
Expand Down Expand Up @@ -369,7 +377,7 @@ def test_bitmap_location(self):

# check that internal bitmap was forced
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))
self.assertStartswith(sys_bitmap, '+')

Expand All @@ -379,7 +387,7 @@ def test_bitmap_location(self):
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))
self.assertEqual(sys_bitmap, 'none')

Expand All @@ -389,7 +397,7 @@ def test_bitmap_location(self):
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))
self.assertStartswith(sys_bitmap, '+')

Expand Down
5 changes: 4 additions & 1 deletion src/udiskslinuxmdraid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *consistency_policy = NULL;
Expand Down Expand Up @@ -318,7 +319,9 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid *mdraid,
sync_action = udisks_linux_device_read_sysfs_attr (raid_device, "md/sync_action", NULL);
sync_completed = udisks_linux_device_read_sysfs_attr (raid_device, "md/sync_completed", NULL);
consistency_policy = udisks_linux_device_read_sysfs_attr (raid_device, "md/consistency_policy", NULL);
bitmap_location = udisks_linux_device_read_sysfs_attr (raid_device, "md/bitmap/location", NULL);
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))
Expand Down