From 34903b22e51422db14828f898974cf0d1e81b56e Mon Sep 17 00:00:00 2001 From: Lei Feng Date: Wed, 5 Jan 2022 20:34:15 -0500 Subject: [PATCH] LU-10499 pcc: add some statistics data Add statictics of the number and total size of pcc attached files and pcc hit files. EX-bug-id: EX-4433 Change-Id: Ib0e429c636298d4c6ff06d84a416073895b86184 Signed-off-by: Lei Feng Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54458 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: James Simmons Reviewed-by: Andreas Dilger --- lustre/llite/llite_internal.h | 2 ++ lustre/llite/lproc_llite.c | 3 +++ lustre/llite/pcc.c | 14 ++++++++++++-- lustre/tests/sanity-pcc.sh | 36 ++++++++++++++++++++++++++++++++++++ lustre/tests/test-framework.sh | 10 +++++++++- 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index ada9b45..de47230 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -1307,6 +1307,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_HYBRID_NOSWITCH, LPROC_LL_HYBRID_WRITESIZE_SWITCH, LPROC_LL_HYBRID_READSIZE_SWITCH, diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 7afeee9..88695b3 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -2568,6 +2568,9 @@ static const struct llite_file_opcode { { LPROC_LL_PCC_ATTACH, LPROCFS_TYPE_REQS, "pcc_attach" }, { LPROC_LL_PCC_DETACH, LPROCFS_TYPE_REQS, "pcc_detach" }, { 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" }, /* hybrid IO switch from buffered I/O (BIO) to direct I/O (DIO) */ { LPROC_LL_HYBRID_NOSWITCH, LPROCFS_TYPE_REQS, "hybrid_noswitch" }, { LPROC_LL_HYBRID_WRITESIZE_SWITCH, LPROCFS_TYPE_REQS, diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 308256e..b1fc32b 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -2374,6 +2374,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: @@ -3721,6 +3723,7 @@ int pcc_readwrite_attach(struct file *file, struct inode *inode, struct pcc_dataset *dataset; struct ll_inode_info *lli = ll_i2info(inode); struct pcc_super *super = ll_i2pccs(inode); + ktime_t kstart = ktime_get(); struct pcc_inode *pcci; struct dentry *dentry; int rc; @@ -3762,7 +3765,10 @@ out_unlock: revert_creds(old_cred); 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_dataset_put: pcc_dataset_put(dataset); @@ -3911,6 +3917,7 @@ static int pcc_readonly_attach(struct file *file, const struct cred *old_cred; struct pcc_dataset *dataset; struct pcc_inode *pcci = NULL; + ktime_t kstart = ktime_get(); struct dentry *dentry; bool attached = false; bool unlinked = false; @@ -3987,7 +3994,10 @@ out_put_unlock: else 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); } revert_creds(old_cred); pcc_inode_unlock(inode); diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index ef66f74..a9e72a4 100755 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -4334,6 +4334,42 @@ test_102() { } run_test 102 "PCC-RO should not hange for io_uring I/O engine" +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_test $SECONDS check_and_cleanup_lustre exit_status diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 0d498e9..50a39b4 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -8379,7 +8379,15 @@ calc_stats() { 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