Skip to content

Commit 85e6c77

Browse files
Christoph Hellwigaxboe
authored andcommitted
nvme: remove support or stream based temperature hint
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 <[email protected]> Acked-by: Jens Axboe <[email protected]> Reviewed-by: Keith Busch <[email protected]> Link: https://lore.kernel.org/r/[email protected] [axboe: fold in ctrl->nr_streams removal from Keith] Signed-off-by: Jens Axboe <[email protected]>
1 parent 8291100 commit 85e6c77

File tree

2 files changed

+0
-144
lines changed

2 files changed

+0
-144
lines changed

drivers/nvme/host/core.c

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ module_param(apst_secondary_latency_tol_us, ulong, 0644);
7777
MODULE_PARM_DESC(apst_secondary_latency_tol_us,
7878
"secondary APST latency tolerance in us");
7979

80-
static bool streams;
81-
module_param(streams, bool, 0644);
82-
MODULE_PARM_DESC(streams, "turn on support for Streams write directives");
83-
8480
/*
8581
* nvme_wq - hosts nvme related works that are not reset or delete
8682
* nvme_reset_wq - hosts nvme reset works
@@ -748,108 +744,6 @@ bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
748744
}
749745
EXPORT_SYMBOL_GPL(__nvme_check_ready);
750746

751-
static int nvme_toggle_streams(struct nvme_ctrl *ctrl, bool enable)
752-
{
753-
struct nvme_command c = { };
754-
755-
c.directive.opcode = nvme_admin_directive_send;
756-
c.directive.nsid = cpu_to_le32(NVME_NSID_ALL);
757-
c.directive.doper = NVME_DIR_SND_ID_OP_ENABLE;
758-
c.directive.dtype = NVME_DIR_IDENTIFY;
759-
c.directive.tdtype = NVME_DIR_STREAMS;
760-
c.directive.endir = enable ? NVME_DIR_ENDIR : 0;
761-
762-
return nvme_submit_sync_cmd(ctrl->admin_q, &c, NULL, 0);
763-
}
764-
765-
static int nvme_disable_streams(struct nvme_ctrl *ctrl)
766-
{
767-
return nvme_toggle_streams(ctrl, false);
768-
}
769-
770-
static int nvme_enable_streams(struct nvme_ctrl *ctrl)
771-
{
772-
return nvme_toggle_streams(ctrl, true);
773-
}
774-
775-
static int nvme_get_stream_params(struct nvme_ctrl *ctrl,
776-
struct streams_directive_params *s, u32 nsid)
777-
{
778-
struct nvme_command c = { };
779-
780-
memset(s, 0, sizeof(*s));
781-
782-
c.directive.opcode = nvme_admin_directive_recv;
783-
c.directive.nsid = cpu_to_le32(nsid);
784-
c.directive.numd = cpu_to_le32(nvme_bytes_to_numd(sizeof(*s)));
785-
c.directive.doper = NVME_DIR_RCV_ST_OP_PARAM;
786-
c.directive.dtype = NVME_DIR_STREAMS;
787-
788-
return nvme_submit_sync_cmd(ctrl->admin_q, &c, s, sizeof(*s));
789-
}
790-
791-
static int nvme_configure_directives(struct nvme_ctrl *ctrl)
792-
{
793-
struct streams_directive_params s;
794-
u16 nssa;
795-
int ret;
796-
797-
if (!(ctrl->oacs & NVME_CTRL_OACS_DIRECTIVES))
798-
return 0;
799-
if (!streams)
800-
return 0;
801-
802-
ret = nvme_enable_streams(ctrl);
803-
if (ret)
804-
return ret;
805-
806-
ret = nvme_get_stream_params(ctrl, &s, NVME_NSID_ALL);
807-
if (ret)
808-
goto out_disable_stream;
809-
810-
nssa = le16_to_cpu(s.nssa);
811-
if (nssa < BLK_MAX_WRITE_HINTS - 1) {
812-
dev_info(ctrl->device, "too few streams (%u) available\n",
813-
nssa);
814-
/* this condition is not an error: streams are optional */
815-
ret = 0;
816-
goto out_disable_stream;
817-
}
818-
819-
ctrl->nr_streams = min_t(u16, nssa, BLK_MAX_WRITE_HINTS - 1);
820-
dev_info(ctrl->device, "Using %u streams\n", ctrl->nr_streams);
821-
return 0;
822-
823-
out_disable_stream:
824-
nvme_disable_streams(ctrl);
825-
return ret;
826-
}
827-
828-
/*
829-
* Check if 'req' has a write hint associated with it. If it does, assign
830-
* a valid namespace stream to the write.
831-
*/
832-
static void nvme_assign_write_stream(struct nvme_ctrl *ctrl,
833-
struct request *req, u16 *control,
834-
u32 *dsmgmt)
835-
{
836-
enum rw_hint streamid = req->write_hint;
837-
838-
if (streamid == WRITE_LIFE_NOT_SET || streamid == WRITE_LIFE_NONE)
839-
streamid = 0;
840-
else {
841-
streamid--;
842-
if (WARN_ON_ONCE(streamid > ctrl->nr_streams))
843-
return;
844-
845-
*control |= NVME_RW_DTYPE_STREAMS;
846-
*dsmgmt |= streamid << 16;
847-
}
848-
849-
if (streamid < ARRAY_SIZE(req->q->write_hints))
850-
req->q->write_hints[streamid] += blk_rq_bytes(req) >> 9;
851-
}
852-
853747
static inline void nvme_setup_flush(struct nvme_ns *ns,
854748
struct nvme_command *cmnd)
855749
{
@@ -953,7 +847,6 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
953847
struct request *req, struct nvme_command *cmnd,
954848
enum nvme_opcode op)
955849
{
956-
struct nvme_ctrl *ctrl = ns->ctrl;
957850
u16 control = 0;
958851
u32 dsmgmt = 0;
959852

@@ -976,9 +869,6 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
976869
cmnd->rw.apptag = 0;
977870
cmnd->rw.appmask = 0;
978871

979-
if (req_op(req) == REQ_OP_WRITE && ctrl->nr_streams)
980-
nvme_assign_write_stream(ctrl, req, &control, &dsmgmt);
981-
982872
if (ns->ms) {
983873
/*
984874
* If formated with metadata, the block layer always provides a
@@ -1697,9 +1587,6 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
16971587
return;
16981588
}
16991589

1700-
if (ctrl->nr_streams && ns->sws && ns->sgs)
1701-
size *= ns->sws * ns->sgs;
1702-
17031590
BUILD_BUG_ON(PAGE_SIZE / sizeof(struct nvme_dsm_range) <
17041591
NVME_DSM_MAX_RANGES);
17051592

@@ -1725,31 +1612,6 @@ static bool nvme_ns_ids_equal(struct nvme_ns_ids *a, struct nvme_ns_ids *b)
17251612
a->csi == b->csi;
17261613
}
17271614

1728-
static int nvme_setup_streams_ns(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
1729-
u32 *phys_bs, u32 *io_opt)
1730-
{
1731-
struct streams_directive_params s;
1732-
int ret;
1733-
1734-
if (!ctrl->nr_streams)
1735-
return 0;
1736-
1737-
ret = nvme_get_stream_params(ctrl, &s, ns->head->ns_id);
1738-
if (ret)
1739-
return ret;
1740-
1741-
ns->sws = le32_to_cpu(s.sws);
1742-
ns->sgs = le16_to_cpu(s.sgs);
1743-
1744-
if (ns->sws) {
1745-
*phys_bs = ns->sws * (1 << ns->lba_shift);
1746-
if (ns->sgs)
1747-
*io_opt = *phys_bs * ns->sgs;
1748-
}
1749-
1750-
return 0;
1751-
}
1752-
17531615
static void nvme_configure_metadata(struct nvme_ns *ns, struct nvme_id_ns *id)
17541616
{
17551617
struct nvme_ctrl *ctrl = ns->ctrl;
@@ -1841,7 +1703,6 @@ static void nvme_update_disk_info(struct gendisk *disk,
18411703
blk_integrity_unregister(disk);
18421704

18431705
atomic_bs = phys_bs = bs;
1844-
nvme_setup_streams_ns(ns->ctrl, ns, &phys_bs, &io_opt);
18451706
if (id->nabo == 0) {
18461707
/*
18471708
* Bit 1 indicates whether NAWUPF is defined for this namespace
@@ -3131,10 +2992,6 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
31312992
if (ret < 0)
31322993
return ret;
31332994

3134-
ret = nvme_configure_directives(ctrl);
3135-
if (ret < 0)
3136-
return ret;
3137-
31382995
ret = nvme_configure_acre(ctrl);
31392996
if (ret < 0)
31402997
return ret;

drivers/nvme/host/nvme.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ struct nvme_ctrl {
280280
u16 crdt[3];
281281
u16 oncs;
282282
u16 oacs;
283-
u16 nr_streams;
284283
u16 sqsize;
285284
u32 max_namespaces;
286285
atomic_t abort_limit;

0 commit comments

Comments
 (0)