From: Alexander Aring <aahringo@redhat.com>
To: teigland@redhat.com
Cc: gfs2@lists.linux.dev, aahringo@redhat.com
Subject: [PATCH dlm/next 2/5] dlm: introduce lockspace control debugfs entry
Date: Wed, 13 Nov 2024 11:46:40 -0500 [thread overview]
Message-ID: <20241113164643.464055-2-aahringo@redhat.com> (raw)
In-Reply-To: <20241113164643.464055-1-aahringo@redhat.com>
To create nowadays a kernel lockspace we need to call the kernel API.
This will provide a debugfs entry to do so. It is named "__ctrl" as the
debugfs entries my collide with lockspace names. It still can but it is
more unlikely as it has a "__" prefix.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/debug_fs.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index c76320acefc1..49ad31120286 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -26,6 +26,7 @@ static struct mutex debug_buf_lock;
static struct dentry *dlm_root;
static struct dentry *dlm_comms;
+static struct dentry *dlm_ctrl;
static char *print_lockmode(int mode)
{
@@ -759,6 +760,36 @@ void dlm_delete_debug_comms_file(void *ctx)
debugfs_remove(ctx);
}
+static ssize_t dlm_ctrl_write(struct file *fp, const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ char clname[DLM_LOCKSPACE_LEN + 1] = {};
+ char lsname[DLM_LOCKSPACE_LEN + 1] = {};
+ dlm_lockspace_t *ls;
+ char buf[512] = {};
+ int rv, n;
+
+ if (copy_from_user(buf, user_buf,
+ min_t(size_t, sizeof(buf) - 1, count)))
+ return -EFAULT;
+
+ n = sscanf(buf, "%" __stringify(DLM_LOCKSPACE_LEN) "s %" __stringify(DLM_LOCKSPACE_LEN) "s",
+ lsname, clname);
+ if (n != 2)
+ return -EINVAL;
+
+ rv = dlm_new_lockspace(lsname, clname, 0, 0, NULL, NULL, NULL, &ls);
+ if (rv)
+ return rv;
+
+ return count;
+}
+
+static const struct file_operations dlm_ctrl_fops = {
+ .open = simple_open,
+ .write = dlm_ctrl_write,
+};
+
void dlm_create_debug_file(struct dlm_ls *ls)
{
/* Reserve enough space for the longest file name */
@@ -816,6 +847,8 @@ 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_ctrl = debugfs_create_file("__ctrl", 0644, dlm_root, NULL,
+ &dlm_ctrl_fops);
}
void dlm_unregister_debugfs(void)
--
2.43.0
next prev parent reply other threads:[~2024-11-13 16:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-13 16:46 [PATCH dlm/next 1/5] dlm: new max length for debugfs entry name Alexander Aring
2024-11-13 16:46 ` Alexander Aring [this message]
2024-11-13 16:46 ` [PATCH dlm/next 3/5] dlm: extend debugfs to manipulate more DLM states Alexander Aring
2024-11-13 16:46 ` [PATCH dlm/next 4/5] dlm: fix middle conversion cases in DLM recovery Alexander Aring
2024-11-13 16:46 ` [PATCH dlm/next 5/5] dlm: more debug info on invalid lock requests 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=20241113164643.464055-2-aahringo@redhat.com \
--to=aahringo@redhat.com \
--cc=gfs2@lists.linux.dev \
--cc=teigland@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