From: James Simmons Date: Sun, 5 Feb 2017 01:10:37 +0000 (-0500) Subject: LU-9019 osd: migrate osd-ldiskfs thandle stats to 64 bit time X-Git-Tag: 2.9.53~6 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=74d0cf95c147ac8dc5a1ace9387b92711e5a6a68;ds=sidebyside LU-9019 osd: migrate osd-ldiskfs thandle stats to 64 bit time To avoid the overflow in 2038 issues we migrate the thandle stats from using jiffies to ktime. Change-Id: I57260d55ca7c0921a9115f4717b13724b870826d Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/25161 Tested-by: Jenkins Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index d10626d..c82c26c 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1466,7 +1466,7 @@ enum { */ static void osd_th_alloced(struct osd_thandle *oth) { - oth->oth_alloced = cfs_time_current(); + oth->oth_alloced = ktime_get(); } /** @@ -1474,58 +1474,42 @@ static void osd_th_alloced(struct osd_thandle *oth) */ static void osd_th_started(struct osd_thandle *oth) { - oth->oth_started = cfs_time_current(); + oth->oth_started = ktime_get(); } /** - * Helper function to convert time interval to microseconds packed in - * long int. + * Check whether the we deal with this handle for too long. */ -static long interval_to_usec(cfs_time_t start, cfs_time_t end) +static void __osd_th_check_slow(void *oth, struct osd_device *dev, + ktime_t alloced, ktime_t started, + ktime_t closed) { - struct timeval val; + ktime_t now = ktime_get(); - cfs_duration_usec(cfs_time_sub(end, start), &val); - return val.tv_sec * 1000000 + val.tv_usec; -} + LASSERT(dev != NULL); -/** - * Check whether the we deal with this handle for too long. - */ -static void __osd_th_check_slow(void *oth, struct osd_device *dev, - cfs_time_t alloced, cfs_time_t started, - cfs_time_t closed) -{ - cfs_time_t now = cfs_time_current(); - - LASSERT(dev != NULL); - - lprocfs_counter_add(dev->od_stats, LPROC_OSD_THANDLE_STARTING, - interval_to_usec(alloced, started)); - lprocfs_counter_add(dev->od_stats, LPROC_OSD_THANDLE_OPEN, - interval_to_usec(started, closed)); - lprocfs_counter_add(dev->od_stats, LPROC_OSD_THANDLE_CLOSING, - interval_to_usec(closed, now)); - - if (cfs_time_before(cfs_time_add(alloced, cfs_time_seconds(30)), now)) { - CWARN("transaction handle %p was open for too long: " - "now "CFS_TIME_T" ," - "alloced "CFS_TIME_T" ," - "started "CFS_TIME_T" ," - "closed "CFS_TIME_T"\n", + lprocfs_counter_add(dev->od_stats, LPROC_OSD_THANDLE_STARTING, + ktime_us_delta(started, alloced)); + lprocfs_counter_add(dev->od_stats, LPROC_OSD_THANDLE_OPEN, + ktime_us_delta(closed, started)); + lprocfs_counter_add(dev->od_stats, LPROC_OSD_THANDLE_CLOSING, + ktime_us_delta(now, closed)); + + if (ktime_before(ktime_add_ns(alloced, 30 * NSEC_PER_SEC), now)) { + CWARN("transaction handle %p was open for too long: now %lld, alloced %lld, started %lld, closed %lld\n", oth, now, alloced, started, closed); libcfs_debug_dumpstack(NULL); } } -#define OSD_CHECK_SLOW_TH(oth, dev, expr) \ -{ \ - cfs_time_t __closed = cfs_time_current(); \ - cfs_time_t __alloced = oth->oth_alloced; \ - cfs_time_t __started = oth->oth_started; \ - \ - expr; \ - __osd_th_check_slow(oth, dev, __alloced, __started, __closed); \ +#define OSD_CHECK_SLOW_TH(oth, dev, expr) \ +{ \ + ktime_t __closed = ktime_get(); \ + ktime_t __alloced = oth->oth_alloced; \ + ktime_t __started = oth->oth_started; \ + \ + expr; \ + __osd_th_check_slow(oth, dev, __alloced, __started, __closed); \ } #else /* OSD_THANDLE_STATS */ diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index 453580f..90fa9a2 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -360,10 +360,10 @@ struct osd_thandle { struct lquota_trans *ot_quota_trans; #if OSD_THANDLE_STATS /** time when this handle was allocated */ - cfs_time_t oth_alloced; + ktime_t oth_alloced; /** time when this thanle was started */ - cfs_time_t oth_started; + ktime_t oth_started; #endif };