From 1f9fe5b9f0ca116e28a1f5f01d10c5ad641aab8b Mon Sep 17 00:00:00 2001 From: Lei Feng Date: Wed, 5 Jan 2022 20:34:15 -0500 Subject: [PATCH] EX-4433 pcc: add some statistics data Add statictics of the number and total size of pcc attached files and pcc hit files. Change-Id: Ib0e429c636298d4c6ff06d84a416073895b86184 Signed-off-by: Lei Feng Reviewed-on: https://review.whamcloud.com/45976 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/llite/llite_internal.h | 2 ++ lustre/llite/lproc_llite.c | 9 ++++++--- lustre/llite/pcc.c | 8 +++++++- lustre/tests/sanity-pcc.sh | 36 ++++++++++++++++++++++++++++++++++++ lustre/tests/test-framework.sh | 9 ++++++++- 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 3e2de1f..51656f1 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -1090,6 +1090,8 @@ enum { LPROC_LL_PCC_ATTACH, LPROC_LL_PCC_DETACH, LPROC_LL_PCC_AUTOAT, + LPROC_LL_PCC_HIT_BYTES, + LPROC_LL_PCC_ATTACH_BYTES, LPROC_LL_FILE_OPCODES }; diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index fefe5dd..fdfd82f 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -1906,7 +1906,7 @@ static const struct llite_file_opcode { { LPROC_LL_TRUNC, LPROCFS_TYPE_LATENCY, "truncate" }, { LPROC_LL_FLOCK, LPROCFS_TYPE_LATENCY, "flock" }, { LPROC_LL_GETATTR, LPROCFS_TYPE_LATENCY, "getattr" }, - { LPROC_LL_FALLOCATE, LPROCFS_TYPE_LATENCY, "fallocate"}, + { LPROC_LL_FALLOCATE, LPROCFS_TYPE_LATENCY, "fallocate"}, /* dir inode operation */ { LPROC_LL_CREATE, LPROCFS_TYPE_LATENCY, "create" }, { LPROC_LL_LINK, LPROCFS_TYPE_LATENCY, "link" }, @@ -1924,9 +1924,12 @@ static const struct llite_file_opcode { { LPROC_LL_LISTXATTR, LPROCFS_TYPE_LATENCY, "listxattr" }, { LPROC_LL_REMOVEXATTR, LPROCFS_TYPE_LATENCY, "removexattr" }, { LPROC_LL_INODE_PERM, LPROCFS_TYPE_LATENCY, "inode_permission" }, - { LPROC_LL_PCC_ATTACH, LPROCFS_TYPE_REQS, "pcc_attach" }, + { LPROC_LL_PCC_ATTACH, LPROCFS_TYPE_LATENCY, "pcc_attach" }, { LPROC_LL_PCC_DETACH, LPROCFS_TYPE_REQS, "pcc_detach" }, - { LPROC_LL_PCC_AUTOAT, LPROCFS_TYPE_REQS, "pcc_auto_attach" }, + { LPROC_LL_PCC_AUTOAT, LPROCFS_TYPE_REQS, "pcc_auto_attach" }, + { LPROC_LL_PCC_HIT_BYTES, LPROCFS_TYPE_BYTES_FULL, "pcc_hit_bytes" }, + { LPROC_LL_PCC_ATTACH_BYTES, LPROCFS_TYPE_BYTES_FULL, + "pcc_attach_bytes" }, }; void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, long count) diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 988ec73..0424147 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -2348,6 +2348,8 @@ int pcc_file_open(struct inode *inode, struct file *file) } else { pccf->pccf_file = pcc_file; pccf->pccf_type = pcci->pcci_type; + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_PCC_HIT_BYTES, + inode->i_size); } out_unlock: @@ -3577,6 +3579,7 @@ static int pcc_attach_data_archive(struct file *file, struct inode *inode, struct file *pcc_filp; bool direct = false; struct path path; + ktime_t kstart = ktime_get(); ssize_t ret; int rc; @@ -3641,7 +3644,10 @@ out_dentry: pcc_inode_remove(inode, *dentry); dput(*dentry); } else { - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_PCC_ATTACH, 1); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_PCC_ATTACH, + ktime_us_delta(ktime_get(), kstart)); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_PCC_ATTACH_BYTES, + inode->i_size); } out_cred: revert_creds(old_cred); diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index 4d53fe9..d469ff8 100644 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -4348,6 +4348,42 @@ test_202() { } run_test 202 "lpcc_purge: match cache file name and approximate LRU" +test_203() { + local loopfile="$TMP/$tfile" + local mntpt="/mnt/pcc.$tdir" + local hsm_root="$mntpt/$tdir" + local file=$DIR/$tfile + local bs="1024" + + setup_loopdev client $loopfile $mntpt 10 + mkdir $hsm_root || error "mkdir $hsm_root failed" + setup_pcc_mapping client \ + "projid={0}\ roid=$HSM_ARCHIVE_NUMBER\ pccro=1" + $LCTL pcc list $MOUNT + clear_stats llite.*.stats + + dd if=/dev/zero of=$file bs=$bs count=1 || + error "Write $file failed" + + cat $file > /dev/null + cat $file > /dev/null + + echo "==== stats ====" + $LCTL get_param llite.*.stats + + local attach_num=$(calc_stats llite.*.stats pcc_attach_bytes) + local attach_bytes=$(calc_stats_sum llite.*.stats pcc_attach_bytes) + local hit_num=$(calc_stats llite.*.stats pcc_hit_bytes) + local hit_bytes=$(calc_stats_sum llite.*.stats pcc_hit_bytes) + echo "attach_num: $attach_num, attach_bytes: $attach_bytes, hit_num: $hit_num, hit_bytes: $hit_bytes" + + (( $attach_num == 1 )) || error "wrong attach number: $attach_num" + (( $attach_bytes == $bs )) || error "wrong attach bytes: $attach_bytes" + (( $hit_num == 2 )) || error "wrong hit number: $hit_num" + (( $hit_bytes == $((2 * bs)) )) || error "wrong hit bytes: $hit_bytes" +} +run_test 203 "Verify attach/hit bytes statistics data" + complete $SECONDS check_and_cleanup_lustre exit_status diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 38c8856..182fbb1 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -7331,7 +7331,14 @@ calc_stats() { local paramfile="$1" local stat="$2" lctl get_param -n $paramfile | - awk '/^'$stat'/ { sum += $2 } END { printf("%0.0f", sum) }' + awk '/^'$stat' / { sum += $2 } END { printf("%0.0f", sum) }' +} + +calc_stats_sum() { + local paramfile="$1" + local stat="$2" + lctl get_param -n $paramfile | + awk '/^'$stat' / { sum += $7 } END { printf("%0.0f", sum) }' } calc_sum () { -- 1.8.3.1