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

wip-user: multipath partition fix / dmcrypt activation fix #5740

Merged
merged 2 commits into from Sep 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 46 additions & 10 deletions src/ceph-disk
Expand Up @@ -996,7 +996,8 @@ def dmcrypt_map(
keypath,
_uuid,
cryptsetup_parameters,
luks
luks,
format_dev=False,
):
"""
Maps a device to a dmcrypt device.
Expand Down Expand Up @@ -1033,7 +1034,8 @@ def dmcrypt_map(

try:
if luks:
command_check_call(luksFormat_args)
if format_dev:
command_check_call(luksFormat_args)
command_check_call(luksOpen_args)
else:
# Plain mode has no format function, nor any validation that the key is correct.
Expand Down Expand Up @@ -1590,7 +1592,14 @@ def prepare_dev(

dev = None
if osd_dm_keypath:
dev = dmcrypt_map(rawdev, osd_dm_keypath, osd_uuid, cryptsetup_parameters, luks)
dev = dmcrypt_map(
rawdev=rawdev,
keypath=osd_dm_keypath,
_uuid=osd_uuid,
cryptsetup_parameters=cryptsetup_parameters,
luks=luks,
format_dev=True,
)
else:
dev = rawdev

Expand Down Expand Up @@ -2123,11 +2132,24 @@ def mount_activate(
# proceeding.
rawdev = dev
ptype = get_partition_type(rawdev)
if ptype not in [DMCRYPT_OSD_UUID]:
if ptype in [DMCRYPT_OSD_UUID]:
luks = False
cryptsetup_parameters = ['--key-size', '256']
elif ptype in [DMCRYPT_LUKS_OSD_UUID]:
luks = True
cryptsetup_parameters = []
else:
raise Error('activate --dmcrypt called for invalid dev %s' % (dev))
part_uuid = get_partition_uuid(rawdev)
dmcrypt_key_path = os.path.join(dmcrypt_key_dir, part_uuid)
dev = dmcrypt_map(rawdev, dmcrypt_key_path, part_uuid)
dmcrypt_key_path = get_dmcrypt_key_path(part_uuid, dmcrypt_key_dir, luks)
dev = dmcrypt_map(
rawdev=rawdev,
keypath=dmcrypt_key_path,
_uuid=part_uuid,
cryptsetup_parameters=cryptsetup_parameters,
luks=luks,
format_dev=False,
)

try:
fstype = detect_fstype(dev=dev)
Expand Down Expand Up @@ -2440,7 +2462,8 @@ def get_journal_osd_uuid(path):
if not stat.S_ISBLK(mode):
raise Error('%s is not a block device' % path)

if (get_partition_type(path) == MPATH_JOURNAL_UUID and
if (is_partition(path) and
get_partition_type(path) == MPATH_JOURNAL_UUID and
not is_mpath(path)):
raise Error('%s is not a multipath block device' %
path)
Expand Down Expand Up @@ -2481,11 +2504,24 @@ def main_activate_journal(args):
# it before proceeding.
rawdev = args.dev
ptype = get_partition_type(rawdev)
if ptype not in [DMCRYPT_JOURNAL_UUID]:
if ptype in [DMCRYPT_JOURNAL_UUID]:
luks = False
cryptsetup_parameters = ['--key-size', '256']
elif ptype in [DMCRYPT_LUKS_JOURNAL_UUID]:
luks = True
cryptsetup_parameters = []
else:
raise Error('activate-journal --dmcrypt called for invalid dev %s' % (rawdev))
part_uuid = get_partition_uuid(rawdev)
dmcrypt_key_path = os.path.join(args.dmcrypt_key_dir, part_uuid)
dev = dmcrypt_map(rawdev, dmcrypt_key_path, part_uuid)
dmcrypt_key_path = get_dmcrypt_key_path(part_uuid, args.dmcrypt_key_dir, luks)
dev = dmcrypt_map(
rawdev=rawdev,
keypath=dmcrypt_key_path,
_uuid=part_uuid,
cryptsetup_parameters=cryptsetup_parameters,
luks=luks,
format_dev=False,
)
else:
dev = args.dev

Expand Down