Skip to content

Commit f467b48

Browse files
Christoph Hellwigkeithbusch
authored andcommitted
nvme: cleanup the nvme_init_integrity calling conventions
Handle the no metadata support case in nvme_init_integrity as well to simplify the calling convention and prepare for future changes in the area. 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 f404dd9 commit f467b48

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

drivers/nvme/host/core.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,11 +1723,21 @@ int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
17231723
return 0;
17241724
}
17251725

1726-
#ifdef CONFIG_BLK_DEV_INTEGRITY
1727-
static void nvme_init_integrity(struct gendisk *disk, struct nvme_ns_head *head)
1726+
static bool nvme_init_integrity(struct gendisk *disk, struct nvme_ns_head *head)
17281727
{
17291728
struct blk_integrity integrity = { };
17301729

1730+
if (!head->ms)
1731+
return true;
1732+
1733+
/*
1734+
* PI can always be supported as we can ask the controller to simply
1735+
* insert/strip it, which is not possible for other kinds of metadata.
1736+
*/
1737+
if (!IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) ||
1738+
!(head->features & NVME_NS_METADATA_SUPPORTED))
1739+
return nvme_ns_has_pi(head);
1740+
17311741
switch (head->pi_type) {
17321742
case NVME_NS_DPS_PI_TYPE3:
17331743
switch (head->guard_type) {
@@ -1772,12 +1782,8 @@ static void nvme_init_integrity(struct gendisk *disk, struct nvme_ns_head *head)
17721782
integrity.tuple_size = head->ms;
17731783
integrity.pi_offset = head->pi_offset;
17741784
blk_integrity_register(disk, &integrity);
1785+
return true;
17751786
}
1776-
#else
1777-
static void nvme_init_integrity(struct gendisk *disk, struct nvme_ns_head *head)
1778-
{
1779-
}
1780-
#endif /* CONFIG_BLK_DEV_INTEGRITY */
17811787

17821788
static void nvme_config_discard(struct nvme_ctrl *ctrl, struct gendisk *disk,
17831789
struct nvme_ns_head *head)
@@ -2012,13 +2018,8 @@ static void nvme_update_disk_info(struct nvme_ctrl *ctrl, struct gendisk *disk,
20122018
* I/O to namespaces with metadata except when the namespace supports
20132019
* PI, as it can strip/insert in that case.
20142020
*/
2015-
if (head->ms) {
2016-
if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) &&
2017-
(head->features & NVME_NS_METADATA_SUPPORTED))
2018-
nvme_init_integrity(disk, head);
2019-
else if (!nvme_ns_has_pi(head))
2020-
capacity = 0;
2021-
}
2021+
if (!nvme_init_integrity(disk, head))
2022+
capacity = 0;
20222023

20232024
set_capacity_and_notify(disk, capacity);
20242025

0 commit comments

Comments
 (0)