Skip to content

Commit

Permalink
Merge pull request #5740 from dachary/wip-user
Browse files Browse the repository at this point in the history
wip-user: multipath partition fix / dmcrypt activation fix

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Sep 1, 2015
2 parents 697a9a3 + 5815c28 commit bc232a4
Showing 1 changed file with 46 additions and 10 deletions.
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

0 comments on commit bc232a4

Please sign in to comment.