]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ocfs2/cluster: Fix output in file elapsed_time_in_ms
authorSunil Mushran <sunil.mushran@oracle.com>
Wed, 22 Jun 2011 23:56:14 +0000 (16:56 -0700)
committerMaxim Uvarov <maxim.uvarov@oracle.com>
Thu, 29 Mar 2012 18:17:09 +0000 (11:17 -0700)
The o2hb debugfs file, elapsed_time_in_ms, should return values only after the
timer is armed for the time time.

Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
fs/ocfs2/cluster/heartbeat.c

index 9a3e6bbff27bd4839b487c2c14282fd9ef1a4675..fc365465fd065fac644101a0ac4c13dd99530ae6 100644 (file)
@@ -1158,6 +1158,7 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)
        struct o2hb_debug_buf *db = inode->i_private;
        struct o2hb_region *reg;
        unsigned long map[BITS_TO_LONGS(O2NM_MAX_NODES)];
+       unsigned long lts;
        char *buf = NULL;
        int i = -1;
        int out = 0;
@@ -1194,9 +1195,11 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)
 
        case O2HB_DB_TYPE_REGION_ELAPSED_TIME:
                reg = (struct o2hb_region *)db->db_data;
-               out += snprintf(buf + out, PAGE_SIZE - out, "%u\n",
-                               jiffies_to_msecs(jiffies -
-                                                reg->hr_last_timeout_start));
+               lts = reg->hr_last_timeout_start;
+               /* If 0, it has never been set before */
+               if (lts)
+                       lts = jiffies_to_msecs(jiffies - lts);
+               out += snprintf(buf + out, PAGE_SIZE - out, "%lu\n", lts);
                goto done;
 
        case O2HB_DB_TYPE_REGION_PINNED: