From d775f9ae37975c853984b67f6d1a21e6ec8a8c3d Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Tue, 8 Jun 2021 05:32:01 -0400 Subject: [PATCH] LU-11698 libcfs: Add checksum speed under /sys/fs This patch adds total of registered checksum and all registered checksum names along with their speed under /sys/kernel/debug/lustre/checksum_speed TestCase sanity/77m added. Sample output: $ lctl get_param checksum_speed checksum_speed=adler32: 1955 crc32: 2423 crc32c: 14035 Test-Parameters: trivial Signed-off-by: Arshad Hussain Change-Id: If125032e35bfd9221eb66e6f77bf7e3753ffcc0f Reviewed-on: https://review.whamcloud.com/43943 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_crypto.h | 3 ++ libcfs/libcfs/linux-crypto.c | 3 +- lustre/obdclass/obd_sysfs.c | 61 +++++++++++++++++++++++++++++++++++ lustre/tests/sanity.sh | 14 ++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) diff --git a/libcfs/include/libcfs/libcfs_crypto.h b/libcfs/include/libcfs/libcfs_crypto.h index 8271306..f271676 100644 --- a/libcfs/include/libcfs/libcfs_crypto.h +++ b/libcfs/include/libcfs/libcfs_crypto.h @@ -134,6 +134,9 @@ static struct cfs_crypto_crypt_type crypt_types[] = { /* Maximum size of hash_types[].cht_size */ #define CFS_CRYPTO_HASH_DIGESTSIZE_MAX 64 +/* Array of hash algorithm speed in MByte per second */ +extern int cfs_crypto_hash_speeds[CFS_HASH_ALG_MAX]; + /** * Return hash algorithm information for the specified algorithm identifier * diff --git a/libcfs/libcfs/linux-crypto.c b/libcfs/libcfs/linux-crypto.c index bcacaa3..e210b80 100644 --- a/libcfs/libcfs/linux-crypto.c +++ b/libcfs/libcfs/linux-crypto.c @@ -49,7 +49,8 @@ static inline const char *crypto_ahash_driver_name(struct crypto_ahash *tfm) /** * Array of hash algorithm speed in MByte per second */ -static int cfs_crypto_hash_speeds[CFS_HASH_ALG_MAX]; +int cfs_crypto_hash_speeds[CFS_HASH_ALG_MAX]; +EXPORT_SYMBOL(cfs_crypto_hash_speeds); /** * Initialize the state descriptor for the specified hash algorithm. diff --git a/lustre/obdclass/obd_sysfs.c b/lustre/obdclass/obd_sysfs.c index 4d064f5..5d9430a 100644 --- a/lustre/obdclass/obd_sysfs.c +++ b/lustre/obdclass/obd_sysfs.c @@ -62,6 +62,7 @@ #include #include +#include #include #include #include @@ -500,6 +501,63 @@ static const struct file_operations obd_device_list_fops = { .release = seq_release, }; +/* checksum_speed */ +static void *checksum_speed_start(struct seq_file *p, loff_t *pos) +{ + return pos; +} + +static void checksum_speed_stop(struct seq_file *p, void *v) +{ +} + +static void *checksum_speed_next(struct seq_file *p, void *v, loff_t *pos) +{ + ++(*pos); + if (*pos >= CFS_HASH_ALG_SPEED_MAX - 1) + return NULL; + + return pos; +} + +static int checksum_speed_show(struct seq_file *p, void *v) +{ + loff_t index = *(loff_t *)v; + + if (!index || index > CFS_HASH_ALG_SPEED_MAX - 1) + return 0; + + seq_printf(p, "%s: %d\n", cfs_crypto_hash_name(index), + cfs_crypto_hash_speeds[index]); + + return 0; +} + +static const struct seq_operations checksum_speed_sops = { + .start = checksum_speed_start, + .stop = checksum_speed_stop, + .next = checksum_speed_next, + .show = checksum_speed_show, +}; + +static int checksum_speed_open(struct inode *inode, struct file *file) +{ + int rc = seq_open(file, &checksum_speed_sops); + + if (rc) + return rc; + + return 0; +} + +static const struct file_operations checksum_speed_fops = { + .owner = THIS_MODULE, + .open = checksum_speed_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static int health_check_seq_show(struct seq_file *m, void *unused) { @@ -592,6 +650,9 @@ int class_procfs_init(void) file = debugfs_create_file("health_check", 0444, debugfs_lustre_root, NULL, &health_check_fops); + file = debugfs_create_file("checksum_speed", 0444, debugfs_lustre_root, + NULL, &checksum_speed_fops); + entry = lprocfs_register("fs/lustre", NULL, NULL, NULL); if (IS_ERR(entry)) { rc = PTR_ERR(entry); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 7e71eba..0f3c56a 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9596,6 +9596,20 @@ run_test 77l "preferred checksum type is remembered after reconnected" rm -f $F77_TMP unset F77_TMP +test_77m() { + (( $CLIENT_VERSION >= $(version_code 2.14.52) )) || + skip "Need at least version 2.14.52" + local param=checksum_speed + + $LCTL get_param $param || error "reading $param failed" + + csum_speeds=$($LCTL get_param -n $param) + + [[ "$csum_speeds" =~ "adler32" && "$csum_speeds" =~ "crc32" ]] || + error "known checksum types are missing" +} +run_test 77m "Verify checksum_speed is correctly read" + cleanup_test_78() { trap 0 rm -f $DIR/$tfile -- 1.8.3.1