Ignore optimal-io if not aligned to minimal page size

This values is bogus on some systems and causes wrong alignment
for data area. Just ignore it there.

Fixes: #585.
This commit is contained in:
Milan Broz
2020-08-24 09:35:57 +02:00
parent 9c8c636ece
commit b79ccb782b
2 changed files with 34 additions and 3 deletions

View File

@@ -520,10 +520,16 @@ void device_topology_alignment(struct crypt_device *cd,
temp_alignment = (unsigned long)min_io_size;
/* Ignore bogus opt-io that could break alignment */
/*
* Ignore bogus opt-io that could break alignment.
* Also real opt_io_size should be aligned to minimal page size (4k).
* Some bogus USB enclosures reports wrong data here.
*/
if ((temp_alignment < (unsigned long)opt_io_size) &&
!((unsigned long)opt_io_size % temp_alignment))
!((unsigned long)opt_io_size % temp_alignment) && !MISALIGNED_4K(opt_io_size))
temp_alignment = (unsigned long)opt_io_size;
else if (opt_io_size)
log_err(cd, "Ignoring bogus optimal-io size for data device (%u bytes).", opt_io_size);
/* If calculated alignment is multiple of default, keep default */
if (temp_alignment && (default_alignment % temp_alignment))