Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3334073yba; Sun, 28 Apr 2019 23:48:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWYlfp5l3aZ4hjJW8gq7MOnKc8OBHAKhbfJYt8xRe9Ykt8pGiua+YWVgo+X06GX2jHcFdg X-Received: by 2002:a17:902:a01:: with SMTP id 1mr59891746plo.36.1556520519663; Sun, 28 Apr 2019 23:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556520519; cv=none; d=google.com; s=arc-20160816; b=omDULJQ1U64HYVUSWHCssC2W8T21GpTwucS+QI/4NqI5653nku6N0mym/Jks14eJvR E+hdtorh/PvQsOFFamPXLQF6bKJWulbf4LuD3VrWrFcjJIrAr9qdenh0X9llCZOwuDVs P93X0IyTrmGJcv9LkY6KEnWbukhUmJCYDSrNPtf2PzjnsEKto5qxr7R8SjqdY27AaaCX 8yF6ZSepo0k40/XYc5WykbUcHAqh0xYZ2maxPDrqcDhqhzxwnSBAUgWufD1fMcwxfW/v 8Ozu8U4JuaU12J5fs1xRVJsfKxcB9xU+sInIJEqRNicMNj8X4Mlh/uecDwl5LwyTPTMM O1IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=gRRNDvDKsw4yHekyYV6jWwvhcuXOU7vkZb3Oh+4vGnw=; b=KqYEoGu6XQR+qX336z1v5lAI5qfiMkAiqvwSMLz/geM2jrq90OgHNHqpx0bNwVkYEr ub6cWlB116rfoOqmV97stHs01ItuM1CDr3AM3mwtitcW5ANa7TL7R0GkJnuggR65ZKlU Rv7BOJk1xharD9uAYwfPCq3kYYZEnZkIGdanCJv9JlfFdrzU35pS7dgKhsV6goLZHcGO Tli78V7eFjcWODNAshYMcm9JdvtOzkOV6ehnRo8CAjV/9FQKFe8yb6ZVHNbIoSOzJShX 7aQiKgZyvrWpR8gKysZ+4rU6kGYf01ej1bvJ+njTUoRYVVDRuq7CoH4QZykFEL3uOPek QcEQ== 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 z4si31583403plk.385.2019.04.28.23.48.24; Sun, 28 Apr 2019 23:48:39 -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 S1727428AbfD2Gq3 (ORCPT + 99 others); Mon, 29 Apr 2019 02:46:29 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:59745 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726846AbfD2Gq3 (ORCPT ); Mon, 29 Apr 2019 02:46:29 -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, 29 Apr 2019 00:46:17 -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 2/2] ocfs2: add locking filter debugfs file Date: Mon, 29 Apr 2019 14:46:13 +0800 Message-Id: <20190429064613.29365-2-ghe@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20190429064613.29365-1-ghe@suse.com> References: <20190429064613.29365-1-ghe@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add locking filter debugfs file, which is used to filter lock resources dump from locking_state debugfs file. We use d_filter_secs field to filter lock resources dump, the default d_filter_secs(0) value filters nothing, otherwise, only dump the last N seconds active lock resources. This enhancement can avoid dumping lots of old records. The d_filter_secs value can be changed via locking_filter file. Signed-off-by: Gang He --- fs/ocfs2/dlmglue.c | 33 +++++++++++++++++++++++++++++++++ fs/ocfs2/ocfs2.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index dccf4136f8c1..2f36fe40295c 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -3006,6 +3006,8 @@ struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void) kref_init(&dlm_debug->d_refcnt); INIT_LIST_HEAD(&dlm_debug->d_lockres_tracking); dlm_debug->d_locking_state = NULL; + dlm_debug->d_locking_filter = NULL; + dlm_debug->d_filter_secs = 0; out: return dlm_debug; } @@ -3104,11 +3106,28 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) { int i; char *lvb; + u32 now, last; struct ocfs2_lock_res *lockres = v; + struct ocfs2_dlm_debug *dlm_debug = + ((struct ocfs2_dlm_seq_priv *)m->private)->p_dlm_debug; if (!lockres) return -EINVAL; + now = ktime_to_timespec(ktime_get()).tv_sec; + if (lockres->l_lock_prmode.ls_last > lockres->l_lock_exmode.ls_last) + last = lockres->l_lock_prmode.ls_last; + else + last = lockres->l_lock_exmode.ls_last; + + /* + * Use d_filter_secs field to filter lock resources dump, + * the default d_filter_secs(0) value filters nothing, + * otherwise, only dump the last N seconds active lock resources. + */ + if (dlm_debug->d_filter_secs && (now - last) > dlm_debug->d_filter_secs) + return 0; + seq_printf(m, "0x%x\t", OCFS2_DLM_DEBUG_STR_VERSION); if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY) @@ -3258,6 +3277,19 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb) goto out; } + dlm_debug->d_locking_filter = debugfs_create_u32("locking_filter", + 0600, + osb->osb_debug_root, + &dlm_debug->d_filter_secs); + if (!dlm_debug->d_locking_filter) { + ret = -EINVAL; + mlog(ML_ERROR, + "Unable to create locking filter debugfs file.\n"); + debugfs_remove(dlm_debug->d_locking_state); + dlm_debug->d_locking_state = NULL; + goto out; + } + ocfs2_get_dlm_debug(dlm_debug); out: return ret; @@ -3269,6 +3301,7 @@ static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb) if (dlm_debug) { debugfs_remove(dlm_debug->d_locking_state); + debugfs_remove(dlm_debug->d_locking_filter); ocfs2_put_dlm_debug(dlm_debug); } } diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 8efa022684f4..f4da51099889 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -237,6 +237,8 @@ struct ocfs2_orphan_scan { struct ocfs2_dlm_debug { struct kref d_refcnt; struct dentry *d_locking_state; + struct dentry *d_locking_filter; + u32 d_filter_secs; struct list_head d_lockres_tracking; }; -- 2.21.0