Skip to content

Commit 1f6b281

Browse files
committed
Merge tag 'nvme-6.17-2025-09-04' of git://git.infradead.org/nvme into block-6.17
Pull NVMe fix from Keith: "nvme fixes for 6.17 - Fix protection information ref tag for device side gen/strip (Christoph)" * tag 'nvme-6.17-2025-09-04' of git://git.infradead.org/nvme: nvme: fix PI insert on write
2 parents 95a7c50 + 7ac3c28 commit 1f6b281

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/nvme/host/core.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,15 @@ static void nvme_set_ref_tag(struct nvme_ns *ns, struct nvme_command *cmnd,
903903
u32 upper, lower;
904904
u64 ref48;
905905

906+
/* only type1 and type 2 PI formats have a reftag */
907+
switch (ns->head->pi_type) {
908+
case NVME_NS_DPS_PI_TYPE1:
909+
case NVME_NS_DPS_PI_TYPE2:
910+
break;
911+
default:
912+
return;
913+
}
914+
906915
/* both rw and write zeroes share the same reftag format */
907916
switch (ns->head->guard_type) {
908917
case NVME_NVM_NS_16B_GUARD:
@@ -942,13 +951,7 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns,
942951

943952
if (nvme_ns_has_pi(ns->head)) {
944953
cmnd->write_zeroes.control |= cpu_to_le16(NVME_RW_PRINFO_PRACT);
945-
946-
switch (ns->head->pi_type) {
947-
case NVME_NS_DPS_PI_TYPE1:
948-
case NVME_NS_DPS_PI_TYPE2:
949-
nvme_set_ref_tag(ns, cmnd, req);
950-
break;
951-
}
954+
nvme_set_ref_tag(ns, cmnd, req);
952955
}
953956

954957
return BLK_STS_OK;
@@ -1039,6 +1042,7 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
10391042
if (WARN_ON_ONCE(!nvme_ns_has_pi(ns->head)))
10401043
return BLK_STS_NOTSUPP;
10411044
control |= NVME_RW_PRINFO_PRACT;
1045+
nvme_set_ref_tag(ns, cmnd, req);
10421046
}
10431047

10441048
if (bio_integrity_flagged(req->bio, BIP_CHECK_GUARD))

0 commit comments

Comments
 (0)