• Dave Reisner's avatar
    lib/utils_crypt: optimize seek to keyfile-offset · 961682aa
    Dave Reisner authored
    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
      real   0m25.589s
      user   0m7.030s
      sys    0m18.479s
      real   0m4.464s
      user   0m4.253s
      sys    0m0.157s
utils_crypt.c 11.6 KB