From patchwork Sun Aug 9 01:25:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhilash Jindal X-Patchwork-Id: 7025701 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9C790C05AC for ; Mon, 17 Aug 2015 16:06:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71CD220549 for ; Mon, 17 Aug 2015 16:06:50 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B778D2053E for ; Mon, 17 Aug 2015 16:06:48 +0000 (UTC) Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t7HG62pO015376 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Aug 2015 16:06:04 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t7HG5xuv002455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 17 Aug 2015 16:05:59 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1ZRMv9-00072S-4H; Mon, 17 Aug 2015 09:05:59 -0700 Received: from userv0022.oracle.com ([156.151.31.74]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1ZOFMo-0004Dn-JB for ocfs2-devel@oss.oracle.com; Sat, 08 Aug 2015 18:25:38 -0700 Received: from aserp1020.oracle.com (aserp1020.oracle.com [141.146.126.67]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t791Pbcc001352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 9 Aug 2015 01:25:37 GMT Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserp1020.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t791PaPS005906 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 9 Aug 2015 01:25:37 GMT Authentication-Results: aserp1020.oracle.com; dkim=pass reason="2048-bit key" header.d=gmail.com header.i=@gmail.com header.b=G/o/dNoS Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.15.0.59/8.15.0.59) with SMTP id t791Nc6T029875 for ; Sun, 9 Aug 2015 01:25:36 GMT Received: from mail-io0-f179.google.com (mail-io0-f179.google.com [209.85.223.179]) by userp2040.oracle.com with ESMTP id 1w5j22sck1-1 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Sun, 09 Aug 2015 01:25:36 +0000 Received: by ioeg141 with SMTP id g141so141974991ioe.3 for ; Sat, 08 Aug 2015 18:25:35 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.156.195 with SMTP id f186mr15270506ioe.177.1439083535469; Sat, 08 Aug 2015 18:25:35 -0700 (PDT) Received: by 10.79.5.84 with HTTP; Sat, 8 Aug 2015 18:25:35 -0700 (PDT) Date: Sat, 8 Aug 2015 21:25:35 -0400 Message-ID: From: Abhilash Jindal To: ocfs2-devel@oss.oracle.com X-ServerName: mail-io0-f179.google.com X-Proofpoint-Virus-Version: vendor=nai engine=5700 definitions=7887 signatures=670623 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1506180000 definitions=main-1508090024 X-Mailman-Approved-At: Mon, 17 Aug 2015 09:05:58 -0700 Cc: mfasheh@suse.com Subject: [Ocfs2-devel] ocfs2: use boot time instead of wall clock time X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: userv0022.oracle.com [156.151.31.74] X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Wall time obtained from do_gettimeofday is susceptible to sudden jumps due to user setting the time or due to NTP. Boot time is constantly increasing time better suited for comparing two timestamps. --- fs/ocfs2/cluster/heartbeat.c | 45 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 363f0dc..a1f6ba2 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -291,6 +291,7 @@ static int o2hb_pop_count(void *map, int count) return pop; } + static void o2hb_write_timeout(struct work_struct *work) { int failed, quorum; @@ -1083,35 +1084,11 @@ bail: return ret; } -/* Subtract b from a, storing the result in a. a *must* have a larger - * value than b. */ -static void o2hb_tv_subtract(struct timeval *a, - struct timeval *b) -{ - /* just return 0 when a is after b */ - if (a->tv_sec < b->tv_sec || - (a->tv_sec == b->tv_sec && a->tv_usec < b->tv_usec)) { - a->tv_sec = 0; - a->tv_usec = 0; - return; - } - - a->tv_sec -= b->tv_sec; - a->tv_usec -= b->tv_usec; - while ( a->tv_usec < 0 ) { - a->tv_sec--; - a->tv_usec += 1000000; - } -} - -static unsigned int o2hb_elapsed_msecs(struct timeval *start, - struct timeval *end) -{ - struct timeval res = *end; - - o2hb_tv_subtract(&res, start); - - return res.tv_sec * 1000 + res.tv_usec / 1000; +static unsigned int o2hb_elapsed_msecs(struct timespec *start, + struct timespec *end) { + struct timespec res; + res = timespec_sub(*end, *start); + return res.tv_sec* MSEC_PER_SEC + res.tv_nsec/NSEC_PER_MSEC; } /* @@ -1124,7 +1101,7 @@ static int o2hb_thread(void *data) int i, ret; struct o2hb_region *reg = data; struct o2hb_bio_wait_ctxt write_wc; - struct timeval before_hb, after_hb; + struct timespec before_hb, after_hb; unsigned int elapsed_msec; mlog(ML_HEARTBEAT|ML_KTHREAD, "hb thread running\n"); @@ -1141,17 +1118,17 @@ static int o2hb_thread(void *data) * hr_timeout_ms between disk writes. On busy systems * this should result in a heartbeat which is less * likely to time itself out. */ - do_gettimeofday(&before_hb); + getboottime(&before_hb); ret = o2hb_do_disk_heartbeat(reg); - do_gettimeofday(&after_hb); + getboottime(&after_hb); elapsed_msec = o2hb_elapsed_msecs(&before_hb, &after_hb); mlog(ML_HEARTBEAT, "start = %lu.%lu, end = %lu.%lu, msec = %u\n", - before_hb.tv_sec, (unsigned long) before_hb.tv_usec, - after_hb.tv_sec, (unsigned long) after_hb.tv_usec, + before_hb.tv_sec, (unsigned long) before_hb.tv_nsec/NSEC_PER_USEC, + after_hb.tv_sec, (unsigned long) after_hb.tv_nsec/NSEC_PER_USEC, elapsed_msec); if (!kthread_should_stop() &&