Do not set default data offset with LUKS2 OPAL detached header.

This commit is contained in:
Ondrej Kozina
2023-07-31 14:48:17 +02:00
parent 570d3ad4e4
commit 5cf9e28530

View File

@@ -2202,7 +2202,11 @@ static int opal_topology_alignment(struct crypt_device *cd,
} }
if (!opal_align) { if (!opal_align) {
*ret_alignment_bytes = required_alignment_sectors ? (required_alignment_sectors * SECTOR_SIZE) : default_alignment_bytes; /* For detached header the alignment is used directly as data offset */
if (required_alignment_sectors || cd->metadata_device)
*ret_alignment_bytes = required_alignment_sectors * SECTOR_SIZE;
else
*ret_alignment_bytes = default_alignment_bytes;
*ret_alignment_offset_bytes = 0; *ret_alignment_offset_bytes = 0;
*ret_opal_block_bytes = opal_block_bytes; *ret_opal_block_bytes = opal_block_bytes;
*ret_opal_alignment_granularity_blocks = 1; *ret_opal_alignment_granularity_blocks = 1;
@@ -2230,7 +2234,8 @@ static int opal_topology_alignment(struct crypt_device *cd,
return -EINVAL; return -EINVAL;
} }
if (required_alignment_sectors) /* For detached header the alignment is used directly as data offset */
if (required_alignment_sectors || cd->metadata_device)
*ret_alignment_bytes = required_alignment_sectors * SECTOR_SIZE; *ret_alignment_bytes = required_alignment_sectors * SECTOR_SIZE;
else else
*ret_alignment_bytes = size_round_up(default_alignment_bytes, opal_block_bytes * opal_alignment_granularity_blocks); *ret_alignment_bytes = size_round_up(default_alignment_bytes, opal_block_bytes * opal_alignment_granularity_blocks);