Sven Eschenberg wrote: > Dear List, > > is there any convenient way to set a dm-crypts volume readahead value? > Cryptsetup and the luks metadata seem to lack this option. If one puts a > dm-crypt volume on a raid, aside from aligning it, the crypted volumes > readahead should match the stripe size. > Why does dmcrypt itself not evaluate the current readahead of the > underlying blockdevice and after creating the mapping applies it to the > newly created blockdevice? > Because the calculation of readahead should be done in userspace and cryptsetup do not implement it yet. (Readahead setting was not available in old libdevmapper.) I think this patch should be enough to do that: (I can commit it to usptream svn if Clemens agrees) Retain readahead of underlying device. Signed-off-by: Milan Broz <mbroz@xxxxxxxxxx> --- lib/libdevmapper.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) Index: cryptsetup.upstream/lib/libdevmapper.c =================================================================== --- cryptsetup.upstream.orig/lib/libdevmapper.c 2009-06-02 15:35:57.000000000 +0200 +++ cryptsetup.upstream/lib/libdevmapper.c 2009-06-02 16:38:13.000000000 +0200 @@ -6,10 +6,13 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/sysmacros.h> +#include <sys/ioctl.h> #include <unistd.h> #include <dirent.h> #include <errno.h> #include <libdevmapper.h> +#include <fcntl.h> +#include <linux/fs.h> #include "libcryptsetup.h" #include "internal.h" @@ -111,6 +114,23 @@ static char *lookup_dev(const char *dev) return __lookup_dev(buf, makedev(major, minor)); } +static int _dev_read_ahead(const char *dev, uint32_t *read_ahead) +{ + int fd, r = 0; + long read_ahead_long; + + if ((fd = open(dev, O_RDONLY)) < 0) + return 0; + + r = ioctl(fd, BLKRAGET, &read_ahead_long) ? 0 : 1; + close(fd); + + if (r) + *read_ahead = (uint32_t) read_ahead_long; + + return r; +} + static char *get_params(struct crypt_options *options, const char *key) { char *params; @@ -234,6 +254,7 @@ static int dm_create_device(int reload, struct dm_info dmi; char *params = NULL; int r = -EINVAL; + uint32_t read_ahead = 0; params = get_params(options, key); if (!params) @@ -247,6 +268,11 @@ static int dm_create_device(int reload, goto out; if (!dm_task_add_target(dmt, 0, options->size, CRYPT_TARGET, params)) goto out; + + if (_dev_read_ahead(options->device, &read_ahead) && + !dm_task_set_read_ahead(dmt, read_ahead, DM_READ_AHEAD_MINIMUM_FLAG)) + goto out; + if (!dm_task_run(dmt)) goto out; --------------------------------------------------------------------- dm-crypt mailing list - http://www.saout.de/misc/dm-crypt/ To unsubscribe, e-mail: dm-crypt-unsubscribe@xxxxxxxx For additional commands, e-mail: dm-crypt-help@xxxxxxxx