diff options
author | Guixin Liu <kanie@linux.alibaba.com> | 2024-11-04 16:55:00 +0800 |
---|---|---|
committer | Keith Busch <kbusch@kernel.org> | 2024-11-11 09:49:50 -0800 |
commit | 8a825d22a70915bd80c811fa93538cf2540af29d (patch) | |
tree | 9604187b32f4d5333c4e00bf5157627ccc11e0f1 /drivers/nvme | |
parent | 1d811438851bae0d5593a9ecc0736db4b3c6d994 (diff) |
nvme: check ns's volatile write cache not present
When the VWC of a namespace does not exist, the BLK_FEAT_WRITE_CACHE
flag should not be set when registering the block device, regardless
of whether the controller supports VWC.
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/host/core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 6f51dde7de6c..e119ba0f8ab8 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -43,6 +43,7 @@ struct nvme_ns_info { bool is_ready; bool is_removed; bool is_rotational; + bool no_vwc; }; unsigned int admin_timeout = 60; @@ -1617,6 +1618,7 @@ static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl, info->is_readonly = id->nsattr & NVME_NS_ATTR_RO; info->is_ready = id->nstat & NVME_NSTAT_NRDY; info->is_rotational = id->nsfeat & NVME_NS_ROTATIONAL; + info->no_vwc = id->nsfeat & NVME_NS_VWC_NOT_PRESENT; } kfree(id); return ret; @@ -2159,7 +2161,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns, ns->head->ids.csi == NVME_CSI_ZNS) nvme_update_zone_info(ns, &lim, &zi); - if (ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT) + if ((ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT) && !info->no_vwc) lim.features |= BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA; else lim.features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA); |