Skip to content

Commit eded04f

Browse files
committed
Merge tag 'nvme-6.11-2024-08-08' of git://git.infradead.org/nvme into block-6.11
Pull NVMe fixes from Keith: "nvme fixes for Linux 6.11 - Cleanups and improved struct packing (Kanchan)" * tag 'nvme-6.11-2024-08-08' of git://git.infradead.org/nvme: nvme: reorganize nvme_ns_head fields nvme: change data type of lba_shift nvme: remove a field from nvme_ns_head nvme: remove unused parameter
2 parents 01aa8c8 + b4c1f33 commit eded04f

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

drivers/nvme/host/core.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct nvme_ns_info {
3636
struct nvme_ns_ids ids;
3737
u32 nsid;
3838
__le32 anagrpid;
39+
u8 pi_offset;
3940
bool is_shared;
4041
bool is_readonly;
4142
bool is_ready;
@@ -1757,8 +1758,8 @@ int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
17571758
return 0;
17581759
}
17591760

1760-
static bool nvme_init_integrity(struct gendisk *disk, struct nvme_ns_head *head,
1761-
struct queue_limits *lim)
1761+
static bool nvme_init_integrity(struct nvme_ns_head *head,
1762+
struct queue_limits *lim, struct nvme_ns_info *info)
17621763
{
17631764
struct blk_integrity *bi = &lim->integrity;
17641765

@@ -1816,7 +1817,7 @@ static bool nvme_init_integrity(struct gendisk *disk, struct nvme_ns_head *head,
18161817
}
18171818

18181819
bi->tuple_size = head->ms;
1819-
bi->pi_offset = head->pi_offset;
1820+
bi->pi_offset = info->pi_offset;
18201821
return true;
18211822
}
18221823

@@ -1902,12 +1903,11 @@ static void nvme_configure_pi_elbas(struct nvme_ns_head *head,
19021903

19031904
static void nvme_configure_metadata(struct nvme_ctrl *ctrl,
19041905
struct nvme_ns_head *head, struct nvme_id_ns *id,
1905-
struct nvme_id_ns_nvm *nvm)
1906+
struct nvme_id_ns_nvm *nvm, struct nvme_ns_info *info)
19061907
{
19071908
head->features &= ~(NVME_NS_METADATA_SUPPORTED | NVME_NS_EXT_LBAS);
19081909
head->pi_type = 0;
19091910
head->pi_size = 0;
1910-
head->pi_offset = 0;
19111911
head->ms = le16_to_cpu(id->lbaf[nvme_lbaf_index(id->flbas)].ms);
19121912
if (!head->ms || !(ctrl->ops->flags & NVME_F_METADATA_SUPPORTED))
19131913
return;
@@ -1922,7 +1922,7 @@ static void nvme_configure_metadata(struct nvme_ctrl *ctrl,
19221922
if (head->pi_size && head->ms >= head->pi_size)
19231923
head->pi_type = id->dps & NVME_NS_DPS_PI_MASK;
19241924
if (!(id->dps & NVME_NS_DPS_PI_FIRST))
1925-
head->pi_offset = head->ms - head->pi_size;
1925+
info->pi_offset = head->ms - head->pi_size;
19261926

19271927
if (ctrl->ops->flags & NVME_F_FABRICS) {
19281928
/*
@@ -2156,7 +2156,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
21562156

21572157
lim = queue_limits_start_update(ns->disk->queue);
21582158
nvme_set_ctrl_limits(ns->ctrl, &lim);
2159-
nvme_configure_metadata(ns->ctrl, ns->head, id, nvm);
2159+
nvme_configure_metadata(ns->ctrl, ns->head, id, nvm, info);
21602160
nvme_set_chunk_sectors(ns, id, &lim);
21612161
if (!nvme_update_disk_info(ns, id, &lim))
21622162
capacity = 0;
@@ -2176,7 +2176,7 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
21762176
* I/O to namespaces with metadata except when the namespace supports
21772177
* PI, as it can strip/insert in that case.
21782178
*/
2179-
if (!nvme_init_integrity(ns->disk, ns->head, &lim))
2179+
if (!nvme_init_integrity(ns->head, &lim, info))
21802180
capacity = 0;
21812181

21822182
ret = queue_limits_commit_update(ns->disk->queue, &lim);
@@ -2280,7 +2280,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_ns_info *info)
22802280
if (unsupported)
22812281
ns->head->disk->flags |= GENHD_FL_HIDDEN;
22822282
else
2283-
nvme_init_integrity(ns->head->disk, ns->head, &lim);
2283+
nvme_init_integrity(ns->head, &lim, info);
22842284
ret = queue_limits_commit_update(ns->head->disk->queue, &lim);
22852285

22862286
set_capacity_and_notify(ns->head->disk, get_capacity(ns->disk));

drivers/nvme/host/nvme.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,20 +462,19 @@ struct nvme_ns_head {
462462
struct srcu_struct srcu;
463463
struct nvme_subsystem *subsys;
464464
struct nvme_ns_ids ids;
465+
u8 lba_shift;
466+
u16 ms;
467+
u16 pi_size;
468+
u8 pi_type;
469+
u8 guard_type;
465470
struct list_head entry;
466471
struct kref ref;
467472
bool shared;
468473
bool passthru_err_log_enabled;
469-
int instance;
470474
struct nvme_effects_log *effects;
471475
u64 nuse;
472476
unsigned ns_id;
473-
int lba_shift;
474-
u16 ms;
475-
u16 pi_size;
476-
u8 pi_type;
477-
u8 pi_offset;
478-
u8 guard_type;
477+
int instance;
479478
#ifdef CONFIG_BLK_DEV_ZONED
480479
u64 zsze;
481480
#endif

0 commit comments

Comments
 (0)