From: Greg Kroah-Hartman Date: Mon, 5 Oct 2020 13:24:26 +0000 (+0200) Subject: 5.4-stable patches X-Git-Tag: v4.19.150~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=930f4848d0aced51869f6638ce837c1452314376;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: nvme-cleanup-and-rename-nvme_block_nr.patch nvme-consolidate-chunk_sectors-settings.patch nvme-introduce-nvme_lba_to_sect.patch --- diff --git a/queue-5.4/nvme-cleanup-and-rename-nvme_block_nr.patch b/queue-5.4/nvme-cleanup-and-rename-nvme_block_nr.patch new file mode 100644 index 00000000000..ffc2b96bf0d --- /dev/null +++ b/queue-5.4/nvme-cleanup-and-rename-nvme_block_nr.patch @@ -0,0 +1,72 @@ +From 314d48dd224897e35ddcaf5a1d7d133b5adddeb7 Mon Sep 17 00:00:00 2001 +From: Damien Le Moal +Date: Mon, 21 Oct 2019 12:40:03 +0900 +Subject: nvme: Cleanup and rename nvme_block_nr() + +From: Damien Le Moal + +commit 314d48dd224897e35ddcaf5a1d7d133b5adddeb7 upstream. + +Rename nvme_block_nr() to nvme_sect_to_lba() and use SECTOR_SHIFT +instead of its hard coded value 9. Also add a comment to decribe this +helper. + +Reviewed-by: Johannes Thumshirn +Reviewed-by: Christoph Hellwig +Signed-off-by: Damien Le Moal +Signed-off-by: Keith Busch +Signed-off-by: Jens Axboe +Signed-off-by: Revanth Rajashekar 1 +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvme/host/core.c | 6 +++--- + drivers/nvme/host/nvme.h | 7 +++++-- + 2 files changed, 8 insertions(+), 5 deletions(-) + +--- a/drivers/nvme/host/core.c ++++ b/drivers/nvme/host/core.c +@@ -630,7 +630,7 @@ static blk_status_t nvme_setup_discard(s + } + + __rq_for_each_bio(bio, req) { +- u64 slba = nvme_block_nr(ns, bio->bi_iter.bi_sector); ++ u64 slba = nvme_sect_to_lba(ns, bio->bi_iter.bi_sector); + u32 nlb = bio->bi_iter.bi_size >> ns->lba_shift; + + if (n < segments) { +@@ -671,7 +671,7 @@ static inline blk_status_t nvme_setup_wr + cmnd->write_zeroes.opcode = nvme_cmd_write_zeroes; + cmnd->write_zeroes.nsid = cpu_to_le32(ns->head->ns_id); + cmnd->write_zeroes.slba = +- cpu_to_le64(nvme_block_nr(ns, blk_rq_pos(req))); ++ cpu_to_le64(nvme_sect_to_lba(ns, blk_rq_pos(req))); + cmnd->write_zeroes.length = + cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1); + cmnd->write_zeroes.control = 0; +@@ -695,7 +695,7 @@ static inline blk_status_t nvme_setup_rw + + cmnd->rw.opcode = (rq_data_dir(req) ? nvme_cmd_write : nvme_cmd_read); + cmnd->rw.nsid = cpu_to_le32(ns->head->ns_id); +- cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, blk_rq_pos(req))); ++ cmnd->rw.slba = cpu_to_le64(nvme_sect_to_lba(ns, blk_rq_pos(req))); + cmnd->rw.length = cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1); + + if (req_op(req) == REQ_OP_WRITE && ctrl->nr_streams) +--- a/drivers/nvme/host/nvme.h ++++ b/drivers/nvme/host/nvme.h +@@ -429,9 +429,12 @@ static inline int nvme_reset_subsystem(s + return ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65); + } + +-static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector) ++/* ++ * Convert a 512B sector number to a device logical block number. ++ */ ++static inline u64 nvme_sect_to_lba(struct nvme_ns *ns, sector_t sector) + { +- return (sector >> (ns->lba_shift - 9)); ++ return sector >> (ns->lba_shift - SECTOR_SHIFT); + } + + static inline void nvme_end_request(struct request *req, __le16 status, diff --git a/queue-5.4/nvme-consolidate-chunk_sectors-settings.patch b/queue-5.4/nvme-consolidate-chunk_sectors-settings.patch new file mode 100644 index 00000000000..b8a9bc2c986 --- /dev/null +++ b/queue-5.4/nvme-consolidate-chunk_sectors-settings.patch @@ -0,0 +1,94 @@ +From 38adf94e166e3cb4eb89683458ca578051e8218d Mon Sep 17 00:00:00 2001 +From: Keith Busch +Date: Thu, 9 Apr 2020 09:09:06 -0700 +Subject: nvme: consolidate chunk_sectors settings + +From: Keith Busch + +commit 38adf94e166e3cb4eb89683458ca578051e8218d upstream. + +Move the quirked chunk_sectors setting to the same location as noiob so +one place registers this setting. And since the noiob value is only used +locally, remove the member from struct nvme_ns. + +Signed-off-by: Keith Busch +Reviewed-by: Sagi Grimberg +Signed-off-by: Christoph Hellwig +Signed-off-by: Jens Axboe +Signed-off-by: Revanth Rajashekar +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvme/host/core.c | 22 ++++++++++------------ + drivers/nvme/host/nvme.h | 1 - + 2 files changed, 10 insertions(+), 13 deletions(-) + +--- a/drivers/nvme/host/core.c ++++ b/drivers/nvme/host/core.c +@@ -1680,12 +1680,6 @@ static void nvme_init_integrity(struct g + } + #endif /* CONFIG_BLK_DEV_INTEGRITY */ + +-static void nvme_set_chunk_size(struct nvme_ns *ns) +-{ +- u32 chunk_size = nvme_lba_to_sect(ns, ns->noiob); +- blk_queue_chunk_sectors(ns->queue, rounddown_pow_of_two(chunk_size)); +-} +- + static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns) + { + struct nvme_ctrl *ctrl = ns->ctrl; +@@ -1840,6 +1834,7 @@ static void nvme_update_disk_info(struct + static void __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id) + { + struct nvme_ns *ns = disk->private_data; ++ u32 iob; + + /* + * If identify namespace failed, use default 512 byte block size so +@@ -1848,7 +1843,13 @@ static void __nvme_revalidate_disk(struc + ns->lba_shift = id->lbaf[id->flbas & NVME_NS_FLBAS_LBA_MASK].ds; + if (ns->lba_shift == 0) + ns->lba_shift = 9; +- ns->noiob = le16_to_cpu(id->noiob); ++ ++ if ((ns->ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) && ++ is_power_of_2(ns->ctrl->max_hw_sectors)) ++ iob = ns->ctrl->max_hw_sectors; ++ else ++ iob = nvme_lba_to_sect(ns, le16_to_cpu(id->noiob)); ++ + ns->ms = le16_to_cpu(id->lbaf[id->flbas & NVME_NS_FLBAS_LBA_MASK].ms); + ns->ext = ns->ms && (id->flbas & NVME_NS_FLBAS_META_EXT); + /* the PI implementation requires metadata equal t10 pi tuple size */ +@@ -1857,8 +1858,8 @@ static void __nvme_revalidate_disk(struc + else + ns->pi_type = 0; + +- if (ns->noiob) +- nvme_set_chunk_size(ns); ++ if (iob) ++ blk_queue_chunk_sectors(ns->queue, rounddown_pow_of_two(iob)); + nvme_update_disk_info(disk, ns, id); + #ifdef CONFIG_NVME_MULTIPATH + if (ns->head->disk) { +@@ -2209,9 +2210,6 @@ static void nvme_set_queue_limits(struct + blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors); + blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX)); + } +- if ((ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) && +- is_power_of_2(ctrl->max_hw_sectors)) +- blk_queue_chunk_sectors(q, ctrl->max_hw_sectors); + blk_queue_virt_boundary(q, ctrl->page_size - 1); + if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) + vwc = true; +--- a/drivers/nvme/host/nvme.h ++++ b/drivers/nvme/host/nvme.h +@@ -384,7 +384,6 @@ struct nvme_ns { + #define NVME_NS_REMOVING 0 + #define NVME_NS_DEAD 1 + #define NVME_NS_ANA_PENDING 2 +- u16 noiob; + + struct nvme_fault_inject fault_inject; + diff --git a/queue-5.4/nvme-introduce-nvme_lba_to_sect.patch b/queue-5.4/nvme-introduce-nvme_lba_to_sect.patch new file mode 100644 index 00000000000..e201379c25f --- /dev/null +++ b/queue-5.4/nvme-introduce-nvme_lba_to_sect.patch @@ -0,0 +1,89 @@ +From e08f2ae850929d40e66268ee47e443e7ea56eeb7 Mon Sep 17 00:00:00 2001 +From: Damien Le Moal +Date: Mon, 21 Oct 2019 12:40:04 +0900 +Subject: nvme: Introduce nvme_lba_to_sect() + +From: Damien Le Moal + +commit e08f2ae850929d40e66268ee47e443e7ea56eeb7 upstream. + +Introduce the new helper function nvme_lba_to_sect() to convert a device +logical block number to a 512B sector number. Use this new helper in +obvious places, cleaning up the code. + +Reviewed-by: Johannes Thumshirn +Reviewed-by: Christoph Hellwig +Signed-off-by: Damien Le Moal +Signed-off-by: Keith Busch +Signed-off-by: Jens Axboe +Signed-off-by: Revanth Rajashekar +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/nvme/host/core.c | 14 +++++++------- + drivers/nvme/host/nvme.h | 8 ++++++++ + 2 files changed, 15 insertions(+), 7 deletions(-) + +--- a/drivers/nvme/host/core.c ++++ b/drivers/nvme/host/core.c +@@ -1682,7 +1682,7 @@ static void nvme_init_integrity(struct g + + static void nvme_set_chunk_size(struct nvme_ns *ns) + { +- u32 chunk_size = (((u32)ns->noiob) << (ns->lba_shift - 9)); ++ u32 chunk_size = nvme_lba_to_sect(ns, ns->noiob); + blk_queue_chunk_sectors(ns->queue, rounddown_pow_of_two(chunk_size)); + } + +@@ -1719,8 +1719,7 @@ static void nvme_config_discard(struct g + + static void nvme_config_write_zeroes(struct gendisk *disk, struct nvme_ns *ns) + { +- u32 max_sectors; +- unsigned short bs = 1 << ns->lba_shift; ++ u64 max_blocks; + + if (!(ns->ctrl->oncs & NVME_CTRL_ONCS_WRITE_ZEROES) || + (ns->ctrl->quirks & NVME_QUIRK_DISABLE_WRITE_ZEROES)) +@@ -1736,11 +1735,12 @@ static void nvme_config_write_zeroes(str + * nvme_init_identify() if available. + */ + if (ns->ctrl->max_hw_sectors == UINT_MAX) +- max_sectors = ((u32)(USHRT_MAX + 1) * bs) >> 9; ++ max_blocks = (u64)USHRT_MAX + 1; + else +- max_sectors = ((u32)(ns->ctrl->max_hw_sectors + 1) * bs) >> 9; ++ max_blocks = ns->ctrl->max_hw_sectors + 1; + +- blk_queue_max_write_zeroes_sectors(disk->queue, max_sectors); ++ blk_queue_max_write_zeroes_sectors(disk->queue, ++ nvme_lba_to_sect(ns, max_blocks)); + } + + static int nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid, +@@ -1774,7 +1774,7 @@ static bool nvme_ns_ids_equal(struct nvm + static void nvme_update_disk_info(struct gendisk *disk, + struct nvme_ns *ns, struct nvme_id_ns *id) + { +- sector_t capacity = le64_to_cpu(id->nsze) << (ns->lba_shift - 9); ++ sector_t capacity = nvme_lba_to_sect(ns, le64_to_cpu(id->nsze)); + unsigned short bs = 1 << ns->lba_shift; + u32 atomic_bs, phys_bs, io_opt; + +--- a/drivers/nvme/host/nvme.h ++++ b/drivers/nvme/host/nvme.h +@@ -437,6 +437,14 @@ static inline u64 nvme_sect_to_lba(struc + return sector >> (ns->lba_shift - SECTOR_SHIFT); + } + ++/* ++ * Convert a device logical block number to a 512B sector number. ++ */ ++static inline sector_t nvme_lba_to_sect(struct nvme_ns *ns, u64 lba) ++{ ++ return lba << (ns->lba_shift - SECTOR_SHIFT); ++} ++ + static inline void nvme_end_request(struct request *req, __le16 status, + union nvme_result result) + { diff --git a/queue-5.4/series b/queue-5.4/series index d6f6f837cd4..6ce9f2558bd 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -47,3 +47,6 @@ random32-restore-__latent_entropy-attribute-on-net_r.patch block-diskstats-more-accurate-approximation-of-io_ticks-for-slow-disks.patch mm-replace-memmap_context-by-meminit_context.patch mm-don-t-rely-on-system-state-to-detect-hot-plug-operations.patch +nvme-cleanup-and-rename-nvme_block_nr.patch +nvme-introduce-nvme_lba_to_sect.patch +nvme-consolidate-chunk_sectors-settings.patch