summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-17 15:27:15 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-10-13 05:08:33 +0900
commit12f5fbdf30cbb917760cc1887abd19089d49b0a8 (patch)
tree06d98762593b99e77dc3af8c5d9aab210d445f44
parent1d369d78b3cdb801c5758880b04cc10f997e2b0c (diff)
downloadsystemd-12f5fbdf30cbb917760cc1887abd19089d49b0a8.tar.gz
dissect-image: fix error handling of @cancel_deferred_remove DM command
See target_message() in drivers/md/dm-ioctl.c and dm_cancel_deferred_remove() in drivers/md/dm.c.
-rw-r--r--src/shared/dissect-image.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index 77d6101cff..6bfea815ee 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -2090,14 +2090,17 @@ static int verity_partition(
if (!restore_deferred_remove){
/* To avoid races, disable automatic removal on umount while setting up the new device. Restore it on failure. */
r = dm_deferred_remove_cancel(name);
- /* If activation returns EBUSY there might be no deferred removal to cancel, that's fine */
- if (r < 0 && r != -ENXIO)
+ /* -EBUSY and -ENXIO: the device has already been removed or being removed. We cannot
+ * use the device, try to open again. See target_message() in drivers/md/dm-ioctl.c
+ * and dm_cancel_deferred_remove() in drivers/md/dm.c */
+ if (IN_SET(r, -EBUSY, -ENXIO))
+ goto try_again;
+ if (r < 0)
return log_debug_errno(r, "Failed to disable automated deferred removal for verity device %s: %m", node);
- if (r >= 0) {
- restore_deferred_remove = strdup(name);
- if (!restore_deferred_remove)
- return log_oom_debug();
- }
+
+ restore_deferred_remove = strdup(name);
+ if (!restore_deferred_remove)
+ return log_oom_debug();
}
r = verity_can_reuse(verity, name, &existing_cd);