Do not run sector read check on suspended device.

This can affect status command, but later also device
stack with authenticated encryption (*_dif device).

Ignoring direct-io should not be problem here.
The logic shoudl be simplified in future anyway...
This commit is contained in:
Milan Broz
2023-11-15 14:10:54 +01:00
parent d3cc5e846a
commit 0f51b5bacb
2 changed files with 21 additions and 1 deletions

View File

@@ -178,6 +178,7 @@ static int device_ready(struct crypt_device *cd, struct device *device)
int devfd = -1, r = 0;
struct stat st;
size_t tmp_size;
const char *dm_name;
if (!device)
return -EINVAL;
@@ -188,7 +189,12 @@ static int device_ready(struct crypt_device *cd, struct device *device)
device->o_direct = 0;
devfd = open(device_path(device), O_RDONLY | O_DIRECT);
if (devfd >= 0) {
if (device_read_test(devfd) == 0) {
/* skip check for suspended DM devices */
dm_name = device_dm_name(device);
if (dm_name && dm_status_suspended(cd, dm_name)) {
close(devfd);
devfd = -1;
} else if (device_read_test(devfd) == 0) {
device->o_direct = 1;
} else {
close(devfd);