Skip to content

Commit 5b2f981

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: add midcomms debugfs functionality
This patch adds functionality to debug midcomms per connection state inside a comms directory which is similar like dlm configfs. Currently there exists the possibility to read out two attributes which is the send queue counter and the version of each midcomms node state. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 489d8e5 commit 5b2f981

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

fs/dlm/debug_fs.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
#include <linux/slab.h>
1717

1818
#include "dlm_internal.h"
19+
#include "midcomms.h"
1920
#include "lock.h"
2021

2122
#define DLM_DEBUG_BUF_LEN 4096
2223
static char debug_buf[DLM_DEBUG_BUF_LEN];
2324
static struct mutex debug_buf_lock;
2425

2526
static struct dentry *dlm_root;
27+
static struct dentry *dlm_comms;
2628

2729
static char *print_lockmode(int mode)
2830
{
@@ -738,6 +740,57 @@ void dlm_delete_debug_file(struct dlm_ls *ls)
738740
debugfs_remove(ls->ls_debug_toss_dentry);
739741
}
740742

743+
static int dlm_state_show(struct seq_file *file, void *offset)
744+
{
745+
seq_printf(file, "%s\n", dlm_midcomms_state(file->private));
746+
return 0;
747+
}
748+
DEFINE_SHOW_ATTRIBUTE(dlm_state);
749+
750+
static int dlm_flags_show(struct seq_file *file, void *offset)
751+
{
752+
seq_printf(file, "%lu\n", dlm_midcomms_flags(file->private));
753+
return 0;
754+
}
755+
DEFINE_SHOW_ATTRIBUTE(dlm_flags);
756+
757+
static int dlm_send_queue_cnt_show(struct seq_file *file, void *offset)
758+
{
759+
seq_printf(file, "%d\n", dlm_midcomms_send_queue_cnt(file->private));
760+
return 0;
761+
}
762+
DEFINE_SHOW_ATTRIBUTE(dlm_send_queue_cnt);
763+
764+
static int dlm_version_show(struct seq_file *file, void *offset)
765+
{
766+
seq_printf(file, "0x%08x\n", dlm_midcomms_version(file->private));
767+
return 0;
768+
}
769+
DEFINE_SHOW_ATTRIBUTE(dlm_version);
770+
771+
void *dlm_create_debug_comms_file(int nodeid, void *data)
772+
{
773+
struct dentry *d_node;
774+
char name[256];
775+
776+
memset(name, 0, sizeof(name));
777+
snprintf(name, 256, "%d", nodeid);
778+
779+
d_node = debugfs_create_dir(name, dlm_comms);
780+
debugfs_create_file("state", 0444, d_node, data, &dlm_state_fops);
781+
debugfs_create_file("flags", 0444, d_node, data, &dlm_flags_fops);
782+
debugfs_create_file("send_queue_count", 0444, d_node, data,
783+
&dlm_send_queue_cnt_fops);
784+
debugfs_create_file("version", 0444, d_node, data, &dlm_version_fops);
785+
786+
return d_node;
787+
}
788+
789+
void dlm_delete_debug_comms_file(void *ctx)
790+
{
791+
debugfs_remove(ctx);
792+
}
793+
741794
void dlm_create_debug_file(struct dlm_ls *ls)
742795
{
743796
char name[DLM_LOCKSPACE_LEN + 8];
@@ -797,6 +850,7 @@ void __init dlm_register_debugfs(void)
797850
{
798851
mutex_init(&debug_buf_lock);
799852
dlm_root = debugfs_create_dir("dlm", NULL);
853+
dlm_comms = debugfs_create_dir("comms", dlm_root);
800854
}
801855

802856
void dlm_unregister_debugfs(void)

fs/dlm/dlm_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,11 +754,15 @@ void dlm_register_debugfs(void);
754754
void dlm_unregister_debugfs(void);
755755
void dlm_create_debug_file(struct dlm_ls *ls);
756756
void dlm_delete_debug_file(struct dlm_ls *ls);
757+
void *dlm_create_debug_comms_file(int nodeid, void *data);
758+
void dlm_delete_debug_comms_file(void *ctx);
757759
#else
758760
static inline void dlm_register_debugfs(void) { }
759761
static inline void dlm_unregister_debugfs(void) { }
760762
static inline void dlm_create_debug_file(struct dlm_ls *ls) { }
761763
static inline void dlm_delete_debug_file(struct dlm_ls *ls) { }
764+
static inline void *dlm_create_debug_comms_file(int nodeid, void *data) { return NULL; }
765+
static inline void dlm_delete_debug_comms_file(void *ctx) { }
762766
#endif
763767

764768
#endif /* __DLM_INTERNAL_DOT_H__ */

fs/dlm/midcomms.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ struct midcomms_node {
189189
*/
190190
int users;
191191

192+
/* not protected by srcu, node_hash lifetime */
193+
void *debugfs;
194+
192195
struct hlist_node hlist;
193196
struct rcu_head rcu;
194197
};
@@ -244,6 +247,26 @@ static inline const char *dlm_state_str(int state)
244247
}
245248
}
246249

250+
const char *dlm_midcomms_state(struct midcomms_node *node)
251+
{
252+
return dlm_state_str(node->state);
253+
}
254+
255+
unsigned long dlm_midcomms_flags(struct midcomms_node *node)
256+
{
257+
return node->flags;
258+
}
259+
260+
int dlm_midcomms_send_queue_cnt(struct midcomms_node *node)
261+
{
262+
return atomic_read(&node->send_queue_cnt);
263+
}
264+
265+
uint32_t dlm_midcomms_version(struct midcomms_node *node)
266+
{
267+
return node->version;
268+
}
269+
247270
static struct midcomms_node *__find_node(int nodeid, int r)
248271
{
249272
struct midcomms_node *node;
@@ -332,6 +355,8 @@ static struct midcomms_node *nodeid2node(int nodeid, gfp_t alloc)
332355

333356
hlist_add_head_rcu(&node->hlist, &node_hash[r]);
334357
spin_unlock(&nodes_lock);
358+
359+
node->debugfs = dlm_create_debug_comms_file(nodeid, node);
335360
return node;
336361
}
337362

@@ -1285,6 +1310,8 @@ void dlm_midcomms_shutdown(void)
12851310
hlist_for_each_entry_rcu(node, &node_hash[i], hlist) {
12861311
midcomms_shutdown(node);
12871312

1313+
dlm_delete_debug_comms_file(node->debugfs);
1314+
12881315
spin_lock(&nodes_lock);
12891316
hlist_del_rcu(&node->hlist);
12901317
spin_unlock(&nodes_lock);

fs/dlm/midcomms.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#ifndef __MIDCOMMS_DOT_H__
1313
#define __MIDCOMMS_DOT_H__
1414

15+
struct midcomms_node;
16+
1517
int dlm_process_incoming_buffer(int nodeid, unsigned char *buf, int buflen);
1618
struct dlm_mhandle *dlm_midcomms_get_mhandle(int nodeid, int len,
1719
gfp_t allocation, char **ppc);
@@ -22,6 +24,10 @@ void dlm_midcomms_shutdown(void);
2224
void dlm_midcomms_add_member(int nodeid);
2325
void dlm_midcomms_remove_member(int nodeid);
2426
void dlm_midcomms_unack_msg_resend(int nodeid);
27+
const char *dlm_midcomms_state(struct midcomms_node *node);
28+
unsigned long dlm_midcomms_flags(struct midcomms_node *node);
29+
int dlm_midcomms_send_queue_cnt(struct midcomms_node *node);
30+
uint32_t dlm_midcomms_version(struct midcomms_node *node);
2531

2632
#endif /* __MIDCOMMS_DOT_H__ */
2733

0 commit comments

Comments
 (0)