Re: README losetup/mount-Parameter "offset" needs another note

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matthias Schniedermeyer wrote:
> But i still think that a little "note" about that is appropriate for the
> README, so that other won't fall into the same tarpit as i. :-)

Following text will be in next version of loop-AES README "Performance
tuning" section:



Soft block size of loop device has negative effect on efficiency and
performance if that soft block size is too small. On recent kernels, default
soft block size is set to such value that full device can be accessed using
X amount of such soft block size chunks. If device size is integer multiple
of processor page size, then default soft block size will also be processor
page size. Some older kernels inherit default soft block size from backing
device.

Mounting a file system on top of loop device sets loop device's soft block
size to same as block size of that mounted file system, so none of this soft
block size optimization affects mounted file system performance. But too
small soft block size may affect unmounted loop device performance.
Unmounting a file system may set loop device's soft block size back to
default value (this depends on kernel version).

Since unmounted loop device is not usually used for anything other than
occasional fsck, this reduced efficiency and performance is not necessarily
a problem. However, if you insist on getting maximum performance from fsck
and other direct to loop device usage, then (1) you can use backing disk
partition whose size is integer multiple of 4096 bytes, or (2) you can limit
size of loop device to integer multiple of 4096 bytes, or (3) you can set
loop device's soft block size manually to 4096 bytes. Option (3) doesn't
work on all kernels because many kernels seem to revert to default soft
block size when device is not mounted and no process is holding open file
descriptor on it.

This command shows size of device in 512 byte units:

    blockdev --getsize /dev/loop0

This command shows soft block size of device in byte units:

    blockdev --getbsz /dev/loop0

This command sets soft block size of device:

    blockdev --setbsz 4096 /dev/loop0
    
In this example, backing device size is 20012106240 bytes (39086145 * 512).
Loop device size is rounded down to integer multiple of 4096 bytes,
20012105728 bytes:

    blockdev --getsize /dev/hda666
    39086145
    losetup -e AES128 -K foo.gpg -s 20012105728 /dev/loop0 /dev/hda666
                                 ^^^^^^^^^^^^^^
You can also add sizelimit=20012105728 mount option /etc/fstab file. Mount
won't benefit much from it because file system mount sets soft block size to
desired value anyway, but "losetup -F /dev/loop0" reads and uses that option
from /etc/fstab file. losetup -s and sizelimit mount option do not work with
2.2 and older kernels.


-- 
Jari Ruusu  1024R/3A220F51 5B 4B F9 BB D3 3F 52 E9  DB 1D EB E3 24 0E A9 DD

-
Linux-crypto:  cryptography in and on the Linux system
Archive:       http://mail.nl.linux.org/linux-crypto/


[Index of Archives]     [Kernel]     [Linux Crypto]     [Gnu Crypto]     [Gnu Classpath]     [Netfilter]     [Bugtraq]
  Powered by Linux