[PATCH] nvmet-tcp: fix data digest calculation for multiple H2CData PDUs

Sagi Grimberg sagi at grimberg.me
Tue Aug 1 06:07:50 PDT 2023



On 8/1/23 11:26, Varun Prakash wrote:
> 
>> Maybe instead of (re)coding crypto_ahash_digest, maybe we can do a
>> little hack to pass the request sg from cmd->sg_idx which is already
>> set when we build the pdu?
>>
>> Something like:
>> --
>> +static void nvmet_tcp_calc_recv_ddgst(struct ahash_request *hash,
>> +               struct nvmet_tcp_cmd *cmd)
>> +{
>> +       struct scatterlist *sg;
>> +       u32 sg_offset;
>> +
>> +       sg = &cmd->req.sg[cmd->sg_idx];
>> +
>> +       /*
>> +        * adjust the offset for the first sg element if the received bytes
>> +        * is not aligned to page size (and adjust back after the ddgst
>> +        * calculation). A bit hacky but we don't need to do the hash digest
>> +        * update per sg entry this way.
>> +        */
>> +       sg_offset = cmd->rbytes_done % PAGE_SIZE;
>> +       sg->offset -= sg_offset;
>> +       __nvmet_tcp_calc_ddgst(hash, sg, (void *)&cmd->exp_ddgst,
>> cmd->pdu_len);
>> +       sg->offset += sg_offset;
>> }
>> --
> 
> In case of offset instead of updating sg->offset can we calculate digest
> for first sg separately by using local sg variable?

Possible, want to give it a go?



More information about the Linux-nvme mailing list