Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvme: fold nvme_config_discard() into nvme_update_disk_info()

The choice of what queue limits are set in nvme_update_disk_info() vs.
nvme_config_discard() seems a bit arbitrary. A subsequent commit will
compute the discard_granularity limit using struct nvme_id_ns, which is
only passed to nvme_update_disk_info() currently. So move the logic in
nvme_config_discard() to nvme_update_disk_info(). Replace several
instances of ns->ctrl in nvme_update_disk_info() with the ctrl variable
brought from nvme_config_discard().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Caleb Sander Mateos and committed by
Keith Busch
9110b852 ac61e869

+19 -24
+19 -24
drivers/nvme/host/core.c
··· 1884 1884 return true; 1885 1885 } 1886 1886 1887 - static void nvme_config_discard(struct nvme_ns *ns, struct queue_limits *lim) 1888 - { 1889 - struct nvme_ctrl *ctrl = ns->ctrl; 1890 - 1891 - if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(ns->head, UINT_MAX)) 1892 - lim->max_hw_discard_sectors = 1893 - nvme_lba_to_sect(ns->head, ctrl->dmrsl); 1894 - else if (ctrl->oncs & NVME_CTRL_ONCS_DSM) 1895 - lim->max_hw_discard_sectors = UINT_MAX; 1896 - else 1897 - lim->max_hw_discard_sectors = 0; 1898 - 1899 - lim->discard_granularity = lim->logical_block_size; 1900 - 1901 - if (ctrl->dmrl) 1902 - lim->max_discard_segments = ctrl->dmrl; 1903 - else 1904 - lim->max_discard_segments = NVME_DSM_MAX_RANGES; 1905 - } 1906 - 1907 1887 static bool nvme_ns_ids_equal(struct nvme_ns_ids *a, struct nvme_ns_ids *b) 1908 1888 { 1909 1889 return uuid_equal(&a->uuid, &b->uuid) && ··· 2062 2082 struct queue_limits *lim) 2063 2083 { 2064 2084 struct nvme_ns_head *head = ns->head; 2085 + struct nvme_ctrl *ctrl = ns->ctrl; 2065 2086 u32 bs = 1U << head->lba_shift; 2066 2087 u32 atomic_bs, phys_bs, io_opt = 0; 2067 2088 bool valid = true; ··· 2097 2116 lim->physical_block_size = min(phys_bs, atomic_bs); 2098 2117 lim->io_min = phys_bs; 2099 2118 lim->io_opt = io_opt; 2100 - if ((ns->ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) && 2101 - (ns->ctrl->oncs & NVME_CTRL_ONCS_DSM)) 2119 + if ((ctrl->quirks & NVME_QUIRK_DEALLOCATE_ZEROES) && 2120 + (ctrl->oncs & NVME_CTRL_ONCS_DSM)) 2102 2121 lim->max_write_zeroes_sectors = UINT_MAX; 2103 2122 else 2104 - lim->max_write_zeroes_sectors = ns->ctrl->max_zeroes_sectors; 2123 + lim->max_write_zeroes_sectors = ctrl->max_zeroes_sectors; 2124 + 2125 + if (ctrl->dmrsl && ctrl->dmrsl <= nvme_sect_to_lba(ns->head, UINT_MAX)) 2126 + lim->max_hw_discard_sectors = 2127 + nvme_lba_to_sect(ns->head, ctrl->dmrsl); 2128 + else if (ctrl->oncs & NVME_CTRL_ONCS_DSM) 2129 + lim->max_hw_discard_sectors = UINT_MAX; 2130 + else 2131 + lim->max_hw_discard_sectors = 0; 2132 + 2133 + lim->discard_granularity = lim->logical_block_size; 2134 + 2135 + if (ctrl->dmrl) 2136 + lim->max_discard_segments = ctrl->dmrl; 2137 + else 2138 + lim->max_discard_segments = NVME_DSM_MAX_RANGES; 2105 2139 return valid; 2106 2140 } 2107 2141 ··· 2381 2385 if (!nvme_update_disk_info(ns, id, &lim)) 2382 2386 capacity = 0; 2383 2387 2384 - nvme_config_discard(ns, &lim); 2385 2388 if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && 2386 2389 ns->head->ids.csi == NVME_CSI_ZNS) 2387 2390 nvme_update_zone_info(ns, &lim, &zi);