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

Add option to specify metadata version when creating MD RAID #1201

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
6 changes: 5 additions & 1 deletion data/org.freedesktop.UDisks2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
@level: The RAID level for the array.
@name: The name for the array.
@chunk: The chunk size (in bytes) or 0 if @level is <quote>raid1</quote>.
@options: Options - known options (in addition to <link linkend="udisks-std-options">standard options</link>) include <parameter>bitmap</parameter> (of type 'ay').
@options: Options - known options (in addition to <link linkend="udisks-std-options">standard options</link>) include <parameter>bitmap</parameter> (of type 'ay') and <parameter>version</parameter> (of type 'ay').
@resulting_array: An object path to the object implementing the #org.freedesktop.UDisks2.MDRaid interface.
@since: 2.0.0

Expand All @@ -171,6 +171,10 @@
is not present, it is up to <literal>mdadm</literal> to decide
whether to create an internal bitmap (typically for arrays larger
than 100 GB) or not.

The @version option specifies the MD metadata version, for example
'0.90'. If not specified the default medata version specified by
<literal>mdadm</literal> is used. (since 2.11)
-->
<method name="MDRaidCreate">
<arg name="blocks" direction="in" type="ao"/>
Expand Down
28 changes: 25 additions & 3 deletions src/tests/dbus-tests/test_mdraid.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ def _force_remove(self, array_name, array_members):
def _zero_superblock(self, device):
self.run_command('mdadm --zero-superblock --force %s' % device)

def _array_create(self, array_name, bitmap=None):
def _array_create(self, array_name, bitmap=None, version=None):
# set the 'force' cleanup now in case create fails
self.addCleanup(self._force_remove, array_name, [m.path for m in self.members])

d = self.no_options
if bitmap:
if bitmap or version:
d = dbus.Dictionary(signature='sv')
d['bitmap'] = self.str_to_ay(bitmap)
if bitmap:
d['bitmap'] = self.str_to_ay(bitmap)
if version:
d['version'] = self.str_to_ay(version)

manager = self.get_object('/Manager')
with wait_for_action('resync'):
Expand Down Expand Up @@ -391,6 +394,25 @@ def test_bitmap_location(self):
dbus_bitmap.assertEqual(self.str_to_ay(sys_bitmap))
self.assertStartswith(sys_bitmap, '+')

@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSTABLE)
def test_metadata_version(self):
array_name = 'udisks_test_version'
array = self._array_create(array_name, version='0.90')

# check IdVersion on the Block interface
for member in self.members:
md_version = self.get_property(member.obj, '.Block', 'IdVersion')
md_version.assertEqual('0.90.0')

array.Delete(self.no_options, dbus_interface=self.iface_prefix + '.MDRaid')
self.udev_settle()

array = self._array_create(array_name)
# check IdVersion on the Block interface
for member in self.members:
md_version = self.get_property(member.obj, '.Block', 'IdVersion')
md_version.assertEqual('1.2')

@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSTABLE)
def test_request_action(self):

Expand Down
4 changes: 3 additions & 1 deletion src/udiskslinuxmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ handle_mdraid_create (UDisksManager *_object,
guint disks_top = 0;
gboolean success = FALSE;
const gchar *option_bitmap = NULL;
const gchar *option_version = NULL;

if (!udisks_daemon_util_get_caller_uid_sync (manager->daemon,
invocation,
Expand Down Expand Up @@ -767,7 +768,8 @@ handle_mdraid_create (UDisksManager *_object,
disks[disks_top] = NULL;

g_variant_lookup (arg_options, "bitmap", "^&ay", &option_bitmap);
if (!bd_md_create (array_name, arg_level, disks, 0, NULL, option_bitmap, arg_chunk, NULL, &error))
g_variant_lookup (arg_options, "version", "^&ay", &option_version);
if (!bd_md_create (array_name, arg_level, disks, 0, option_version, option_bitmap, arg_chunk, NULL, &error))
{
g_prefix_error (&error, "Error creating RAID array: ");
udisks_simple_job_complete (UDISKS_SIMPLE_JOB (job), FALSE, error->message);
Expand Down