Comment 7 for bug 1838329

Revision history for this message
Dan Streetman (ddstreet) wrote :

@mmstick76, while I agree with the grumblings upstream that udev should be better about race conditions like this, if we're working around it I'd prefer to flock while mkswap instead of retriggering udev...can you test with that change?

Patch below, and I have test builds for b/f here:
https://launchpad.net/~ddstreet/+archive/ubuntu/lp1838329

--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -202,8 +202,8 @@ static int create_disk(

         if (swap)
                 fprintf(f,
- "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
- name_escaped);
+ "ExecStartPost=/usr/bin/flock -F '/dev/mapper/%s' /sbin/mkswap '/dev/mapper/%s'\n",
+ name_escaped, name_escaped);

         r = fflush_and_check(f);
         if (r < 0)