From: Guixin Liu <kanie@linux.alibaba.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Nilay Shroff <nilay@linux.ibm.com>,
Daniel Wagner <dwagner@suse.de>,
John Garry <john.g.garry@oracle.com>,
Hannes Reinecke <hare@suse.de>
Cc: linux-nvme@lists.infradead.org
Subject: [PATCH 10/11] nvmet: translate placement identifiers of writes to write streams
Date: Tue, 13 Oct 2026 10:21:08 +0800 [thread overview]
Message-ID: <20261013022109.1507911-11-kanie@linux.alibaba.com> (raw)
In-Reply-To: <20261013022109.1507911-1-kanie@linux.alibaba.com>
A write command that carries the Data Placement Directive names a
placement identifier in the Directive Specific field. Both sides of
the bridge use identity mapped handles: the write streams of the
backing device map to the placement handles one by one, in the order
the reclaim unit handle status reports them. Translate the placement
identifier to the matching backing write stream on the write path, so
the data lands in the reclaim unit of the backing device that the
host selected. The enable of the namespace has verified that the
backing placement identifiers are identity mapped.
Writes without the directive, and writes with a placement identifier
that is out of range, keep the default stream 0: the spec lets the
controller place such data itself.
Assisted-by: LLM
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
drivers/nvme/target/io-cmd-bdev.c | 4 ++++
drivers/nvme/target/nvmet.h | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c
index f2d9e8901df4e..ff480f9ab9906 100644
--- a/drivers/nvme/target/io-cmd-bdev.c
+++ b/drivers/nvme/target/io-cmd-bdev.c
@@ -300,6 +300,10 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
bio->bi_iter.bi_sector = sector;
bio->bi_private = req;
bio->bi_end_io = nvmet_bio_done;
+ if (req->cmd->rw.opcode == nvme_cmd_write &&
+ nvmet_fdp_enabled(req->ns)) {
+ bio->bi_write_stream = nvmet_fdp_write_stream(req);
+ }
blk_start_plug(&plug);
if (req->metadata_len)
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 5bcc719973a57..af77591053226 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -1005,6 +1005,26 @@ void nvmet_execute_io_mgmt_recv(struct nvmet_req *req);
void nvmet_execute_io_mgmt_send(struct nvmet_req *req);
void nvmet_execute_get_log_page_fdp_configs(struct nvmet_req *req);
void nvmet_fdp_log_forward(struct nvmet_req *req);
+
+/*
+ * Both sides of the bridge use identity mapped handles, so placement
+ * identifier i routes to backing write stream i+1; stream 0, the
+ * default, places the data without a directive.
+ */
+static inline u8 nvmet_fdp_write_stream(struct nvmet_req *req)
+{
+ u16 control = le16_to_cpu(req->cmd->rw.control);
+ u16 pid;
+
+ if ((control & 0xf0) != (NVME_RW_DTYPE_DPLCMT & 0xf0))
+ return 0;
+
+ pid = le32_to_cpu(req->cmd->rw.dsmgmt) >> 16;
+ if (pid >= req->ns->fdp.nruh)
+ return 0;
+
+ return pid + 1;
+}
#else
static inline bool nvmet_fdp_enabled(struct nvmet_ns *ns)
{
--
2.43.7
next prev parent reply other threads:[~2026-10-13 2:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 2:20 [PATCH 0/11] nvmet: FDP bridge for NVMe-oF targets Guixin Liu
2026-10-13 2:20 ` [PATCH 01/11] nvme: add the FDP wire structures for the I/O management send command Guixin Liu
2026-10-13 2:21 ` [PATCH 02/11] block: add bdev_write_stream_granularity() Guixin Liu
2026-10-13 2:21 ` [PATCH 03/11] nvme: export nvme_bdev_ops Guixin Liu
2026-10-13 2:21 ` [PATCH 04/11] nvmet: add per-namespace FDP bridge state and configuration Guixin Liu
2026-10-13 2:21 ` [PATCH 05/11] nvmet: report the Endurance Group Identifier in the CS-INDEP identify data Guixin Liu
2026-10-13 2:21 ` [PATCH 06/11] nvmet: advertise the FDP capability Guixin Liu
2026-10-13 2:21 ` [PATCH 07/11] nvmet: implement the FDP feature Guixin Liu
2026-10-13 2:21 ` [PATCH 08/11] nvmet: forward the FDP I/O management commands to the backing device Guixin Liu
2026-10-13 2:21 ` [PATCH 09/11] nvmet: serve the FDP log pages Guixin Liu
2026-10-13 2:21 ` Guixin Liu [this message]
2026-10-13 2:21 ` [PATCH 11/11] nvmet: add an FDP write translation tracepoint Guixin Liu
-- strict thread matches above, loose matches on Subject: below --
2026-10-19 3:36 [PATCH RESEND 0/11] nvmet: FDP bridge for NVMe-oF targets Guixin Liu
2026-10-19 3:36 ` [PATCH 10/11] nvmet: translate placement identifiers of writes to write streams Guixin Liu
2026-10-19 3:44 ` sashiko-bot
2026-10-19 8:27 ` Guixin Liu
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=20261013022109.1507911-11-kanie@linux.alibaba.com \
--to=kanie@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=john.g.garry@oracle.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nilay@linux.ibm.com \
--cc=sagi@grimberg.me \
/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