Skip to content

Commit 28c4c36

Browse files
committed
Do not use pagesize as fallback for block size.
Device must process MAX_SECTOR_SIZE as it is encryption block size, so if it does not work with this value, it will fail anyway.
1 parent 58db7d2 commit 28c4c36

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/utils_device.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct device {
4848

4949
static size_t device_fs_block_size_fd(int fd)
5050
{
51-
size_t page_size = crypt_getpagesize();
51+
size_t max_size = MAX_SECTOR_SIZE;
5252

5353
#if HAVE_SYS_STATVFS_H
5454
struct statvfs buf;
@@ -57,10 +57,10 @@ static size_t device_fs_block_size_fd(int fd)
5757
* NOTE: some filesystems (NFS) returns bogus blocksize (1MB).
5858
* Page-size io should always work and avoids increasing IO beyond aligned LUKS header.
5959
*/
60-
if (!fstatvfs(fd, &buf) && buf.f_bsize && buf.f_bsize <= page_size)
60+
if (!fstatvfs(fd, &buf) && buf.f_bsize && buf.f_bsize <= max_size)
6161
return (size_t)buf.f_bsize;
6262
#endif
63-
return page_size;
63+
return max_size;
6464
}
6565

6666
static size_t device_block_size_fd(int fd, size_t *min_size)
@@ -533,7 +533,7 @@ void device_topology_alignment(struct crypt_device *cd,
533533

534534
/* minimum io size */
535535
if (ioctl(fd, BLKIOMIN, &min_io_size) == -1) {
536-
log_dbg(cd, "Topology info for %s not supported, using default offset %lu bytes.",
536+
log_dbg(cd, "Topology info for %s not supported, using default alignment %lu bytes.",
537537
device->path, default_alignment);
538538
goto out;
539539
}

0 commit comments

Comments
 (0)