Skip to content

Commit d60c23e

Browse files
Christoph Hellwigkeithbusch
authored andcommitted
nvme: move setting the write cache flags out of nvme_set_queue_limits
nvme_set_queue_limits is used on the admin queue and all gendisks including hidden ones that don't support block I/O. The write cache setting on the other hand only makes sense for block I/O. Move the blk_queue_write_cache call to nvme_update_ns_info_block instead. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent a5b1cd6 commit d60c23e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/nvme/host/core.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,15 +1954,12 @@ static u32 nvme_max_drv_segments(struct nvme_ctrl *ctrl)
19541954
static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
19551955
struct request_queue *q)
19561956
{
1957-
bool vwc = ctrl->vwc & NVME_CTRL_VWC_PRESENT;
1958-
19591957
blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors);
19601958
blk_queue_max_segments(q, min_t(u32, USHRT_MAX,
19611959
min_not_zero(nvme_max_drv_segments(ctrl), ctrl->max_segments)));
19621960
blk_queue_max_integrity_segments(q, ctrl->max_integrity_segments);
19631961
blk_queue_virt_boundary(q, NVME_CTRL_PAGE_SIZE - 1);
19641962
blk_queue_dma_alignment(q, 3);
1965-
blk_queue_write_cache(q, vwc, vwc);
19661963
}
19671964

19681965
static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id)
@@ -2093,6 +2090,7 @@ static int nvme_update_ns_info_generic(struct nvme_ns *ns,
20932090
static int nvme_update_ns_info_block(struct nvme_ns *ns,
20942091
struct nvme_ns_info *info)
20952092
{
2093+
bool vwc = ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT;
20962094
struct nvme_id_ns *id;
20972095
sector_t capacity;
20982096
unsigned lbaf;
@@ -2154,6 +2152,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
21542152
if ((id->dlfeat & 0x7) == 0x1 && (id->dlfeat & (1 << 3)))
21552153
ns->head->features |= NVME_NS_DEAC;
21562154
set_disk_ro(ns->disk, nvme_ns_is_readonly(ns, info));
2155+
blk_queue_write_cache(ns->disk->queue, vwc, vwc);
21572156
set_bit(NVME_NS_READY, &ns->flags);
21582157
blk_mq_unfreeze_queue(ns->disk->queue);
21592158

0 commit comments

Comments
 (0)