Skip to content

Commit 1d81143

Browse files
wangyugui-e16keithbusch
authored andcommitted
nvme: add rotational support
Rotational devices, such as hard-drives, can be detected using the rotational bit in the namespace independent identify namespace data structure. Make the bit visible to the block layer through the rotational queue setting. Signed-off-by: Wang Yugui <[email protected]> Reviewed-by: Matias Bjørling <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent ee9f36d commit 1d81143

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/nvme/host/core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct nvme_ns_info {
4242
bool is_readonly;
4343
bool is_ready;
4444
bool is_removed;
45+
bool is_rotational;
4546
};
4647

4748
unsigned int admin_timeout = 60;
@@ -1615,6 +1616,7 @@ static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl,
16151616
info->is_shared = id->nmic & NVME_NS_NMIC_SHARED;
16161617
info->is_readonly = id->nsattr & NVME_NS_ATTR_RO;
16171618
info->is_ready = id->nstat & NVME_NSTAT_NRDY;
1619+
info->is_rotational = id->nsfeat & NVME_NS_ROTATIONAL;
16181620
}
16191621
kfree(id);
16201622
return ret;
@@ -2162,6 +2164,9 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
21622164
else
21632165
lim.features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA);
21642166

2167+
if (info->is_rotational)
2168+
lim.features |= BLK_FEAT_ROTATIONAL;
2169+
21652170
/*
21662171
* Register a metadata profile for PI, or the plain non-integrity NVMe
21672172
* metadata masquerading as Type 0 if supported, otherwise reject block
@@ -3608,6 +3613,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
36083613
head->ns_id = info->nsid;
36093614
head->ids = info->ids;
36103615
head->shared = info->is_shared;
3616+
head->rotational = info->is_rotational;
36113617
ratelimit_state_init(&head->rs_nuse, 5 * HZ, 1);
36123618
ratelimit_set_flags(&head->rs_nuse, RATELIMIT_MSG_ON_RELEASE);
36133619
kref_init(&head->ref);

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ struct nvme_ns_head {
474474
struct list_head entry;
475475
struct kref ref;
476476
bool shared;
477+
bool rotational;
477478
bool passthru_err_log_enabled;
478479
struct nvme_effects_log *effects;
479480
u64 nuse;

0 commit comments

Comments
 (0)