[systemd-devel] Raid device issue

Ken Bass kbass at kenbass.com
Thu Dec 8 09:35:34 PST 2011


I just want to add one additional potential race issue that I saw in my 
log files.

I used the cryptsetup.target which I understood to be a synchronization 
barrier.

In my case I used 'Before=cryptsetup.target' in my mnt-usbkey.mount, but 
this issue is more general.

Looking at the log files, it appears that cryptsetup.target is triggered 
not triggered when the cryptsetup stuff begins.
Rather, a separate service for each entry in /etc/crypttab completes 
right before cryptsetup.target.

So I'm thinking that this is another case of a race issue. If someone 
specifies 'Before=cryptsetup.target' as a synchronization target, there 
is a window of time before that where stuff in the /etc/crypttab is 
being performed yet cryptsetup.target has not triggered.

[   27.073983] systemd[1]: About to execute: 
/lib/systemd/systemd-cryptsetup attach encrypt_storage 
/dev/disk/by-id/md-uuid-432b22e3:364555c6:f3927192:227cec7f 
/mnt/usbkey/storage.key cipher=aes-cbc-essiv:sha256,size=256,hash=sha1
[   27.086057] rmmod[1004]: ERROR: Module scsi_wait_scan does not exist 
in /proc/modules
[   27.104056] systemd[1]: Forked /lib/systemd/systemd-cryptsetup as 1007
[   27.104133] systemd[1]: cryptsetup at encrypt_storage.service changed 
dead -> start
...
[   29.042725] systemd[1]: cryptsetup at encrypt_storage.service: main 
process exited, code=exited, status=0
[   29.075045] systemd[1]: cryptsetup at encrypt_storage.service changed 
start -> exited
[   29.075051] systemd[1]: Job cryptsetup at encrypt_storage.service/start 
finished, result=done
[   29.075215] systemd[1]: cryptsetup.target changed dead -> active
[   29.075221] systemd[1]: Job cryptsetup.target/start finished, result=done

 From the above logs, there is a full 2 seconds between systemd doing 
the '/lib/systemd/systemd-cryptsetup attach' and when 'cryptsetup.target 
changed dead -> active' is declared.

In my case, I specified a 'Before=cryptsetup.target' in my 
mnt-usbkey.mount. However, what would prevent the mnt-usbkey.mount from 
not being executed within the above  2 second interval? This looks wrong 
to me.


More information about the systemd-devel mailing list