From c18d5d892b62ccee3cc9ec20a2278f17bb2d2f2c Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Thu, 26 Aug 2021 08:07:50 -0400 Subject: [PATCH] LU-14889 lproc: Add server checksum_type This patch adds 'checksum_type' lproc entries under server: 1. obdfilter.$FSNAME-OST${count}.checksum_type 2. mdt.$FSNAME-MDT${count}.checksum_type Test-case: sanity/77o added Test-Parameters: trivial Signed-off-by: Arshad Hussain Change-Id: I12a26f5c8c8f2f93d57f377626b1753fc13ffbb3 Reviewed-on: https://review.whamcloud.com/44755 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Li Dongyang Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_lproc.c | 40 ++++++++++++++++++++++++++++++++++++++++ lustre/ofd/lproc_ofd.c | 41 +++++++++++++++++++++++++++++++++++++++++ lustre/tests/sanity.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 4dd78ef..1d09ad4 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -56,6 +56,7 @@ #include #include #include "mdt_internal.h" +#include /** * The rename stats output would be YAML formats, like @@ -1324,6 +1325,43 @@ static ssize_t checksum_t10pi_enforce_store(struct kobject *kobj, } LUSTRE_RW_ATTR(checksum_t10pi_enforce); +/* + * mdt_checksum_type(server) proc handling + */ +DECLARE_CKSUM_NAME; + +static int mdt_checksum_type_seq_show(struct seq_file *m, void *data) +{ + struct obd_device *obd = m->private; + struct lu_target *lut; + enum cksum_types pref; + int i; + + if (!obd) + return 0; + + lut = obd->u.obt.obt_lut; + + /* select fastest checksum type on the server */ + pref = obd_cksum_type_select(obd->obd_name, + lut->lut_cksum_types_supported, 0); + + for (i = 0; i < ARRAY_SIZE(cksum_name); i++) { + if ((BIT(i) & lut->lut_cksum_types_supported) == 0) + continue; + + if (pref == BIT(i)) + seq_printf(m, "[%s] ", cksum_name[i]); + else + seq_printf(m, "%s ", cksum_name[i]); + } + seq_puts(m, "\n"); + + return 0; +} + +LPROC_SEQ_FOPS_RO(mdt_checksum_type); + LPROC_SEQ_FOPS_RO_TYPE(mdt, hash); LPROC_SEQ_FOPS_WR_ONLY(mdt, mds_evict_client); LPROC_SEQ_FOPS_RW_TYPE(mdt, checksum_dump); @@ -1402,6 +1440,8 @@ static struct lprocfs_vars lprocfs_mdt_obd_vars[] = { .fops = &mdt_root_squash_fops }, { .name = "nosquash_nids", .fops = &mdt_nosquash_nids_fops }, + { .name = "checksum_type", + .fops = &mdt_checksum_type_fops }, { NULL } }; diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index 6c7d5f8..e0bdfed 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -45,6 +45,7 @@ #include #include #include +#include #include "ofd_internal.h" @@ -470,6 +471,44 @@ ofd_brw_size_seq_write(struct file *file, const char __user *buffer, } LPROC_SEQ_FOPS(ofd_brw_size); +/* + * ofd_checksum_type(server) proc handling + */ +DECLARE_CKSUM_NAME; + +static int ofd_checksum_type_seq_show(struct seq_file *m, void *data) +{ + struct obd_device *obd = m->private; + struct lu_target *lut; + enum cksum_types pref; + int i; + + if (!obd) + return 0; + + lut = obd->u.obt.obt_lut; + + /* select fastest checksum type on the server */ + pref = obd_cksum_type_select(obd->obd_name, + lut->lut_cksum_types_supported, 0); + + for (i = 0; i < ARRAY_SIZE(cksum_name); i++) { + if ((BIT(i) & lut->lut_cksum_types_supported) == 0) + continue; + + if (pref == BIT(i)) + seq_printf(m, "[%s] ", cksum_name[i]); + else + seq_printf(m, "%s ", cksum_name[i]); + } + seq_puts(m, "\n"); + + return 0; +} + +LPROC_SEQ_FOPS_RO(ofd_checksum_type); + + #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0) static bool sync_on_lock_cancel_warned; static ssize_t sync_on_lock_cancel_show(struct kobject *kobj, @@ -1017,6 +1056,8 @@ struct lprocfs_vars lprocfs_ofd_obd_vars[] = { .fops = &ofd_lfsck_verify_pfid_fops }, { .name = "site_stats", .fops = &ofd_site_stats_fops }, + { .name = "checksum_type", + .fops = &ofd_checksum_type_fops }, { NULL } }; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 16d3553..65c457e 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -9840,6 +9840,36 @@ test_77n() { } run_test 77n "Verify read from a hole inside contiguous blocks with T10PI" +test_77o() { + (( $CLIENT_VERSION >= $(version_code 2.14.54) )) || + skip "Need at least version 2.14.54" + local ofd=obdfilter + local mdt=mdt + + # print OST checksum_type + echo "$ofd.$FSNAME-*.checksum_type:" + do_nodes $(comma_list $(osts_nodes)) \ + $LCTL get_param -n $ofd.$FSNAME-*.checksum_type + + # print MDT checksum_type + echo "$mdt.$FSNAME-*.checksum_type:" + do_nodes $(comma_list $(mdts_nodes)) \ + $LCTL get_param -n $mdt.$FSNAME-*.checksum_type + + local o_count=$(do_nodes $(comma_list $(osts_nodes)) \ + $LCTL get_param -n $ofd.$FSNAME-*.checksum_type | wc -l) + + (( $o_count == $OSTCOUNT )) || + error "found $o_count checksums, not \$MDSCOUNT=$OSTCOUNT" + + local m_count=$(do_nodes $(comma_list $(mdts_nodes)) \ + $LCTL get_param -n $mdt.$FSNAME-*.checksum_type | wc -l) + + (( $m_count == $MDSCOUNT )) || + error "found $m_count checksums, not \$MDSCOUNT=$MDSCOUNT" +} +run_test 77o "Verify checksum_type for server (mdt and ofd(obdfilter))" + cleanup_test_78() { trap 0 rm -f $DIR/$tfile -- 1.8.3.1