On Wed, Sep 04, 2019 at 07:27:32PM +0300, Max Gurtovoy wrote:
> @@ -1405,6 +1406,11 @@ bool blk_update_request(struct request *req,
> blk_status_t error,
> if (!req->bio)
> return false;
>
> + if (blk_integrity_rq(req) && req_op(req) == REQ_OP_READ &&
> + error == BLK_STS_OK)
> + t10_pi_complete(req,
> + nr_bytes >> blk_integrity_interval_shift(req->q));
I think it would be nicer to just pass nr_bytes to t10_pi_complete and
do the calculation internally. That keeps the caller a littler cleaner.
> -void t10_pi_prepare(struct request *rq, u8 protection_type)
> +void t10_pi_prepare(struct request *rq)
> {
> + u8 protection_type = rq->rq_disk->protection_type;
The protection_type variable is only used once, so we might as well
remove it.
> +void t10_pi_complete(struct request *rq, unsigned int intervals)
> {
> + u8 protection_type = rq->rq_disk->protection_type;
Same here.
> +static void nvme_set_disk_prot_type(struct nvme_ns *ns, struct gendisk *disk)
> +{
> + switch (ns->pi_type) {
> + case NVME_NS_DPS_PI_TYPE1:
> + disk->protection_type = T10_PI_TYPE1_PROTECTION;
> + break;
> + case NVME_NS_DPS_PI_TYPE2:
> + disk->protection_type = T10_PI_TYPE2_PROTECTION;
> + break;
> + case NVME_NS_DPS_PI_TYPE3:
> + disk->protection_type = T10_PI_TYPE3_PROTECTION;
> + break;
> + default:
> + disk->protection_type = T10_PI_TYPE0_PROTECTION;
> + break;
> + }
> +}
We just passed the value in direttly before, so I think we can keep
it that way. In fact it might make sense to just remove the
NVME_NS_DPS_PI_TYPE* values entirely (in a separate patch).
But I think we should remove the pi_type field in struct nvme_ns here,
just like in sd.