Kernel needs some time to delete a device after losetup --detach. If
the losetup --find --nooverlay is called just after losetup --delete,
it can sometimes attempt to recycle the device that is just being
released. To prevent this race, clear the AUTOCLEAR flag of the
device.
[kzak@redhat.com: - rebase to the new version of the code]
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
loopcxt_deinit(lc);
errx(EXIT_FAILURE, _("%s: overlapping encrypted loop device exists"), file);
}
+
+ lc->info.lo_flags &= !LO_FLAGS_AUTOCLEAR;
+ if (loopcxt_set_status(lc)) {
+ loopcxt_deinit(lc);
+ errx(EXIT_FAILURE, _("%s: failed to re-use loop device"), file);
+ }
return 0; /* success, re-use */
}
default: /* error */