Skip to content
  • Dave Reisner's avatar
    lib/utils_crypt: optimize seek to keyfile-offset · 961682aa
    Dave Reisner authored and Milan Broz's avatar Milan Broz committed
    Avoid using unbuffered reads when "seeking" to a keyfile offset. This is
    abysmally slow when the key is hidden at the end of a large device.
    Instead, try to actually call lseek, falling back on reading in chunks
    of BUFSIZ bytes until the desired offset is reached.
    
    Command line:
    
      cryptsetup luksOpen /dev/vdc1 home \
          --keyfile /dev/vdd --keyfile-size 4096 --keyfile-offset 123456789
    
    Before:
    
      real   0m25.589s
      user   0m7.030s
      sys    0m18.479s
    
    After:
    
      real   0m4.464s
      user   0m4.253s
      sys    0m0.157s
    961682aa
To find the state of this project's repository at the time of any of these versions, check out the tags.