From: Christoph Hellwig <hch@lst.de>
To: axboe@kernel.dk
Cc: sagi@grimberg.me, kbusch@kernel.org, song@kernel.org,
linux-block@vger.kernel.org, linux-raid@vger.kernel.org,
linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/2] nvme: remove support or stream based temperature hint
Date: Fri, 4 Mar 2022 18:55:55 +0100 [thread overview]
Message-ID: <20220304175556.407719-1-hch@lst.de> (raw)
This support was added for RocksDB, but RocksDB ended up not using it.
At the same time drives on the open marked (vs those build for OEMs
for non-Linux support) that actually support streams are extremly
rare. Don't bloat the nvme driver for it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/core.c | 140 ---------------------------------------
1 file changed, 140 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 5e0bfda04bd7b..ca1504c178162 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -77,10 +77,6 @@ module_param(apst_secondary_latency_tol_us, ulong, 0644);
MODULE_PARM_DESC(apst_secondary_latency_tol_us,
"secondary APST latency tolerance in us");
-static bool streams;
-module_param(streams, bool, 0644);
-MODULE_PARM_DESC(streams, "turn on support for Streams write directives");
-
/*
* nvme_wq - hosts nvme related works that are not reset or delete
* nvme_reset_wq - hosts nvme reset works
@@ -714,105 +710,6 @@ bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
}
EXPORT_SYMBOL_GPL(__nvme_check_ready);
-static int nvme_toggle_streams(struct nvme_ctrl *ctrl, bool enable)
-{
- struct nvme_command c = { };
-
- c.directive.opcode = nvme_admin_directive_send;
- c.directive.nsid = cpu_to_le32(NVME_NSID_ALL);
- c.directive.doper = NVME_DIR_SND_ID_OP_ENABLE;
- c.directive.dtype = NVME_DIR_IDENTIFY;
- c.directive.tdtype = NVME_DIR_STREAMS;
- c.directive.endir = enable ? NVME_DIR_ENDIR : 0;
-
- return nvme_submit_sync_cmd(ctrl->admin_q, &c, NULL, 0);
-}
-
-static int nvme_disable_streams(struct nvme_ctrl *ctrl)
-{
- return nvme_toggle_streams(ctrl, false);
-}
-
-static int nvme_enable_streams(struct nvme_ctrl *ctrl)
-{
- return nvme_toggle_streams(ctrl, true);
-}
-
-static int nvme_get_stream_params(struct nvme_ctrl *ctrl,
- struct streams_directive_params *s, u32 nsid)
-{
- struct nvme_command c = { };
-
- memset(s, 0, sizeof(*s));
-
- c.directive.opcode = nvme_admin_directive_recv;
- c.directive.nsid = cpu_to_le32(nsid);
- c.directive.numd = cpu_to_le32(nvme_bytes_to_numd(sizeof(*s)));
- c.directive.doper = NVME_DIR_RCV_ST_OP_PARAM;
- c.directive.dtype = NVME_DIR_STREAMS;
-
- return nvme_submit_sync_cmd(ctrl->admin_q, &c, s, sizeof(*s));
-}
-
-static int nvme_configure_directives(struct nvme_ctrl *ctrl)
-{
- struct streams_directive_params s;
- int ret;
-
- if (!(ctrl->oacs & NVME_CTRL_OACS_DIRECTIVES))
- return 0;
- if (!streams)
- return 0;
-
- ret = nvme_enable_streams(ctrl);
- if (ret)
- return ret;
-
- ret = nvme_get_stream_params(ctrl, &s, NVME_NSID_ALL);
- if (ret)
- goto out_disable_stream;
-
- ctrl->nssa = le16_to_cpu(s.nssa);
- if (ctrl->nssa < BLK_MAX_WRITE_HINTS - 1) {
- dev_info(ctrl->device, "too few streams (%u) available\n",
- ctrl->nssa);
- goto out_disable_stream;
- }
-
- ctrl->nr_streams = min_t(u16, ctrl->nssa, BLK_MAX_WRITE_HINTS - 1);
- dev_info(ctrl->device, "Using %u streams\n", ctrl->nr_streams);
- return 0;
-
-out_disable_stream:
- nvme_disable_streams(ctrl);
- return ret;
-}
-
-/*
- * Check if 'req' has a write hint associated with it. If it does, assign
- * a valid namespace stream to the write.
- */
-static void nvme_assign_write_stream(struct nvme_ctrl *ctrl,
- struct request *req, u16 *control,
- u32 *dsmgmt)
-{
- enum rw_hint streamid = req->write_hint;
-
- if (streamid == WRITE_LIFE_NOT_SET || streamid == WRITE_LIFE_NONE)
- streamid = 0;
- else {
- streamid--;
- if (WARN_ON_ONCE(streamid > ctrl->nr_streams))
- return;
-
- *control |= NVME_RW_DTYPE_STREAMS;
- *dsmgmt |= streamid << 16;
- }
-
- if (streamid < ARRAY_SIZE(req->q->write_hints))
- req->q->write_hints[streamid] += blk_rq_bytes(req) >> 9;
-}
-
static inline void nvme_setup_flush(struct nvme_ns *ns,
struct nvme_command *cmnd)
{
@@ -916,7 +813,6 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
struct request *req, struct nvme_command *cmnd,
enum nvme_opcode op)
{
- struct nvme_ctrl *ctrl = ns->ctrl;
u16 control = 0;
u32 dsmgmt = 0;
@@ -939,9 +835,6 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
cmnd->rw.apptag = 0;
cmnd->rw.appmask = 0;
- if (req_op(req) == REQ_OP_WRITE && ctrl->nr_streams)
- nvme_assign_write_stream(ctrl, req, &control, &dsmgmt);
-
if (ns->ms) {
/*
* If formated with metadata, the block layer always provides a
@@ -1662,9 +1555,6 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
return;
}
- if (ctrl->nr_streams && ns->sws && ns->sgs)
- size *= ns->sws * ns->sgs;
-
BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
NVME_DSM_MAX_RANGES);
@@ -1697,31 +1587,6 @@ static bool nvme_ns_ids_equal(struct nvme_ns_ids *a, struct nvme_ns_ids *b)
a->csi == b->csi;
}
-static int nvme_setup_streams_ns(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
- u32 *phys_bs, u32 *io_opt)
-{
- struct streams_directive_params s;
- int ret;
-
- if (!ctrl->nr_streams)
- return 0;
-
- ret = nvme_get_stream_params(ctrl, &s, ns->head->ns_id);
- if (ret)
- return ret;
-
- ns->sws = le32_to_cpu(s.sws);
- ns->sgs = le16_to_cpu(s.sgs);
-
- if (ns->sws) {
- *phys_bs = ns->sws * (1 << ns->lba_shift);
- if (ns->sgs)
- *io_opt = *phys_bs * ns->sgs;
- }
-
- return 0;
-}
-
static int nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
{
struct nvme_ctrl *ctrl = ns->ctrl;
@@ -1814,7 +1679,6 @@ static void nvme_update_disk_info(struct gendisk *disk,
blk_integrity_unregister(disk);
atomic_bs = phys_bs = bs;
- nvme_setup_streams_ns(ns->ctrl, ns, &phys_bs, &io_opt);
if (id->nabo == 0) {
/*
* Bit 1 indicates whether NAWUPF is defined for this namespace
@@ -3103,10 +2967,6 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
if (ret < 0)
return ret;
- ret = nvme_configure_directives(ctrl);
- if (ret < 0)
- return ret;
-
ret = nvme_configure_acre(ctrl);
if (ret < 0)
return ret;
--
2.30.2
next reply other threads:[~2022-03-04 17:56 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 17:55 Christoph Hellwig [this message]
2022-03-04 17:55 ` [PATCH 2/2] block: remove the per-bio/request write hint Christoph Hellwig
2022-03-04 19:24 ` Jens Axboe
2022-03-04 22:12 ` Dave Chinner
2022-03-05 5:19 ` Christoph Hellwig
2022-03-05 21:40 ` Dave Chinner
2022-03-05 23:55 ` Bart Van Assche
2022-03-06 17:11 ` Jens Axboe
2022-03-06 18:01 ` Christoph Hellwig
2022-03-06 18:06 ` Jens Axboe
2022-03-06 23:17 ` Dave Chinner
[not found] ` <CGME20220309042324epcas1p111312e20f4429dc3a17172458284a923@epcas1p1.samsung.com>
2022-03-09 13:31 ` Manjong Lee
2022-03-09 8:24 ` Paul Menzel
2022-03-10 11:34 ` [EXT] " Luca Porzio (lporzio)
2022-03-10 12:15 ` Jens Axboe
2022-03-10 18:50 ` Luca Porzio (lporzio)
2022-03-10 19:10 ` Jens Axboe
2022-03-10 19:34 ` Bart Van Assche
2022-03-10 21:52 ` Bean Huo (beanhuo)
2022-03-10 22:10 ` Jens Axboe
2022-03-11 16:45 ` Bart Van Assche
2022-03-11 16:56 ` Jens Axboe
2022-03-14 7:40 ` Avi Shchislowski
2022-03-14 8:00 ` hch
2022-03-14 19:50 ` Eric Biggers
2022-03-14 19:58 ` [EXT] " Jens Axboe
2022-03-15 15:36 ` Luca Porzio (lporzio)
2022-03-15 15:44 ` Jens Axboe
2022-03-10 22:18 ` Bart Van Assche
2022-03-11 5:31 ` Eric Biggers
2022-03-11 9:21 ` Luca Porzio (lporzio)
2022-03-10 14:21 ` hch
2022-03-10 18:51 ` Luca Porzio (lporzio)
2022-03-10 19:14 ` hch
2022-03-11 5:06 ` Eric Biggers
2022-03-11 9:23 ` Luca Porzio (lporzio)
2022-03-04 19:34 ` [PATCH 1/2] nvme: remove support or stream based temperature hint Keith Busch
2022-03-04 19:36 ` Christoph Hellwig
2022-03-04 19:38 ` Jens Axboe
2022-03-04 20:20 ` Jens Axboe
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=20220304175556.407719-1-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-raid@vger.kernel.org \
--cc=sagi@grimberg.me \
--cc=song@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 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).