From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH dlm/next 1/2] fs: dlm: plock debugfs to check for pending operations
Date: Wed, 24 May 2023 13:19:31 -0400 [thread overview]
Message-ID: <20230524171932.1132564-1-aahringo@redhat.com> (raw)
In the past issues were found that there were still ongoing plock
operations in the kernel but it should cleanup routines should clear
them up because there were no plock activity by the user anymore. To
check that "dlm_tool plocks $LS" can be used, but this only shows
pending operations in dlm_controld daemon. To check the kernel part, if
the kernel waits for an answer of the user space, this patch introduces
a debugfs entry which reports if there are ongoing plock operations or
not.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/debug_fs.c | 26 ++++++++++++++++++++++++++
fs/dlm/dlm_internal.h | 5 +++++
fs/dlm/plock.c | 15 +++++++++++++++
3 files changed, 46 insertions(+)
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index a1aca41c49d0..494a6e73f8e8 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -25,6 +25,7 @@ static struct mutex debug_buf_lock;
static struct dentry *dlm_root;
static struct dentry *dlm_comms;
+static struct dentry *dlm_plock;
static char *print_lockmode(int mode)
{
@@ -883,6 +884,30 @@ void dlm_delete_debug_comms_file(void *ctx)
debugfs_remove(ctx);
}
+static int dlm_plock_ops_pending_show(struct seq_file *file, void *offset)
+{
+ seq_printf(file, "%d\n", dlm_plock_ops_pending());
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(dlm_plock_ops_pending);
+
+void dlm_create_debug_plock_file(void)
+{
+ /* TODO currently use case if only to look if everything got cleaned
+ * up probably if user space dlm_tool plocks $LS shows no activity
+ * anymore on all lockspaces.
+ *
+ * However in future a dump could be useful as well.
+ */
+ debugfs_create_file("plock_ops_pending", 0444, dlm_plock, NULL,
+ &dlm_plock_ops_pending_fops);
+}
+
+void dlm_remove_debug_plock_file(void)
+{
+ debugfs_remove(dlm_plock);
+}
+
void dlm_create_debug_file(struct dlm_ls *ls)
{
char name[DLM_LOCKSPACE_LEN + 8];
@@ -943,6 +968,7 @@ void __init dlm_register_debugfs(void)
mutex_init(&debug_buf_lock);
dlm_root = debugfs_create_dir("dlm", NULL);
dlm_comms = debugfs_create_dir("comms", dlm_root);
+ dlm_plock = debugfs_create_dir("plock", dlm_root);
}
void dlm_unregister_debugfs(void)
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index 986a9d7b1f33..f5f741ee527b 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -805,6 +805,7 @@ static inline void dlm_set_sbflags_val(struct dlm_lkb *lkb, uint32_t val)
__DLM_SBF_MAX_BIT);
}
+int dlm_plock_ops_pending(void);
int dlm_plock_init(void);
void dlm_plock_exit(void);
@@ -815,6 +816,8 @@ void dlm_create_debug_file(struct dlm_ls *ls);
void dlm_delete_debug_file(struct dlm_ls *ls);
void *dlm_create_debug_comms_file(int nodeid, void *data);
void dlm_delete_debug_comms_file(void *ctx);
+void dlm_create_debug_plock_file(void);
+void dlm_remove_debug_plock_file(void);
#else
static inline void dlm_register_debugfs(void) { }
static inline void dlm_unregister_debugfs(void) { }
@@ -822,6 +825,8 @@ static inline void dlm_create_debug_file(struct dlm_ls *ls) { }
static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
static inline void *dlm_create_debug_comms_file(int nodeid, void *data) { return NULL; }
static inline void dlm_delete_debug_comms_file(void *ctx) { }
+static inline void dlm_create_debug_plock_file(void) { };
+static inline void dlm_remove_debug_plock_file(void) { };
#endif
#endif /* __DLM_INTERNAL_DOT_H__ */
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index 53d17dbbb716..d6ec70547b77 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -35,6 +35,18 @@ struct plock_op {
struct plock_async_data *data;
};
+int dlm_plock_ops_pending(void)
+{
+ int rv;
+
+ spin_lock(&ops_lock);
+ rv = !list_empty(&send_list);
+ rv |= !list_empty(&recv_list);
+ spin_unlock(&ops_lock);
+
+ return rv;
+}
+
static inline void set_version(struct dlm_plock_info *info)
{
info->version[0] = DLM_PLOCK_VERSION_MAJOR;
@@ -509,11 +521,14 @@ int dlm_plock_init(void)
rv = misc_register(&plock_dev_misc);
if (rv)
log_print("dlm_plock_init: misc_register failed %d", rv);
+
+ dlm_create_debug_plock_file();
return rv;
}
void dlm_plock_exit(void)
{
+ dlm_remove_debug_plock_file();
misc_deregister(&plock_dev_misc);
}
--
2.31.1
next reply other threads:[~2023-05-24 17:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 17:19 Alexander Aring [this message]
2023-05-24 17:19 ` [Cluster-devel] [PATCH dlm/next 2/2] fs: dlm: cleanup plock op lookup functionality Alexander Aring
-- strict thread matches above, loose matches on Subject: below --
2023-05-19 15:23 [Cluster-devel] [PATCH dlm/next 1/2] fs: dlm: plock debugfs to check for pending operations Alexander Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230524171932.1132564-1-aahringo@redhat.com \
--to=aahringo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).