Commit aaeb7bb0 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

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: 6e02318e ("nvme: add support for the Write Zeroes command")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 234211b8
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -900,6 +900,9 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns,
		cpu_to_le64(nvme_sect_to_lba(ns, blk_rq_pos(req)));
		cpu_to_le64(nvme_sect_to_lba(ns, blk_rq_pos(req)));
	cmnd->write_zeroes.length =
	cmnd->write_zeroes.length =
		cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1);
		cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1);
	if (nvme_ns_has_pi(ns))
		cmnd->write_zeroes.control = cpu_to_le16(NVME_RW_PRINFO_PRACT);
	else
		cmnd->write_zeroes.control = 0;
		cmnd->write_zeroes.control = 0;
	return BLK_STS_OK;
	return BLK_STS_OK;
}
}