From 1475553456c74f25022351ea9670d73b45863e38 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Thu, 27 Jan 2022 16:43:21 -0500 Subject: [PATCH] LU-12585 mdt: Add read/write latency to MDT stats The MDT does not currently record latency stats for reads and writes. Add this, and change the naming to be the same as for the OFD. Note on this: Existing naming on the MDT uses "read/write" instead of "{read,write}_bytes", which is inconsistent with OFD and also inconsistent within the MDT, since other ops without the "_bytes" suffix are latency. It's not deal to change the names of existing stats, but I decided this was less problematic than leaving them inconsistent. Lustre-change: https://review.whamcloud.com/46229/ Lustre-commit: ab1f7876b4b9e81738b1357395289aab76124255 (tbd) Signed-off-by: Patrick Farrell Change-Id: I7b7a5742678cbe0269086f37877833e877a5ca5f Reviewed-on: https://review.whamcloud.com/46230 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_internal.h | 2 ++ lustre/mdt/mdt_io.c | 8 ++++++-- lustre/mdt/mdt_lproc.c | 9 ++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 85824de8..b921ecf 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -1302,6 +1302,8 @@ enum mdt_stat_idx { LPROC_MDT_CROSSDIR_RENAME, LPROC_MDT_IO_READ, LPROC_MDT_IO_WRITE, + LPROC_MDT_IO_READ_BYTES, + LPROC_MDT_IO_WRITE_BYTES, LPROC_MDT_IO_PUNCH, LPROC_MDT_MIGRATE, LPROC_MDT_LAST, diff --git a/lustre/mdt/mdt_io.c b/lustre/mdt/mdt_io.c index 0a021d2..0e1dbb4 100644 --- a/lustre/mdt/mdt_io.c +++ b/lustre/mdt/mdt_io.c @@ -781,7 +781,9 @@ int mdt_obd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, la_from_obdo(la, oa, valid); - mdt_counter_incr(req, LPROC_MDT_IO_WRITE, nob); + mdt_counter_incr(req, LPROC_MDT_IO_WRITE_BYTES, nob); + mdt_counter_incr(req, LPROC_MDT_IO_WRITE, + ktime_us_delta(ktime_get(), kstart)); rc = mdt_commitrw_write(env, exp, mdt, mo, la, oa, objcount, npages, lnb, oa->o_grant_used, old_rc); @@ -836,7 +838,9 @@ int mdt_obd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, if (oa) mdt_dom_obj_lvb_update(env, mo, true); - mdt_counter_incr(req, LPROC_MDT_IO_READ, nob); + mdt_counter_incr(req, LPROC_MDT_IO_READ_BYTES, nob); + mdt_counter_incr(req, LPROC_MDT_IO_READ, + ktime_us_delta(ktime_get(), kstart)); rc = mdt_commitrw_read(env, mdt, mo, objcount, npages, lnb); if (old_rc) diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 51637e6..4097088 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -1482,8 +1482,10 @@ static const char * const mdt_stats[] = { [LPROC_MDT_SYNC] = "sync", [LPROC_MDT_SAMEDIR_RENAME] = "samedir_rename", [LPROC_MDT_CROSSDIR_RENAME] = "crossdir_rename", - [LPROC_MDT_IO_READ] = "read_bytes", - [LPROC_MDT_IO_WRITE] = "write_bytes", + [LPROC_MDT_IO_READ_BYTES] = "read_bytes", + [LPROC_MDT_IO_WRITE_BYTES] = "write_bytes", + [LPROC_MDT_IO_READ] = "read", + [LPROC_MDT_IO_WRITE] = "write", [LPROC_MDT_IO_PUNCH] = "punch", [LPROC_MDT_MIGRATE] = "migrate", }; @@ -1498,7 +1500,8 @@ void mdt_stats_counter_init(struct lprocfs_stats *stats, unsigned int offset) for (midx = 0; midx < array_size; midx++) { oidx = midx + offset; - if (midx == LPROC_MDT_IO_READ || midx == LPROC_MDT_IO_WRITE) + if (midx == LPROC_MDT_IO_READ_BYTES || + midx == LPROC_MDT_IO_WRITE_BYTES) lprocfs_counter_init(stats, oidx, LPROCFS_TYPE_BYTES_FULL, mdt_stats[midx], "bytes"); -- 1.8.3.1