Whamcloud - gitweb
LU-11698 libcfs: Add checksum speed under /sys/fs 43/43943/11
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Tue, 8 Jun 2021 09:32:01 +0000 (05:32 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 8 Jul 2021 02:06:13 +0000 (02:06 +0000)
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 <arshad.hussain@aeoncomputing.com>
Change-Id: If125032e35bfd9221eb66e6f77bf7e3753ffcc0f
Reviewed-on: https://review.whamcloud.com/43943
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/include/libcfs/libcfs_crypto.h
libcfs/libcfs/linux-crypto.c
lustre/obdclass/obd_sysfs.c
lustre/tests/sanity.sh

index 8271306..f271676 100644 (file)
@@ -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
 
 /* 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
  *
 /**
  * Return hash algorithm information for the specified algorithm identifier
  *
index bcacaa3..e210b80 100644 (file)
@@ -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
  */
 /**
  *  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.
 
 /**
  * Initialize the state descriptor for the specified hash algorithm.
index 4d064f5..5d9430a 100644 (file)
@@ -62,6 +62,7 @@
 #include <linux/kobject.h>
 
 #include <libcfs/libcfs.h>
 #include <linux/kobject.h>
 
 #include <libcfs/libcfs.h>
+#include <libcfs/libcfs_crypto.h>
 #include <obd_support.h>
 #include <obd_class.h>
 #include <lprocfs_status.h>
 #include <obd_support.h>
 #include <obd_class.h>
 #include <lprocfs_status.h>
@@ -500,6 +501,63 @@ static const struct file_operations obd_device_list_fops = {
        .release = seq_release,
 };
 
        .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)
 {
 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("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);
        entry = lprocfs_register("fs/lustre", NULL, NULL, NULL);
        if (IS_ERR(entry)) {
                rc = PTR_ERR(entry);
index 7e71eba..0f3c56a 100755 (executable)
@@ -9596,6 +9596,20 @@ run_test 77l "preferred checksum type is remembered after reconnected"
 rm -f $F77_TMP
 unset F77_TMP
 
 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
 cleanup_test_78() {
        trap 0
        rm -f $DIR/$tfile