Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3862257ybi; Mon, 10 Jun 2019 18:56:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXhlsjGV6gd57bI9y+2dmaTecOieOGZ53Z25sZro03cU4pdOdZk4/S5j0858ErNwNQaXzv X-Received: by 2002:a17:902:76c6:: with SMTP id j6mr48527266plt.263.1560218171299; Mon, 10 Jun 2019 18:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560218171; cv=none; d=google.com; s=arc-20160816; b=EaYVfmfPNmo1TSxtkv5kBmbYn6OhItlYjIU3x7sX2pLQOL8NK+kRoymRYcrdY2qZEe qsrHk7PwU+w4rdEIGE4EUXKV58BtWwJWdUM16H3jYyVsq9sv61iEA1vmQhMpJmrR4Ugl fClUKjkDwULOJH+THarLYF5cDZUsAqPcpvVxmcu5WGoXRH8oB59CfjaRTQ7HoNatQDdU dFMtBqFHLaxumJEZ/dA7CKvOgxFWzMakCuXWPrPyuOOyn5Ud1hrrjkb9+woffsPbMFup xxl3Ec0NOSmD0Lj1VXQD5KuVlou1mw2Ht2apuAaDftvWiLf9KWP9zMZENsYDg61bq91b 2CiQ== 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=Y0FaY76jSn29O3sSJ6nfXrOrEMw3psZmPoBPdLPaLu4=; b=QSM78/5ZBmfK0sboEZPa9tAjRhDAFG1GGfZSky0N3LHrSZ5Q/RfCZryGYK0krmq53V CgoTuNdN4AL66gR+qDpmf1rssRyq4+Op1eni37Ko0GOR1Ib+LgqE2IwLF90wTxGWRD2g 3QYX+u/8lAJu3ZJRJMZGSOrZDqLQzyy/U/ZPfMZIaL3WBeVY1twcPHzNzeZ40llvnyti 8YXO5BtpyAqgBtBTcRCoFNeRBn1UAw9O6kHsX5m4VwvmOUPX6HYmQj7fQLekABteffYS v4lRoVVUH6q+A0spCEIn3x3HtCVkcK6Zx2aHMcCXsNL+PbOF8f+B1GdsEecrNfDTtZBq GF1A== 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 d185si11601595pfa.182.2019.06.10.18.55.56; Mon, 10 Jun 2019 18:56:11 -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 S2390244AbfFKBye (ORCPT + 99 others); Mon, 10 Jun 2019 21:54:34 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:47114 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbfFKByd (ORCPT ); Mon, 10 Jun 2019 21:54:33 -0400 Received: from ghe-pc.suse.asia (prva10-snat226-1.provo.novell.com [137.65.226.35]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Mon, 10 Jun 2019 19:54:27 -0600 From: Gang He To: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com Cc: Gang He , linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com, akpm@linux-foundation.org Subject: [PATCH V4 1/3] ocfs2: add last unlock times in locking_state Date: Tue, 11 Jun 2019 09:54:12 +0800 Message-Id: <20190611015414.27754-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. Compared with v1, the main change is to use wall time in microsecond for last pr/ex unlock time. Signed-off-by: Gang He Reviewed-by: Joseph Qi --- fs/ocfs2/dlmglue.c | 18 +++++++++++++++--- fs/ocfs2/ocfs2.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index af405586c5b1..3b0e7d399df2 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -474,6 +474,8 @@ static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level, if (ret) stats->ls_fail++; + + stats->ls_last = ktime_to_us(ktime_get_real()); } static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) @@ -3093,8 +3095,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 usecs */ -#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 +3149,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 +3161,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) (0ULL) +# define lock_last_exmode(_l) (0ULL) #endif /* The following seq_print was added in version 2 of this output */ seq_printf(m, "%u\t" @@ -3165,7 +3173,9 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) "%llu\t" "%u\t" "%u\t" - "%u\t", + "%u\t" + "%llu\t" + "%llu\t", lock_num_prmode(lockres), lock_num_exmode(lockres), lock_num_prmode_failed(lockres), @@ -3174,7 +3184,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..6f43651f01b3 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 */ + u64 ls_last; /* Last unlock time in USEC */ }; #endif -- 2.21.0