Whamcloud - gitweb
LU-10499 pcc: add some statistics data 58/54458/7
authorLei Feng <flei@whamcloud.com>
Thu, 6 Jan 2022 01:34:15 +0000 (20:34 -0500)
committerOleg Drokin <green@whamcloud.com>
Mon, 2 Dec 2024 05:42:42 +0000 (05:42 +0000)
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 <flei@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54458
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/llite/llite_internal.h
lustre/llite/lproc_llite.c
lustre/llite/pcc.c
lustre/tests/sanity-pcc.sh
lustre/tests/test-framework.sh

index ada9b45..de47230 100644 (file)
@@ -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,
index 7afeee9..88695b3 100644 (file)
@@ -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,
index 308256e..b1fc32b 100644 (file)
@@ -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);
index ef66f74..a9e72a4 100755 (executable)
@@ -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
index 0d498e9..50a39b4 100755 (executable)
@@ -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 () {