Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3862142ybi; Mon, 10 Jun 2019 18:55:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkUW+ZVNxRLg3aGy2G/yrdcBcXzDDMhhDnNd2+qHyEf6jMEdOvSx9xC/aPNjbZTl1hyeLt X-Received: by 2002:a17:90a:2ec1:: with SMTP id h1mr22929921pjs.101.1560218158868; Mon, 10 Jun 2019 18:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560218158; cv=none; d=google.com; s=arc-20160816; b=gQQdFOssNZRDp/bSZF+pKLYvuKHeKigxwon27gOYfx9Cyd2mM8B9SHLhAAanjENzWY 6wtQfzXeuUasKpFkOMrXdslF/Esk7bCytmIWr2yeEb+dZssu61MHf9YB76szAWgJzHzs 13Zu7Qam1JKypZr5ovr6YVHC0XV3so9kSHvuSdoUlGFaMeP5ZxQd7awBxZkHBVdoI7P9 lhwrifijMYBXskBvUyhMTcTqGDIB+TFIqxF97I+VAMtwBgetonXjA4sZ6ulCI4KVqjtk Q9JgEzQMR9hQpVNdreljwGhYW2u3OJNxhwIoKqtRCDxIc03oWiNdeLP0r7biDi7Wsn4i rDpA== 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=dmvdWDW75DpJEoZTYNvFzvDzNe4/mdBj+gp/jk2xBaA=; b=gYzguS1+BVo01Fs8D4hCtywOjU7oFnWUZpImo7NFQGXZsiIQ4Lxc3ly2y81E2q2nK2 SRfW/scp/mHXDa0D29Bym7kgUg0FhLgRy37nLPICAOVhI8zlbV5RXmDxDbzVZjCCVjK4 DwK+SfFWWn5vB5X3D3eYYldl79Fz/MBleF3uU+EiAV7Lggr18wS1imyQpJDw9fULBffl lPE///8DXPbl2dRMejZUJlAmByqKrjaXvucPfUfbfuoyjNMpMY/0T8SwWDtE8HDbLmIH Pned1n/vo85WxIQEff6t/4W8LXoMBnph4ixLAOFxXwrRB8PEf5GBvO9bIssu2nDrYVXT 4JiA== 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 c24si10195568pfd.105.2019.06.10.18.55.43; Mon, 10 Jun 2019 18:55:58 -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 S2390473AbfFKByn (ORCPT + 99 others); Mon, 10 Jun 2019 21:54:43 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:53687 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390388AbfFKByn (ORCPT ); Mon, 10 Jun 2019 21:54:43 -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:31 -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 2/3] ocfs2: add locking filter debugfs file Date: Tue, 11 Jun 2019 09:54:13 +0800 Message-Id: <20190611015414.27754-2-ghe@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20190611015414.27754-1-ghe@suse.com> References: <20190611015414.27754-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. Compared with v3, I need to do the related change since last lock/unlock uses wall time in microsecond. secondly, adjust CONFIG_OCFS2_FS_STATS macro positions. Compared with v2, ocfs2_dlm_init_debug() returns directly with error when creating locking filter debugfs file is failed, since ocfs2_dlm_shutdown_debug() will handle this failure perfectly. Compared with v1, the main change is to add CONFIG_OCFS2_FS_STATS macro definition judgment. Signed-off-by: Gang He Reviewed-by: Joseph Qi --- fs/ocfs2/dlmglue.c | 38 ++++++++++++++++++++++++++++++++++++++ fs/ocfs2/ocfs2.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 3b0e7d399df2..d4caa6d117c6 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c @@ -3005,6 +3005,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,10 +3106,34 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) int i; char *lvb; struct ocfs2_lock_res *lockres = v; +#ifdef CONFIG_OCFS2_FS_STATS + u64 now, last; + struct ocfs2_dlm_debug *dlm_debug = + ((struct ocfs2_dlm_seq_priv *)m->private)->p_dlm_debug; +#endif if (!lockres) return -EINVAL; +#ifdef CONFIG_OCFS2_FS_STATS + if (dlm_debug->d_filter_secs) { + now = ktime_to_us(ktime_get_real()); + 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 ((now - last) / 1000000 > dlm_debug->d_filter_secs) + return 0; + } +#endif + seq_printf(m, "0x%x\t", OCFS2_DLM_DEBUG_STR_VERSION); if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY) @@ -3257,6 +3283,17 @@ 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"); + goto out; + } + ocfs2_get_dlm_debug(dlm_debug); out: return ret; @@ -3268,6 +3305,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 6f43651f01b3..6d0a77703d0e 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