Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1774729yba; Thu, 25 Apr 2019 05:38:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqye0QdxB1yXn0GUOMZrYO1RHT+NhoQOiOCqvUUJWpcj9tqlL+wh8ChsH9LKPMcC9m0dewsY X-Received: by 2002:a65:6392:: with SMTP id h18mr36493388pgv.273.1556195893903; Thu, 25 Apr 2019 05:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556195893; cv=none; d=google.com; s=arc-20160816; b=YXVZr2Vy2cJ6nfOTYIxuGNWh2zV9Kvlr9Q7xiPYwyTwjd8hnmsTduAK8BiuxLjFiu8 wPrG0g3Lw+B3LgdJ5bfe2tzR35fHvw60vwG0LGKoCcANKzNW14iRx8wTWCIVOlh+F4cv aL/kQtTlCewKVfV+vCCYne2zgR0nFETr6gLspmnlcKWV6vPeOz+JAihFsQwypbs6acth dug15dtUSbsw3p2ccL5jcaeoKRwMhcXKOq0btdp5ZlcIsCQTy+sndn4ww+9SV1VfxVRi pi9BIKGKmwvL8KP0NRCboJQFcvnxz48fs3rdlsOiVWRtJiTyA7K1LerqqpttFS4ZSB3p GpAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=UKMMFrBJeEwb3f+mqDQ3s90beq/3sbp3y9+ubjcovHk=; b=jIPknYtH6t2yCTk0QDhCkTP6hARjrvH7P/hZPrln7CpqB2CmDPSTU0DtSGFna5w1Mx +ayOX6KMIZFE60Vdtp11N5OKck0MsXcMqI0SVk/TzhIeD0s711LhiX3kno5MYc5FUxPU Cp5POZzG3JVbHSQuZU2LoWHLs0a+ZDuI8iFE5hRoW7byUGYG3ZzHtRg/kdPFybYTI7Hb xI4N5iDywzI5JgE9i6OwawfenB8/MUYQTLyqs+6H3HWOPHxv5N+MuMvhT9sn629epzGY 0SkA4fZvykl1Xg5g/Q+94xy6XPZT1nrPmth79Ylt8I9zVrOKPL4qWT7Ny2hj0s5/MXi8 Jw7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si9036893pgt.259.2019.04.25.05.37.57; Thu, 25 Apr 2019 05:38:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbfDYJNG (ORCPT + 99 others); Thu, 25 Apr 2019 05:13:06 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:37344 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbfDYJNG (ORCPT ); Thu, 25 Apr 2019 05:13:06 -0400 Received: from ghe-pc.suse.asia (prva10-snat226-2.provo.novell.com [137.65.226.36]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Thu, 25 Apr 2019 03:12:53 -0600 From: Gang He To: mark@fasheh.com, jlbec@evilplan.org, jiangqi903@gmail.com Cc: Gang He , linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com, akpm@linux-foundation.org Subject: [PATCH] ocfs2: add last unlock times in locking_state Date: Thu, 25 Apr 2019 17:12:50 +0800 Message-Id: <20190425091250.3625-1-ghe@suse.com> X-Mailer: git-send-email 2.12.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ocfs2 file system uses locking_state file under debugfs to dump each ocfs2 file system's dlm lock resources, but the dlm lock resources in memory are becoming more and more after the files were touched by the user. it will become a bit difficult to analyze these dlm lock resource records in locking_state file by the upper scripts, though some files are not active for now, which were accessed long time ago. Then, I'd like to add last pr/ex unlock times in locking_state file for each dlm lock resource record, the the upper scripts can use last unlock time to filter inactive dlm lock resource record. Signed-off-by: Gang He --- fs/ocfs2/dlmglue.c | 21 +++++++++++++++++---- fs/ocfs2/ocfs2.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index af405586c5b1..dccf4136f8c1 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -448,7 +448,7 @@ static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level, struct ocfs2_mask_waiter *mw, int ret) { u32 usec; - ktime_t kt; + ktime_t last, kt; struct ocfs2_lock_stats *stats; if (level == LKM_PRMODE) @@ -458,7 +458,8 @@ static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level, else return; - kt = ktime_sub(ktime_get(), mw->mw_lock_start); + last = ktime_get(); + kt = ktime_sub(last, mw->mw_lock_start); usec = ktime_to_us(kt); stats->ls_gets++; @@ -474,6 +475,8 @@ static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level, if (ret) stats->ls_fail++; + + stats->ls_last = ktime_to_timespec(last).tv_sec; } static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) @@ -3093,8 +3096,10 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) * - Lock stats printed * New in version 3 * - Max time in lock stats is in usecs (instead of nsecs) + * New in version 4 + * - Add last pr/ex unlock times in secs */ -#define OCFS2_DLM_DEBUG_STR_VERSION 3 +#define OCFS2_DLM_DEBUG_STR_VERSION 4 static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) { int i; @@ -3145,6 +3150,8 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) # define lock_max_prmode(_l) ((_l)->l_lock_prmode.ls_max) # define lock_max_exmode(_l) ((_l)->l_lock_exmode.ls_max) # define lock_refresh(_l) ((_l)->l_lock_refresh) +# define lock_last_prmode(_l) ((_l)->l_lock_prmode.ls_last) +# define lock_last_exmode(_l) ((_l)->l_lock_exmode.ls_last) #else # define lock_num_prmode(_l) (0) # define lock_num_exmode(_l) (0) @@ -3155,6 +3162,8 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) # define lock_max_prmode(_l) (0) # define lock_max_exmode(_l) (0) # define lock_refresh(_l) (0) +# define lock_last_prmode(_l) (0) +# define lock_last_exmode(_l) (0) #endif /* The following seq_print was added in version 2 of this output */ seq_printf(m, "%u\t" @@ -3165,6 +3174,8 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) "%llu\t" "%u\t" "%u\t" + "%u\t" + "%u\t" "%u\t", lock_num_prmode(lockres), lock_num_exmode(lockres), @@ -3174,7 +3185,9 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) lock_total_exmode(lockres), lock_max_prmode(lockres), lock_max_exmode(lockres), - lock_refresh(lockres)); + lock_refresh(lockres), + lock_last_prmode(lockres), + lock_last_exmode(lockres)); /* End the line */ seq_printf(m, "\n"); diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 1f029fbe8b8d..8efa022684f4 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -164,6 +164,7 @@ struct ocfs2_lock_stats { /* Storing max wait in usecs saves 24 bytes per inode */ u32 ls_max; /* Max wait in USEC */ + u32 ls_last; /* Last unlock time in SEC */ }; #endif -- 2.21.0