> -     if (scsi_prot_sg_count(cmd))
> -             sg_free_table_chained(&cmd->prot_sdb->table, true);
> +     if (scsi_prot_sg_count(cmd) && cmd->prot_sdb->table.sgl !=
> +                     scsi_prot_inline_sg(cmd))
> +             sg_free_table_chained(&cmd->prot_sdb->table, false);

Nipick: I usually find it easier to read if we break around conditions
instead of inside them:

        if (scsi_prot_sg_count(cmd) &&
            cmd->prot_sdb->table.sgl != scsi_prot_inline_sg(cmd))

> +             if (ivecs <= SCSI_INLINE_PROT_SG_CNT) {
> +                     scsi_init_inline_sg_table(&prot_sdb->table,
> +                                               scsi_prot_inline_sg(cmd),
> +                                               SCSI_INLINE_PROT_SG_CNT);
> +             } else if (sg_alloc_table_chained(&prot_sdb->table,
> +                                               ivecs, NULL)) {

Hmm.  Maybe we just need to pass an nr_inline_vecs argument
to sg_alloc_table_chained to replace the SG_CHUNK_SIZE argument instead
of open coding this logic?

If we'd also pass it to sg_free_table_chained we could also simplify
those checks in all callers.

Reply via email to