Skip to content

Commit bdebe41

Browse files
committed
md: Fix getting bitmap location on latest kernels
The 'md/bitmap/location' file no longer exists in sysfs when the bitmap is not set. The location of the "internal" bitmap is also slightly differet now.
1 parent 49608e3 commit bdebe41

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/plugins/mdraid.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,9 @@ gchar* bd_md_get_bitmap_location (const gchar *raid_spec, GError **error) {
14891489
sys_path = g_strdup_printf ("/sys/class/block/%s/md/bitmap/location", raid_node);
14901490
g_free (raid_node);
14911491

1492+
if (!g_file_test (sys_path, G_FILE_TEST_EXISTS))
1493+
return g_strdup ("none");
1494+
14921495
success = g_file_get_contents (sys_path, &ret, NULL, error);
14931496
if (!success) {
14941497
/* error is already populated */

tests/mdraid_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def test_set_bitmap_location(self):
476476
self.assertTrue(succ)
477477

478478
loc = BlockDev.md_get_bitmap_location("bd_test_md")
479-
self.assertEqual(loc, "+8")
479+
self.assertIn(loc, ("+8", "+2"))
480480

481481
succ = BlockDev.md_set_bitmap_location("bd_test_md", "none")
482482
self.assertTrue(succ)
@@ -488,7 +488,7 @@ def test_set_bitmap_location(self):
488488
self.assertTrue(succ)
489489

490490
loc = BlockDev.md_get_bitmap_location("bd_test_md")
491-
self.assertEqual(loc, "+8")
491+
self.assertIn(loc, ("+8", "+2"))
492492

493493
# test some different name specifications
494494
# (need to switch between internal and none because setting the same

0 commit comments

Comments
 (0)