49 lines
1.3 KiB
Diff
49 lines
1.3 KiB
Diff
From 10b1d6493e3be04953ac9f65d2b2d992ab87bdde Mon Sep 17 00:00:00 2001
|
|
From: Milan Broz <gmazyland@gmail.com>
|
|
Date: Tue, 21 Sep 2021 15:54:07 +0200
|
|
Subject: [PATCH 2/7] Check if DM create device failed in an early phase.
|
|
|
|
This happens when concurrent creation of DM devices meets
|
|
in the very early state (no device node exists but creation fails).
|
|
|
|
Return -ENODEV here instead of -EINVAL.
|
|
|
|
(Should "fix" random verity concurrent test failure.)
|
|
---
|
|
lib/libdevmapper.c | 11 ++++-------
|
|
1 file changed, 4 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c
|
|
index 09fd9588..1594f877 100644
|
|
--- a/lib/libdevmapper.c
|
|
+++ b/lib/libdevmapper.c
|
|
@@ -1346,12 +1346,6 @@ err:
|
|
return r;
|
|
}
|
|
|
|
-static bool dm_device_exists(struct crypt_device *cd, const char *name)
|
|
-{
|
|
- int r = dm_status_device(cd, name);
|
|
- return (r >= 0 || r == -EEXIST);
|
|
-}
|
|
-
|
|
static int _dm_create_device(struct crypt_device *cd, const char *name, const char *type,
|
|
struct crypt_dm_active_device *dmd)
|
|
{
|
|
@@ -1402,8 +1396,11 @@ static int _dm_create_device(struct crypt_device *cd, const char *name, const ch
|
|
goto out;
|
|
|
|
if (!dm_task_run(dmt)) {
|
|
- if (dm_device_exists(cd, name))
|
|
+ r = dm_status_device(cd, name);;
|
|
+ if (r >= 0)
|
|
r = -EEXIST;
|
|
+ if (r != -EEXIST && r != -ENODEV)
|
|
+ r = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|