From 58566d58e53ed2bd5ec6b5a17f1e0a8b73f2b433 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 5 Dec 2018 20:54:13 -0800 Subject: [PATCH] FROMGIT: dm verity: log the hash algorithm implementation Log the hash algorithm's driver name when a dm-verity target is created. This will help people determine whether the expected implementation is being used. It can make an enormous difference; e.g., SHA-256 on ARM can be 8x faster with the crypto extensions than without. It can also be useful to know if an implementation using an external crypto accelerator is being used instead of a software implementation. Example message: [ 35.281945] device-mapper: verity: sha256 using implementation "sha256-ce" We've already found the similar message in fs/crypto/keyinfo.c to be very useful. Signed-off-by: Eric Biggers Signed-off-by: Mike Snitzer (cherry picked from commit 8ec60e93af574f0426dba17208084f1038b1418e https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next) Test: Verified that the message is logged when dm-verity is used. Change-Id: I78a803eb8e0db8eda7b4790cd338d5d5555486e5 Signed-off-by: Eric Biggers --- drivers/md/dm-verity-target.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 0bb39cc34747..4e1d1089f3c7 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -1044,6 +1044,15 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) v->tfm = NULL; goto bad; } + + /* + * dm-verity performance can vary greatly depending on which hash + * algorithm implementation is used. Help people debug performance + * problems by logging the ->cra_driver_name. + */ + DMINFO("%s using implementation \"%s\"", v->alg_name, + crypto_hash_alg_common(v->tfm)->base.cra_driver_name); + v->digest_size = crypto_ahash_digestsize(v->tfm); if ((1 << v->hash_dev_block_bits) < v->digest_size * 2) { ti->error = "Digest size too big";