Skip to content

Commit aaeb7bb

Browse files
author
Christoph Hellwig
committed
nvme: set the PRACT bit when using Write Zeroes with T10 PI
When using Write Zeroes on a namespace that has protection information enabled they behavior without the PRACT bit counter-intuitive and will generally lead to validation failures when reading the written blocks. Fix this by always setting the PRACT bit that generates matching PI data on the fly. Fixes: 6e02318 ("nvme: add support for the Write Zeroes command") Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Keith Busch <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]>
1 parent 234211b commit aaeb7bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,10 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns,
900900
cpu_to_le64(nvme_sect_to_lba(ns, blk_rq_pos(req)));
901901
cmnd->write_zeroes.length =
902902
cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1);
903-
cmnd->write_zeroes.control = 0;
903+
if (nvme_ns_has_pi(ns))
904+
cmnd->write_zeroes.control = cpu_to_le16(NVME_RW_PRINFO_PRACT);
905+
else
906+
cmnd->write_zeroes.control = 0;
904907
return BLK_STS_OK;
905908
}
906909

0 commit comments

Comments
 (0)