From: Mikulas Patocka <mpatocka@redhat.com>
To: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Benjamin Marzinski <bmarzins@redhat.com>,
Bruce Johnston <bjohnsto@redhat.com>,
Matthew Sakai <msakai@redhat.com>
Cc: dm-devel@lists.linux.dev
Subject: Re: [RFC PATCH] dm: add deviceless messages
Date: Tue, 12 May 2026 15:39:31 +0200 (CEST) [thread overview]
Message-ID: <ba49d68e-ece2-f56c-6b25-e47e87ef739f@redhat.com> (raw)
In-Reply-To: <3bdbd9fa-52ce-ab52-569f-29d4a30c6780@redhat.com>
On Tue, 12 May 2026, Mikulas Patocka wrote:
> The VDO code needs to perform some calculations before creating a device.
> The calculations should be performed in the kernel, so that the same logic
> is not duplicated in the kernel and in the userspace.
>
> However, currently it is not possible to call a device mapper target
> when no device exists.
>
> This commit solves the problem by adding "deviceless" messages. If the
> message starts with '%', the name is a name of a target, not a name of a
> device. The message will be directed to the target by calling the
> "deviceless_message" method. The target can perform the requested
> calculations in this method and return the result back to userspace.
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
This is example code how to use deviceless messages. You can call it with
"dmsetup message linear 0 %Hello"
Mikulas
---
drivers/md/dm-linear.c | 10 ++++++++++
1 file changed, 10 insertions(+)
Index: linux-2.6/drivers/md/dm-linear.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-linear.c 2026-05-11 13:00:08.000000000 +0200
+++ linux-2.6/drivers/md/dm-linear.c 2026-05-11 13:00:14.000000000 +0200
@@ -199,6 +199,15 @@ static size_t linear_dax_recovery_write(
#define linear_dax_recovery_write NULL
#endif
+static int linear_deviceless_message(unsigned int argc, char **argv, char *result, unsigned int maxlen)
+{
+ if (argc == 1 && !strcasecmp(argv[0], "%Hello")) {
+ snprintf(result, maxlen, "World!");
+ return 1;
+ }
+ return -EINVAL;
+}
+
static struct target_type linear_target = {
.name = "linear",
.version = {1, 5, 0},
@@ -211,6 +220,7 @@ static struct target_type linear_target
.dtr = linear_dtr,
.map = linear_map,
.status = linear_status,
+ .deviceless_message = linear_deviceless_message,
.prepare_ioctl = linear_prepare_ioctl,
.iterate_devices = linear_iterate_devices,
.direct_access = linear_dax_direct_access,
next prev parent reply other threads:[~2026-05-12 13:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 13:36 [RFC PATCH] dm: add deviceless messages Mikulas Patocka
2026-05-12 13:39 ` Mikulas Patocka [this message]
2026-05-12 17:31 ` Benjamin Marzinski
2026-05-12 19:26 ` Matthew Sakai
2026-05-13 10:37 ` Mikulas Patocka
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=ba49d68e-ece2-f56c-6b25-e47e87ef739f@redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=bjohnsto@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=msakai@redhat.com \
--cc=snitzer@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.